Skip to content

Commit d8e577a

Browse files
committed
add binarybuilder script for Julia package
1 parent 52f2b69 commit d8e577a

File tree

5 files changed

+131
-0
lines changed

5 files changed

+131
-0
lines changed

contrib/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/
2+
products/

contrib/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[deps]
2+
BinaryBuilder = "12aac903-9f7c-5d81-afc2-d9565ea332ae"
3+
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232"

contrib/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Shipping a Julia-compatible Enzyme library
2+
Since Julia has LLVM as a core dependency and uses a heavily patched version
3+
we want to ship enzyme build against the same LLVM version in a way that is compatible
4+
ABI compatible with the LLVM version used by Julia.
5+
6+
## Instructions
7+
8+
```
9+
julia --project=. build_tarballs.jl --debug x86_64-linux-gnu
10+
```

contrib/build_LLVM.v6.0.1.jl

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
using BinaryProvider # requires BinaryProvider 0.3.0 or later
2+
3+
# Parse some basic command-line arguments
4+
const verbose = "--verbose" in ARGS
5+
const prefix = Prefix(get([a for a in ARGS if a != "--verbose"], 1, joinpath(@__DIR__, "usr")))
6+
products = [
7+
LibraryProduct(prefix, ["libLLVM"], :libLLVM),
8+
LibraryProduct(prefix, ["libLTO"], :libLTO),
9+
LibraryProduct(prefix, ["libclang"], :libclang),
10+
ExecutableProduct(prefix, "llvm-tblgen", :llvm_tblgen),
11+
ExecutableProduct(prefix, "clang-tblgen", :clang_tblgen),
12+
ExecutableProduct(prefix, "llvm-config", :llvm_config),
13+
]
14+
15+
# Download binaries from hosted location
16+
bin_prefix = "https://github.com/staticfloat/LLVMBuilder/releases/download/v6.0.1-7+nowasm"
17+
18+
# Listing of files generated by BinaryBuilder:
19+
download_info = Dict(
20+
Linux(:aarch64, libc=:glibc, compiler_abi=CompilerABI(:gcc4)) => ("$bin_prefix/LLVM.v6.0.1.aarch64-linux-gnu-gcc4.tar.gz", "258733cf9305f135ab8be9b6c3bea7eb7bcc4e14d951d85e7d9e31a15c255fa5"),
21+
Linux(:aarch64, libc=:glibc, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/LLVM.v6.0.1.aarch64-linux-gnu-gcc7.tar.gz", "baa5f6ebd814b846d7dc62687962b7a2a4e822c02e5c53030ac958661679e06f"),
22+
Linux(:aarch64, libc=:glibc, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/LLVM.v6.0.1.aarch64-linux-gnu-gcc8.tar.gz", "a4b63136fc760db96fa7417027c5e1042818c4047b3723dcb2472f495a35d2db"),
23+
Linux(:armv7l, libc=:glibc, call_abi=:eabihf, compiler_abi=CompilerABI(:gcc4)) => ("$bin_prefix/LLVM.v6.0.1.arm-linux-gnueabihf-gcc4.tar.gz", "1e5733920dfb71ec013634817f8ab51ce24fc62a3bea67838a1818d93cf6b75a"),
24+
Linux(:armv7l, libc=:glibc, call_abi=:eabihf, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/LLVM.v6.0.1.arm-linux-gnueabihf-gcc7.tar.gz", "d9aad01adc6f3e32f875c85c425440d59f7865648ea7e3b70b1dc1f6d2a4d42c"),
25+
Linux(:armv7l, libc=:glibc, call_abi=:eabihf, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/LLVM.v6.0.1.arm-linux-gnueabihf-gcc8.tar.gz", "d4c625e28615419456c104681068bc4d28015d23cf6f18fa12744d87ee4ea408"),
26+
Linux(:i686, libc=:glibc, compiler_abi=CompilerABI(:gcc4)) => ("$bin_prefix/LLVM.v6.0.1.i686-linux-gnu-gcc4.tar.gz", "4430d32b9dbcdf27a91bf9888d169065a459eaae12f0cbe39314e7c5ba7d7251"),
27+
Linux(:i686, libc=:glibc, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/LLVM.v6.0.1.i686-linux-gnu-gcc7.tar.gz", "ea5c80514a178025458a28fcd442840c7a82cb96e6359cb4fa33e0fe9312f466"),
28+
Linux(:i686, libc=:glibc, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/LLVM.v6.0.1.i686-linux-gnu-gcc8.tar.gz", "d217b23c5509c7990a79c3c2f46a9c6c2fd2982d9a052e92186db227833c891e"),
29+
Windows(:i686, compiler_abi=CompilerABI(:gcc4)) => ("$bin_prefix/LLVM.v6.0.1.i686-w64-mingw32-gcc4.tar.gz", "e7045ddbf9da0afee4add08860f98b667a406331250b4f0a998615798d1b44b6"),
30+
Windows(:i686, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/LLVM.v6.0.1.i686-w64-mingw32-gcc7.tar.gz", "07b519d8ccea686bbb66b770fd58d7878ed818a59a8bef2ed745e3efff1e0d81"),
31+
Windows(:i686, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/LLVM.v6.0.1.i686-w64-mingw32-gcc8.tar.gz", "99850539331480460e34a631807939c4f4f903da2d4cbbfb41d869c4826acd68"),
32+
Linux(:powerpc64le, libc=:glibc, compiler_abi=CompilerABI(:gcc4)) => ("$bin_prefix/LLVM.v6.0.1.powerpc64le-linux-gnu-gcc4.tar.gz", "5fca09febf50921d088d0b00da881e37bbe29b1fb80ee3f3dd73baea7ace98fc"),
33+
Linux(:powerpc64le, libc=:glibc, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/LLVM.v6.0.1.powerpc64le-linux-gnu-gcc7.tar.gz", "2fff9e2baac6f8d1c12c5b92d0fdd729569ced10dedf871604e03c745cd96dab"),
34+
Linux(:powerpc64le, libc=:glibc, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/LLVM.v6.0.1.powerpc64le-linux-gnu-gcc8.tar.gz", "45bb08eec360606b39a8860bf3385fdba8014261d11fb5a251cdbb473b94156c"),
35+
MacOS(:x86_64, compiler_abi=CompilerABI(:gcc4)) => ("$bin_prefix/LLVM.v6.0.1.x86_64-apple-darwin14-gcc4.tar.gz", "688422a003781e2430cb4c1d44a6f07a8e077050b97213695d4995dd8bbff18c"),
36+
MacOS(:x86_64, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/LLVM.v6.0.1.x86_64-apple-darwin14-gcc7.tar.gz", "801c50b0bf3a9cebb680257d4bf043c39bab5fb50ec13c1a5c36a4b69b8a6e8c"),
37+
MacOS(:x86_64, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/LLVM.v6.0.1.x86_64-apple-darwin14-gcc8.tar.gz", "0b87531d75dd95b1646b8d3c25eaf55f6707af14c6ac9d6571df3a2bcb0b83ca"),
38+
Linux(:x86_64, libc=:glibc, compiler_abi=CompilerABI(:gcc4)) => ("$bin_prefix/LLVM.v6.0.1.x86_64-linux-gnu-gcc4.tar.gz", "74af89216a5c3eba22a73b983ff8fa4b6525481368b49fa51e88b22da7cc0dd9"),
39+
Linux(:x86_64, libc=:glibc, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/LLVM.v6.0.1.x86_64-linux-gnu-gcc7.tar.gz", "f2c335eb912720a5b3318f909eda1650973043beb033dfb3adc0f7d150b91bf6"),
40+
Linux(:x86_64, libc=:glibc, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/LLVM.v6.0.1.x86_64-linux-gnu-gcc8.tar.gz", "33cdab926a924d6befb1bdf7db9598815dcb931c9b1de89a72d129bf5b6fb0eb"),
41+
Linux(:x86_64, libc=:musl, compiler_abi=CompilerABI(:gcc4)) => ("$bin_prefix/LLVM.v6.0.1.x86_64-linux-musl-gcc4.tar.gz", "f994ba50dbd5b465911d1d3cb0a3debb7b3c15850b58bb171992a9ec21069bcf"),
42+
Linux(:x86_64, libc=:musl, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/LLVM.v6.0.1.x86_64-linux-musl-gcc7.tar.gz", "9030772689d1eed85a41aae4a3413dd2fcff930537dbe782099071cef7276cb4"),
43+
Linux(:x86_64, libc=:musl, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/LLVM.v6.0.1.x86_64-linux-musl-gcc8.tar.gz", "62538f3b86629984adccb311ba35120f3fac1ba6cd9265ccda3d722071133834"),
44+
FreeBSD(:x86_64, compiler_abi=CompilerABI(:gcc4)) => ("$bin_prefix/LLVM.v6.0.1.x86_64-unknown-freebsd11.1-gcc4.tar.gz", "6baf75dfe38e57024e816d139eb77187c413b255193697d3bd49a769014d2af9"),
45+
FreeBSD(:x86_64, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/LLVM.v6.0.1.x86_64-unknown-freebsd11.1-gcc7.tar.gz", "3b38e5c912ed407999f75f6f021569984941034207943bbe393536d2f35f6cba"),
46+
FreeBSD(:x86_64, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/LLVM.v6.0.1.x86_64-unknown-freebsd11.1-gcc8.tar.gz", "d5fd71f9ba902128d9c9685454d5dba7d5936ebb0c0e30277141439d97dc16ea"),
47+
Windows(:x86_64, compiler_abi=CompilerABI(:gcc4)) => ("$bin_prefix/LLVM.v6.0.1.x86_64-w64-mingw32-gcc4.tar.gz", "9214e0e58a3373a8d0c34f55514aa7278d64cc2c9b866a32e3d5ecb3f3b202e5"),
48+
Windows(:x86_64, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/LLVM.v6.0.1.x86_64-w64-mingw32-gcc7.tar.gz", "74811cb50b41ac40bc69548811063ae595ea5ec8f77108e9a2a2f7c22196376f"),
49+
Windows(:x86_64, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/LLVM.v6.0.1.x86_64-w64-mingw32-gcc8.tar.gz", "c8baabecbf232437d58848ceeccef31a9ca59d7e452f55ceb26981d17293ba32"),
50+
)
51+
52+
# Install unsatisfied or updated dependencies:
53+
unsatisfied = any(!satisfied(p; verbose=verbose, isolate=true) for p in products)
54+
dl_info = choose_download(download_info, platform_key_abi())
55+
if dl_info === nothing && unsatisfied
56+
# If we don't have a compatible .tar.gz to download, complain.
57+
# Alternatively, you could attempt to install from a separate provider,
58+
# build from source or something even more ambitious here.
59+
error("Your platform (\"$(Sys.MACHINE)\", parsed as \"$(triplet(platform_key_abi()))\") is not supported by this package!")
60+
end
61+
62+
# If we have a download, and we are unsatisfied (or the version we're
63+
# trying to install is not itself installed) then load it up!
64+
if unsatisfied || !isinstalled(dl_info...; prefix=prefix)
65+
# Download and install binaries
66+
install(dl_info...; prefix=prefix, force=true, verbose=verbose)
67+
end
68+
69+
# Write out a deps.jl file that will contain mappings for our products
70+
write_deps_file(joinpath(@__DIR__, "deps.jl"), products, verbose=verbose)

contrib/build_tarballs.jl

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using BinaryBuilder
2+
3+
sources = [
4+
joinpath(@__DIR__, "../../enzyme")
5+
]
6+
7+
script = raw"""
8+
cmake -G Ninja -DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_TOOLCHAIN_FILE=/opt/$target/$target.toolchain \
9+
-DLLVM_DIR=${WORKSPACE}/destdir/lib/cmake/llvm
10+
ninja install
11+
"""
12+
13+
products(prefix) = [
14+
LibraryProduct(prefix, "LLVMEnzyme", :libenzyme),
15+
]
16+
17+
dependencies = [
18+
BinaryBuilder.InlineBuildDependency(readchomp("build_LLVM.v6.0.1.jl"))]
19+
20+
# These are the platforms we will build for by default, unless further
21+
# platforms are passed in on the command line
22+
platforms = [
23+
BinaryProvider.Linux(:i686, :glibc),
24+
BinaryProvider.Linux(:x86_64, :glibc),
25+
BinaryProvider.Linux(:x86_64, :musl),
26+
BinaryProvider.Linux(:aarch64, :glibc),
27+
BinaryProvider.Linux(:armv7l, :glibc),
28+
BinaryProvider.Linux(:powerpc64le, :glibc),
29+
# BinaryProvider.MacOS(),
30+
# BinaryProvider.Windows(:i686),
31+
# BinaryProvider.Windows(:x86_64),
32+
# BinaryProvider.FreeBSD(:x86_64),
33+
]
34+
platforms = expand_gcc_versions(platforms)
35+
36+
# Build 'em!
37+
build_tarballs(
38+
ARGS,
39+
"enzyme",
40+
v"0.0.1",
41+
sources,
42+
script,
43+
platforms,
44+
products,
45+
dependencies,
46+
)

0 commit comments

Comments
 (0)