-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OpenFHE] introduce common.jl to share source code with OpenFHE_int128 (
#9891) * [OpenFHE] introduce common.jl to share source code with OpenFHE_128 * add native_size * add space * remove enter * try to correct * Update common.jl * add comment to build_tarballs.jl * apply suggestions * Change source to get openFHE?128 also find the patch * rename to OpenFHE_int128 * Update O/OpenFHE/common.jl --------- Co-authored-by: Mosè Giordano <[email protected]>
- Loading branch information
1 parent
499bded
commit 3350e2a
Showing
3 changed files
with
94 additions
and
62 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
The OpenFHE library works with both 64-bit and 128-bit integers. | ||
|
||
This package builds the default 64-bit version. | ||
|
||
To build the 128-bit version, use | ||
[OpenFHE_int128](https://github.com/JuliaPackaging/Yggdrasil/tree/master/O/OpenFHE_int128). | ||
|
||
Most of the build steps for OpenFHE and | ||
[OpenFHE_int128](https://github.com/JuliaPackaging/Yggdrasil/tree/master/O/OpenFHE_int128) are the same, | ||
so the shared parts are in the | ||
[common.jl](https://github.com/JuliaPackaging/Yggdrasil/blob/master/O/OpenFHE/common.jl) script. |
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 |
---|---|---|
@@ -1,72 +1,15 @@ | ||
# Note that this script can accept some limited command-line arguments, run | ||
# `julia build_tarballs.jl --help` to see a usage message. | ||
using BinaryBuilder, Pkg | ||
include("common.jl") | ||
|
||
# If you make changes in this file, e.g., to release a new version, | ||
# be sure to also release a new version of `OpenFHE_int128` as well (see `../OpenFHE_int128/build_tarballs.jl`) | ||
name = "OpenFHE" | ||
version = v"1.2.3" | ||
|
||
# Collection of sources required to complete build | ||
sources = [ | ||
GitSource("https://github.com/openfheorg/openfhe-development.git", | ||
"7b8346f4eac27121543e36c17237b919e03ec058"), | ||
DirectorySource("./bundled") | ||
] | ||
git_hash = "7b8346f4eac27121543e36c17237b919e03ec058" | ||
|
||
# Bash recipe for building across all platforms | ||
script = raw""" | ||
cd $WORKSPACE/srcdir/openfhe-development/ | ||
# Set proper install directories for libraries on Windows | ||
if [[ "${target}" == *-mingw* ]]; then | ||
atomic_patch -p1 "${WORKSPACE}/srcdir/patches/windows-fix-cmake-libdir.patch" | ||
fi | ||
mkdir build && cd build | ||
cmake .. \ | ||
-DCMAKE_INSTALL_PREFIX=$prefix \ | ||
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DWITH_BE2=ON \ | ||
-DWITH_BE4=ON \ | ||
-DBUILD_UNITTESTS=OFF \ | ||
-DBUILD_BENCHMARKS=OFF | ||
make -j${nproc} | ||
make install | ||
""" | ||
|
||
# These are the platforms we will build for by default, unless further | ||
# platforms are passed in on the command line | ||
platforms = supported_platforms() | ||
|
||
# We cannot build with musl since OpenFHE requires the `execinfo.h` header for `backtrace` | ||
platforms = filter(p -> libc(p) != "musl", platforms) | ||
|
||
# PowerPC and 32-bit x86 platforms are not supported by OpenFHE | ||
platforms = filter(p -> arch(p) != "i686", platforms) | ||
platforms = filter(p -> arch(p) != "powerpc64le", platforms) | ||
|
||
# Expand C++ string ABIs since we use std::string | ||
platforms = expand_cxxstring_abis(platforms) | ||
|
||
|
||
# The products that we will ensure are always built | ||
products = [ | ||
LibraryProduct("libOPENFHEbinfhe", :libOPENFHEbinfhe), | ||
LibraryProduct("libOPENFHEpke", :libOPENFHEpke), | ||
LibraryProduct("libOPENFHEcore", :libOPENFHEcore), | ||
] | ||
|
||
# Dependencies that must be installed before this package can be built | ||
dependencies = Dependency[ | ||
# For OpenMP we use libomp from `LLVMOpenMP_jll` where we use LLVM as compiler (BSD | ||
# systems), and libgomp from `CompilerSupportLibraries_jll` everywhere else. | ||
Dependency(PackageSpec(name="CompilerSupportLibraries_jll", uuid="e66e0078-7015-5450-92f7-15fbd957f2ae"); | ||
platforms=filter(!Sys.isbsd, platforms)), | ||
Dependency(PackageSpec(name="LLVMOpenMP_jll", uuid="1d63c593-3942-5779-bab2-d838dc0a180e"); | ||
platforms=filter(Sys.isbsd, platforms)), | ||
] | ||
sources, script, platforms, products, dependencies = prepare_openfhe_build(name, git_hash) | ||
|
||
# Build the tarballs, and possibly a `build.jl` as well. | ||
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6", preferred_gcc_version = v"10.2.0") |
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,78 @@ | ||
using BinaryBuilder, Pkg | ||
|
||
function prepare_openfhe_build(name::String, git_hash::String) | ||
# Collection of sources required to complete build | ||
sources = [ | ||
GitSource("https://github.com/openfheorg/openfhe-development.git", | ||
git_hash), | ||
DirectorySource("../OpenFHE/bundled") | ||
] | ||
|
||
# Set native size for bash recipe | ||
native_size = (name == "OpenFHE_int128" ? 128 : 64) | ||
|
||
# Bash recipe for building across all platforms | ||
script = raw""" | ||
cd $WORKSPACE/srcdir/openfhe-development/ | ||
# Set proper install directories for libraries on Windows | ||
if [[ "${target}" == *-mingw* ]]; then | ||
atomic_patch -p1 "${WORKSPACE}/srcdir/patches/windows-fix-cmake-libdir.patch" | ||
fi | ||
mkdir build && cd build | ||
cmake .. \ | ||
-DCMAKE_INSTALL_PREFIX=$prefix \ | ||
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DWITH_BE2=ON \ | ||
-DWITH_BE4=ON \ | ||
-DBUILD_UNITTESTS=OFF \ | ||
-DBUILD_BENCHMARKS=OFF \ | ||
-DNATIVE_SIZE=""" * "$native_size" * | ||
raw""" | ||
make -j${nproc} | ||
make install | ||
""" | ||
|
||
# These are the platforms we will build for by default, unless further | ||
# platforms are passed in on the command line | ||
platforms = supported_platforms() | ||
|
||
# We cannot build with musl since OpenFHE requires the `execinfo.h` header for `backtrace` | ||
platforms = filter(p -> libc(p) != "musl", platforms) | ||
|
||
# PowerPC and 32-bit x86 platforms are not supported by OpenFHE | ||
platforms = filter(p -> arch(p) != "i686", platforms) | ||
platforms = filter(p -> arch(p) != "powerpc64le", platforms) | ||
|
||
# Expand C++ string ABIs since we use std::string | ||
platforms = expand_cxxstring_abis(platforms) | ||
|
||
# armv6l and armv7l do not support 128 bit int size | ||
if name == "OpenFHE_int128" | ||
platforms = filter(p -> arch(p) != "armv6l", platforms) | ||
platforms = filter(p -> arch(p) != "armv7l", platforms) | ||
end | ||
|
||
# The products that we will ensure are always built | ||
products = [ | ||
LibraryProduct("libOPENFHEbinfhe", :libOPENFHEbinfhe), | ||
LibraryProduct("libOPENFHEpke", :libOPENFHEpke), | ||
LibraryProduct("libOPENFHEcore", :libOPENFHEcore), | ||
] | ||
|
||
# Dependencies that must be installed before this package can be built | ||
dependencies = Dependency[ | ||
# For OpenMP we use libomp from `LLVMOpenMP_jll` where we use LLVM as compiler (BSD | ||
# systems), and libgomp from `CompilerSupportLibraries_jll` everywhere else. | ||
Dependency(PackageSpec(name="CompilerSupportLibraries_jll", uuid="e66e0078-7015-5450-92f7-15fbd957f2ae"); | ||
platforms=filter(!Sys.isbsd, platforms)), | ||
Dependency(PackageSpec(name="LLVMOpenMP_jll", uuid="1d63c593-3942-5779-bab2-d838dc0a180e"); | ||
platforms=filter(Sys.isbsd, platforms)), | ||
] | ||
|
||
return sources, script, platforms, products, dependencies | ||
end |