-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to use boost::multiprecision on platforms where int128_t i… #3430
Conversation
lib/CMakeLists.txt
Outdated
if (USE_BOOST_MULTIPREC) | ||
find_package(Boost REQUIRED COMPONENTS system) | ||
include_directories(${Boost_INCLUDE_DIRS}) | ||
add_compile_definitions(USE_BOOST_MULTIPREC) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use:
target_include_directories(lib_objs PUBLIC SYSTEM ${Boost_INCLUDE_DIRS})
target_compile_definitions(lib_objs PUBLIC USE_BOOST_MULTIPREC)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this makes it specific to lib_objs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's add_definitions(-DUSE_BOOST_MULTIPREC)
- target_compile_definitions()
is not available in CMake 2.8 (let's tackle a CMake update later - if I ever get healthy again).
Also those should be placed in findDependencies.cmake
and compilerDefinitions.cmake
.
Also those should be PRIVATE
so they don't spill into everything.
Dont we need to update |
I guess the MathLib::bigint change could be made in another PR. |
@@ -40,13 +40,18 @@ class Variable; | |||
#if defined(__GNUC__) && defined (__SIZEOF_INT128__) | |||
typedef __int128_t int128_t; | |||
#else | |||
#if defined(USE_BOOST_MULTIPREC) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be the first case. If we configure to use it we should use it across all platforms
@@ -43,3 +43,9 @@ add_library(lib_objs OBJECT ${srcs_lib} ${hdrs}) | |||
if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS) | |||
target_precompile_headers(lib_objs PRIVATE precompiled.h) | |||
endif() | |||
|
|||
if (USE_BOOST_MULTIPREC) | |||
find_package(Boost REQUIRED COMPONENTS system) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why system
? The component is just multiprecision
.
I am skeptic about taking in a boost dependency even if it's optional. I assume this is a msvc problem primarily. Is there no cleaner way to get this in windows also? |
@@ -997,7 +997,7 @@ ExprEngine::ConditionalValue::Vector ExprEngine::ArrayValue::read(ExprEngine::Va | |||
if (i->minValue >= 0 && i->minValue == i->maxValue) { | |||
int c = 0; | |||
if (i->minValue < stringLiteral->size()) | |||
c = stringLiteral->string[i->minValue]; | |||
c = stringLiteral->string[static_cast<size_t>(i->minValue)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is 128-bit now it will probably cause problems when it doesn't fit into size_t
.
Maybe using |
Hi @firewave good to see you.. I think we should look into using clang-cl in the windows build. as far as I have seen it makes the cppcheck binary a lot faster. For information, there is a ticket here: https://trac.cppcheck.net/ticket/10441 And then for the bughunting I am not 100% sure it was a good idea to use 128 bit integer. The Z3 library does not support this at all so we get 64-bit integers anyway in all expressions. Maybe a redesign is better.. |
Don't blink.
Well - I think it's up to the actual user which toolchain is being used. And having something which is available on all platforms seems better. But I also feel uneasy about having a Boost dependency. I would prefer something much lighter.
This was actually triggered by https://trac.cppcheck.net/ticket/9994 which has nothing to do with bug hunting. |
aha ok.. Do we have to make bigint 128 bit.. I have the feeling that some class like:
and then some convenient interface might work also..? and maybe that could handle calculations more properly also. |
I guess I won't waste time on CMake details until there is a consensus that this could be approved in principle... |
thanks @chrchr-github that sounds reasonable. |
We could incorporate calccrypto/uint128_t into cppcheck. We would need to write some code to make this work for signed integers(although all the arithmetic operations should be the same only the conversions need updated) and we may need fill in some of the math functions. However, using boost.multiprecision doesn't really need any extra code changes, so it seems simpler to integrate and then we can look into removing dependency in the future.
I am not sure how easy that can be used in place of I think it would be best to use boost.multiprecision as an optional dependency now and then we can look at better options in the future. Also, this is header only, so this does not require building boost nor will the final binaries have a dependency on boost. |
Good point.
"waste" - it's "learning" ;) |
BTW Please mark this a draft for now until the changes are finished/it has been decided about. Thanks. |
…s not available