This repository has been archived by the owner on Jul 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
WIP: Pkg Artifacts with legacy mode #4
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
62d437f
add basic ccall test for flint (malloc+free)
benlorenz ec84f5a
use pkg artifacts
benlorenz d1d74fe
update for upstream FLINT_jll
benlorenz 2c2930c
cleanup
benlorenz 6223331
bump version
benlorenz 56e89f4
bump gmp and flint
benlorenz e7dbb47
add revdep tests
benlorenz 8a9dd24
minor improvements
benlorenz dcd6d55
Revert "bump gmp and flint"
benlorenz cbc18e3
travis: work around Pkg.jl / JULIA_PROJECT weirdness ....
benlorenz 1196ff5
bump to 0.2
benlorenz 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/deps/build.log | ||
/deps/build_*.jl | ||
/deps/deps.jl | ||
/deps/usr/ | ||
Manifest.toml |
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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
name = "LoadFlint" | ||
uuid = "472f376f-f1cf-461b-9ac1-d103423be9b7" | ||
authors = ["Claus Fieker <[email protected]>"] | ||
version = "0.1.3" | ||
version = "0.1.4" | ||
|
||
[deps] | ||
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" | ||
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232" | ||
FLINT_jll = "e134572f-a0d5-539d-bddf-3cad8db41a82" | ||
GMP_jll = "781609d7-10c4-51f6-84f2-b8444358ff6d" | ||
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" | ||
MPFR_jll = "3a97d323-0669-5f0c-9066-3539efd106a3" | ||
|
||
[compat] | ||
BinaryProvider = "0.4, 0.5" | ||
|
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,273 +1,61 @@ | ||
using Libdl | ||
|
||
using BinaryProvider | ||
|
||
# Parse some basic command-line arguments | ||
const verbose = "--verbose" in ARGS | ||
|
||
issource_build = "NEMO_SOURCE_BUILD" in keys(ENV) && ENV["NEMO_SOURCE_BUILD"] == "1" | ||
|
||
const prefixpath = joinpath(@__DIR__, "usr") | ||
|
||
const wdir = joinpath(@__DIR__) | ||
|
||
if !issource_build | ||
# Dependencies that must be installed before this package can be built | ||
dependencies = [ | ||
# This has to be in sync with the corresponding commit in the source build below (for flint, arb, antic) | ||
"https://github.com/JuliaPackaging/Yggdrasil/releases/download/GMP-v6.1.2-1/build_GMP.v6.1.2.jl", | ||
"https://github.com/JuliaPackaging/Yggdrasil/releases/download/MPFR-v4.0.2-1/build_MPFR.v4.0.2.jl", | ||
"https://github.com/thofma/Flint2Builder/releases/download/f46562/build_libflint.v0.0.0-f465622699d5c4c22bb3617596f8ae86e4570652.jl" | ||
] | ||
|
||
const prefix = Prefix(get([a for a in ARGS if a != "--verbose"], 1, joinpath(@__DIR__, "usr"))) | ||
|
||
products = [] | ||
|
||
for url in dependencies | ||
build_file = joinpath(@__DIR__, basename(url)) | ||
if !isfile(build_file) | ||
download(url, build_file) | ||
end | ||
end | ||
# this file is only for julia older than 1.3 | ||
|
||
# Execute the build scripts for the dependencies in an isolated module to avoid overwriting | ||
# any variables/constants here | ||
for url in dependencies | ||
build_file = joinpath(@__DIR__, basename(url)) | ||
m = @eval module $(gensym()); include($build_file); end | ||
append!(products, m.products) | ||
end | ||
|
||
filenames = ["libgmp.la", "libgmpxx.la", "libmpfr.la"] | ||
for filename in filenames | ||
fpath = joinpath(prefixpath, "lib", filename) | ||
txt = read(fpath, String) | ||
open(fpath, "w") do f | ||
write(f, replace(txt, "/workspace/destdir" => prefixpath)) | ||
end | ||
end | ||
|
||
else | ||
println("Doing a source build for C dependencies...") | ||
if "NEMO_BUILD_THREADS" in keys(ENV) | ||
build_threads = ENV["NEMO_BUILD_THREADS"] | ||
println("Using $build_threads threads for building as specified by NEMO_BUILD_THREADS.") | ||
else | ||
build_threads = Sys.CPU_THREADS | ||
println("Using $build_threads threads (detected that many CPU threads).") | ||
end | ||
|
||
@show M4_VERSION = "1.4.17" | ||
@show YASM_VERSION = "1.3.0" | ||
@show MPIR_VERSION = "3.0.0-90740d8fdf03b941b55723b449831c52fd7f51ca" | ||
@show MPFR_VERSION = "4.0.0" | ||
@show FLINT_VERSION = "f465622699d5c4c22bb3617596f8ae86e4570652" | ||
@show ARB_VERSION = "6c3738555d00b8b8b24a1f5e0065ef787432513c" | ||
@show ANTIC_VERSION = "364f97edd9b6af537787113cf910f16d7bbc48a3" | ||
|
||
if Sys.iswindows() | ||
error("Source build not available on Windows") | ||
end | ||
|
||
println("Removing old binaries ...") | ||
|
||
rm(prefixpath, force = true, recursive = true) | ||
mkdir(prefixpath) | ||
mkdir(joinpath(prefixpath, "lib")) | ||
|
||
if Sys.isapple() && !("CC" in keys(ENV)) | ||
ENV["CC"] = "clang" | ||
ENV["CXX"] = "clang++" | ||
end | ||
|
||
LDFLAGS = "-Wl,-rpath,$prefixpath/lib -Wl,-rpath,\$\$ORIGIN/../share/julia/site/v$(VERSION.major).$(VERSION.minor)/Nemo/local/lib" | ||
DLCFLAGS = "-fPIC -fno-common" | ||
|
||
cd(wdir) | ||
using Libdl | ||
|
||
try | ||
run(`m4 --version`) | ||
catch | ||
println("Building m4 ... ") | ||
M4_FILE = "m4-" * M4_VERSION * ".tar.bz2" | ||
download("http://ftp.gnu.org/gnu/m4/$M4_FILE", joinpath(wdir, "$M4_FILE")) | ||
if "FLINT_PATH" in keys(ENV) | ||
|
||
run(`tar -xvf $M4_FILE`) | ||
run(`rm $M4_FILE`) | ||
cd(joinpath("$wdir", "m4-$M4_VERSION")) | ||
run(`./configure --prefix=$prefixpath`) | ||
run(`make`) | ||
run(`make install`) | ||
println("DONE") | ||
if VERSION >= v"1.3.0-rc4" | ||
error("please use Pkg Overrides.toml for custom flint installations in julia >= 1.3") | ||
end | ||
|
||
cd(wdir) | ||
|
||
# install yasm | ||
|
||
if !ispath(joinpath(wdir, "yasm-$YASM_VERSION")) | ||
println("Building yasm ... ") | ||
YASM_FILE = "yasm-" * YASM_VERSION * ".tar.gz" | ||
download("https://github.com/yasm/yasm/archive/v$(YASM_VERSION).tar.gz", YASM_FILE) | ||
run(`tar -xvf $YASM_FILE`) | ||
run(`rm $YASM_FILE`) | ||
cd(joinpath("$wdir","yasm-$YASM_VERSION")) | ||
run(`./autogen.sh`) | ||
run(`./configure`) | ||
run(`make`) | ||
println("DONE") | ||
end | ||
|
||
cd(wdir) | ||
|
||
# install GMP/MPIR | ||
|
||
MPIR_FILE = "mpir-" * MPIR_VERSION * ".tar.bz2" | ||
|
||
if !ispath(joinpath(wdir, "mpir-$MPIR_VERSION")) | ||
println("Downloading MPIR sources ... ") | ||
download("http://nemocas.org/binaries/$MPIR_FILE", joinpath(wdir, MPIR_FILE)) | ||
println("DONE") | ||
end | ||
|
||
println("Building MPIR ... ") | ||
if isfile(joinpath(wdir, MPIR_FILE)) | ||
run(`tar -xvf $MPIR_FILE`) | ||
run(`rm $MPIR_FILE`) | ||
end | ||
cd("$wdir/mpir-$MPIR_VERSION") | ||
try | ||
run(`m4 --version`) | ||
run(`./configure --with-yasm=$wdir/yasm-$YASM_VERSION/yasm --prefix=$prefixpath --enable-gmpcompat --disable-static --enable-shared`) | ||
catch | ||
run(`./configure --with-yasm=$wdir/yasm-$YASM_VERSION/yasm --prefix=$prefixpath M4=$prefixpath/bin/m4 --enable-gmpcompat --disable-static --enable-shared`) | ||
end | ||
run(`make -j$build_threads`) | ||
run(`make install`) | ||
cd(wdir) | ||
run(`rm -rf bin`) | ||
println("DONE") | ||
|
||
cd(wdir) | ||
|
||
# install MPFR | ||
|
||
MPFR_FILE = "mpfr-" * MPFR_VERSION * ".tar.bz2" | ||
|
||
if !ispath(joinpath(wdir, "mpfr-$MPFR_VERSION")) | ||
println("Downloading MPFR sources ... ") | ||
download("http://ftp.vim.org/ftp/gnu/mpfr/$MPFR_FILE", joinpath(wdir, MPFR_FILE)) | ||
|
||
println("DONE") | ||
end | ||
|
||
println("Building MPFR ... ") | ||
if isfile(joinpath(wdir, MPFR_FILE)) | ||
run(`tar -xvf $MPFR_FILE`) | ||
run(`rm $MPFR_FILE`) | ||
end | ||
cd("$wdir/mpfr-$MPFR_VERSION") | ||
withenv("LD_LIBRARY_PATH"=>"$prefixpath/lib", "LDFLAGS"=>LDFLAGS) do | ||
run(`./configure --prefix=$prefixpath --with-gmp=$prefixpath --disable-static --enable-shared`) | ||
run(`make -j$build_threads`) | ||
run(`make install`) | ||
end | ||
println("DONE") | ||
|
||
cd(wdir) | ||
|
||
# INSTALL FLINT | ||
flint_path = ENV["FLINT_PATH"] | ||
if !isfile(flint_path) | ||
error("FLINT_PATH: file does not exists") | ||
end | ||
|
||
try | ||
println("Cloning flint2 ... ") | ||
run(`git clone https://github.com/wbhart/flint2.git`) | ||
cd(joinpath("$wdir", "flint2")) | ||
run(`git checkout $FLINT_VERSION`) | ||
cd(wdir) | ||
catch | ||
if ispath(joinpath("$wdir", "flint2")) | ||
open(`patch -R --forward -d flint2 -r -`, "r", open("../deps-PIE-ftbfs.patch")) | ||
cd(joinpath("$wdir", "flint2")) | ||
run(`git fetch`) | ||
run(`git checkout $FLINT_VERSION`) | ||
cd(wdir) | ||
end | ||
end | ||
open(`patch --forward -d flint2 -r -`, "r", open("../deps-PIE-ftbfs.patch")) | ||
println("DONE") | ||
open(joinpath(@__DIR__,"deps.jl"), "w") do f | ||
println(f, """ | ||
using Libdl | ||
libflint = "$flint_path" | ||
if Libdl.dlopen_e(libflint) in (C_NULL, nothing) | ||
error("$(libflint) cannot be opened, Please check FLINT_PATH environment variable and re-run Pkg.build("LoadFlint"), then restart Julia.") | ||
end | ||
# there must be some libgmp loaded for libflint | ||
libgmp = filter(x->occursin(r"libgmp[.-]", x), dllist())[1] | ||
libmpfr = filter(x->occursin(r"libmpfr[.-]", x), dllist())[1] | ||
|
||
println("Building flint ... ") | ||
cd(joinpath("$wdir", "flint2")) | ||
withenv("LD_LIBRARY_PATH"=>"$prefixpath/lib", "LDFLAGS"=>LDFLAGS) do | ||
run(`./configure --prefix=$prefixpath --disable-static --enable-shared --with-mpir=$prefixpath --with-mpfr=$prefixpath`) | ||
run(`make -j$build_threads`) | ||
run(`make install`) | ||
end | ||
""") | ||
end | ||
|
||
println("DONE") | ||
elseif VERSION < v"1.3.0-rc4" | ||
|
||
cd(wdir) | ||
using BinaryProvider | ||
|
||
# INSTALL ARB | ||
# Parse some basic command-line arguments | ||
const verbose = "--verbose" in ARGS | ||
|
||
println("Cloning arb ... ") | ||
try | ||
run(`git clone https://github.com/fredrik-johansson/arb.git`) | ||
cd(joinpath("$wdir", "arb")) | ||
run(`git checkout $ARB_VERSION`) | ||
cd(wdir) | ||
catch | ||
if ispath(joinpath("$wdir", "arb")) | ||
#open(`patch -R --forward -d arb -r -`, "r", open("../deps-PIE-ftbfs.patch")) | ||
cd(joinpath("$wdir", "arb")) | ||
run(`git fetch`) | ||
run(`git checkout $ARB_VERSION`) | ||
cd(wdir) | ||
end | ||
end | ||
println("DONE") | ||
# GMP and MPFR might not be needed on unix as julia should have those loaded already | ||
# but on windows flint will not load without them so we put leave them here for simplicity | ||
dependencies = [ | ||
# This has to be in sync with the jll packages (using generate_build.jl and build_tarballs.jl from Yggdrasil) | ||
"build_GMP.v6.1.2.jl", | ||
"build_MPFR.v4.0.2.jl", | ||
"build_FLINT.v2.6.0.jl", | ||
] | ||
|
||
println("Building arb ... ") | ||
cd(joinpath("$wdir", "arb")) | ||
withenv("LD_LIBRARY_PATH"=>"$prefixpath/lib", "LDFLAGS"=>LDFLAGS) do | ||
run(`./configure --prefix=$prefixpath --disable-static --enable-shared --with-mpir=$prefixpath --with-mpfr=$prefixpath --with-flint=$prefixpath`) | ||
run(`make -j$build_threads`) | ||
run(`make install`) | ||
end | ||
println("DONE") | ||
const prefix = Prefix(get([a for a in ARGS if a != "--verbose"], 1, joinpath(@__DIR__, "usr"))) | ||
|
||
cd(wdir) | ||
products = [] | ||
|
||
# INSTALL ANTIC | ||
# Execute the build scripts for the dependencies in an isolated module to avoid overwriting | ||
# any variables/constants here | ||
for file in dependencies | ||
build_file = joinpath(@__DIR__, file) | ||
m = @eval module $(gensym()); include($build_file); end | ||
append!(products, m.products) | ||
end | ||
|
||
println("Cloning antic ... ") | ||
try | ||
run(`git clone https://github.com/wbhart/antic.git`) | ||
cd(joinpath("$wdir", "antic")) | ||
run(`git checkout $ANTIC_VERSION`) | ||
cd(wdir) | ||
catch | ||
if ispath(joinpath("$wdir", "antic")) | ||
#open(`patch -R --forward -d antic -r -`, "r", open("../deps-PIE-ftbfs.patch")) | ||
cd(joinpath("$wdir", "antic")) | ||
run(`git fetch`) | ||
run(`git checkout $ANTIC_VERSION`) | ||
cd(wdir) | ||
end | ||
end | ||
println("DONE") | ||
write_deps_file(joinpath(@__DIR__, "deps.jl"), Array{Product,1}(products), verbose=verbose) | ||
|
||
println("Building antic ... ") | ||
cd(joinpath("$wdir", "antic")) | ||
withenv("LD_LIBRARY_PATH"=>"$prefixpath/lib", "LDFLAGS"=>LDFLAGS) do | ||
run(`./configure --prefix=$prefixpath --disable-static --enable-shared --with-mpir=$prefixpath --with-mpfr=$prefixpath --with-flint=$prefixpath`) | ||
run(`make -j$build_threads`) | ||
run(`make install`) | ||
end | ||
println("DONE") | ||
cd(wdir) | ||
end | ||
|
||
push!(Libdl.DL_LOAD_PATH, joinpath(prefixpath, "lib"), joinpath(prefixpath, "bin")) | ||
|
Oops, something went wrong.
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.