-
Notifications
You must be signed in to change notification settings - Fork 50
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
Build intx bignum library in CMake #245
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f7d54f4
Build libintx library for bignum
jakelang 3bed396
make intx not build tests or benchmarks using hacky sed patch on cmak…
jakelang 2a8a914
Update CMake file for INTX
jakelang ca909e7
make hera actually include intx properly
jakelang badab6e
fix safeLoadUint128 using intx
jakelang ae4cf8c
Add number of parallel jobs to Ninja build command
jakelang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
if(ProjectIntXIncluded) | ||
return() | ||
endif() | ||
|
||
set(ProjectIntXIncluded TRUE) | ||
|
||
include(ExternalProject) | ||
include(GNUInstallDirs) | ||
|
||
set(prefix ${CMAKE_BINARY_DIR}/deps) | ||
set(source_dir ${prefix}/src/intx) | ||
set(binary_dir ${prefix}/src/intx-build) | ||
|
||
set(intx_include_dir ${source_dir}/include/intx) | ||
set(intx_lib ${binary_dir}/libs/intx/libintx.a) | ||
|
||
set(patch_command sed -i -e "$ d" ${source_dir}/CMakeLists.txt) | ||
set(build_command cmake --build <BINARY_DIR>) | ||
set(install_command cmake --build <BINARY_DIR> --target install) | ||
|
||
if(CMAKE_GENERATOR STREQUAL Ninja) | ||
if($ENV{BUILD_PARALLEL_JOBS}) | ||
set(build_command cmake --build <BINARY_DIR> -- -j $ENV{BUILD_PARALLEL_JOBS}) | ||
message(STATUS "Ninja $ENV{BUILD_PARALLEL_JOBS}") | ||
endif() | ||
endif() | ||
|
||
ExternalProject_Add(intx | ||
PREFIX ${prefix} | ||
GIT_REPOSITORY https://github.com/chfast/intx.git | ||
GIT_TAG 1a10f4fc3433d5ce88ea4c6067002680e2ea0385 | ||
CMAKE_ARGS | ||
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> | ||
SOURCE_DIR ${source_dir} | ||
BINARY_DIR ${binary_dir} | ||
PATCH_COMMAND ${patch_command} | ||
BUILD_COMMAND ${build_command} | ||
INSTALL_COMMAND ${install_command} | ||
INSTALL_DIR ${prefix}/${CMAKE_INSTALL_LIBDIR} | ||
BUILD_BYPRODUCTS ${intx_lib} | ||
) | ||
|
||
add_library(intx::intx STATIC IMPORTED) | ||
|
||
file(MAKE_DIRECTORY ${intx_include_dir}) | ||
set_target_properties( | ||
intx::intx | ||
PROPERTIES | ||
IMPORTED_LOCATION_RELEASE ${intx_lib} | ||
INTERFACE_INCLUDE_DIRECTORIES ${intx_include_dir} | ||
INTERFACE_LINK_LIBRARIES ${intx_lib} | ||
) | ||
|
||
add_dependencies(intx::intx intx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You know that GCC / clang have
unsigned __int128
?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.
@chfast would have been cool if you could have mentioned that when the original issue was created :)
But according to https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html :
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.
So we can assume it works for x86-64 but not much else until we investigate
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 wasn't aware that 128-bit is the max precision you need.
Anyway, the type is available on 64-bit targets. Because you don't support MSVC at the moment it can be used as a temporary solution.