-
Notifications
You must be signed in to change notification settings - Fork 511
/
build_tarballs.jl
77 lines (61 loc) · 2.47 KB
/
build_tarballs.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using BinaryBuilder, Pkg
using Base.BinaryPlatforms
include("../../fancy_toys.jl")
name = "Enzyme"
repo = "https://github.com/wsmoses/Enzyme.git"
auto_version = "refs/tags/v0.0.17"
version = VersionNumber(split(auto_version, "/")[end])
# Collection of sources required to build attr
sources = [GitSource(repo, "51cd8528880c63bc123421b0257861c62402fcfe")]
# Bash recipe for building across all platforms
script = raw"""
cd Enzyme
# install_license LICENSE.TXT
CMAKE_FLAGS=()
# Release build for best performance
CMAKE_FLAGS+=(-DENZYME_EXTERNAL_SHARED_LIB=ON)
CMAKE_FLAGS+=(-DCMAKE_BUILD_TYPE=RelWithDebInfo)
# Install things into $prefix
CMAKE_FLAGS+=(-DCMAKE_INSTALL_PREFIX=${prefix})
# Explicitly use our cmake toolchain file and tell CMake we're cross-compiling
CMAKE_FLAGS+=(-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN})
CMAKE_FLAGS+=(-DCMAKE_CROSSCOMPILING:BOOL=ON)
# Tell CMake where LLVM is
CMAKE_FLAGS+=(-DLLVM_DIR="${prefix}/lib/cmake/llvm")
# Force linking against shared lib
CMAKE_FLAGS+=(-DLLVM_LINK_LLVM_DYLIB=ON)
# Build the library
CMAKE_FLAGS+=(-DBUILD_SHARED_LIBS=ON)
cmake -B build -S enzyme -GNinja ${CMAKE_FLAGS[@]}
ninja -C build -j ${nproc} install
"""
function configure(julia_version, llvm_version)
# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = expand_cxxstring_abis(supported_platforms(; experimental=julia_version>=v"1.7"))
foreach(platforms) do p
BinaryPlatforms.add_tag!(p.tags, "julia_version", string(julia_version))
end
# The products that we will ensure are always built
products = Product[
LibraryProduct(["libEnzyme-$(llvm_version.major)", "libEnzyme"], :libEnzyme),
]
dependencies = [
BuildDependency(get_addable_spec("LLVM_full_jll", llvm_version))
# Dependency(PackageSpec(name="libLLVM_jll", version=v"9.0.1")) is given through julia_version tag
]
return platforms, products, dependencies
end
# TODO: Don't require build-id on LLVM version
supported = (
(v"1.6", v"11.0.1+3"),
(v"1.7", v"12.0.0+0"),
(v"1.8", v"12.0.0+0"),
)
for (julia_version, llvm_version) in supported
platforms, products, dependencies = configure(julia_version, llvm_version)
any(should_build_platform.(triplet.(platforms))) || continue
# Build the tarballs.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies;
preferred_gcc_version=v"8", julia_compat="1.6")
end