-
Notifications
You must be signed in to change notification settings - Fork 509
/
build_tarballs.jl
99 lines (81 loc) · 3.6 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using BinaryBuilder, Pkg
name = "XGBoost"
version = v"1.7.2"
const YGGDRASIL_DIR = "../.."
include(joinpath(YGGDRASIL_DIR, "fancy_toys.jl"))
include(joinpath(YGGDRASIL_DIR, "platforms", "cuda.jl"))
# Collection of sources required to build XGBoost
sources = [
GitSource("https://github.com/dmlc/xgboost.git","62ed8b5fef01d960b5e180b6c3ab170b5f7a85d2"),
DirectorySource("./bundled"),
]
# Bash recipe for building across all platforms
script = raw"""
cd ${WORKSPACE}/srcdir/xgboost
git submodule update --init
# Patch dmlc-core to use case-sensitive windows.h includes: https://github.com/dmlc/dmlc-core/pull/673
(cd dmlc-core; atomic_patch -p1 "../../patches/dmlc_windows.patch")
mkdir build && cd build
if [[ $bb_full_target == x86_64-linux*cuda* ]]; then
# nvcc writes to /tmp, which is a small tmpfs in our sandbox.
# make it use the workspace instead
export TMPDIR=${WORKSPACE}/tmpdir
mkdir ${TMPDIR}
export CUDA_HOME=${WORKSPACE}/destdir/cuda
export PATH=$PATH:$CUDA_HOME/bin
cmake .. -DCMAKE_INSTALL_PREFIX=${prefix} \
-DCMAKE_TOOLCHAIN_FILE="${CMAKE_TARGET_TOOLCHAIN}" \
-DCUDA_TOOLKIT_ROOT_DIR=${WORKSPACE}/destdir/cuda \
-DUSE_CUDA=ON \
-DBUILD_WITH_CUDA_CUB=ON
make -j${nproc}
else
cmake .. -DCMAKE_INSTALL_PREFIX=${prefix} -DCMAKE_TOOLCHAIN_FILE="${CMAKE_TARGET_TOOLCHAIN}"
make -j${nproc}
fi
# Manual installation, to avoid installing dmlc
cd ..
for header in include/xgboost/*.h; do
install -Dv "${header}" "${includedir}/xgboost/$(basename ${header})"
done
install -Dvm 0755 xgboost${exeext} ${bindir}/xgboost${exeext}
if [[ ${target} == *mingw* ]]; then
install -Dvm 0755 lib/xgboost.dll ${libdir}/xgboost.dll
else
install -Dvm 0755 lib/libxgboost.${dlext} ${libdir}/libxgboost.${dlext}
fi
install_license LICENSE
"""
cuda_full_versions = Dict(
v"11.0" => v"11.0.3",
)
cuda_version = v"11.0"
# 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())
cuda_platforms = expand_cxxstring_abis(Platform("x86_64", "linux";
cuda=CUDA.platform(cuda_version)))
for p in cuda_platforms
push!(platforms, p)
end
# The products that we will ensure are always built
products = [
LibraryProduct(["libxgboost", "xgboost"], :libxgboost),
ExecutableProduct("xgboost", :xgboost)
]
# Dependencies that must be installed before this package can be built
dependencies = [
# 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)),
# You can only specify one cuda version in the deps. To build against more than
# one cuda version, you have to include them as Archive Sources. (see Torch_jll)
BuildDependency(PackageSpec(name="CUDA_full_jll", version=cuda_full_versions[cuda_version]), platforms=cuda_platforms),
RuntimeDependency(PackageSpec(name="CUDA_Runtime_jll"), platforms=cuda_platforms),
]
# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies;
preferred_gcc_version=v"8",
julia_compat="1.6",
augment_platform_block=CUDA.augment)