Skip to content

Commit fb995ff

Browse files
authored
Merge pull request #3 from EnzymeAD/v
Vendor new tarball builder
2 parents a135c6f + 3fbd238 commit fb995ff

File tree

1 file changed

+28
-52
lines changed

1 file changed

+28
-52
lines changed

R/Reactant/build_tarballs.jl

Lines changed: 28 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ include(joinpath(YGGDRASIL_DIR, "fancy_toys.jl"))
66

77
name = "Reactant"
88
repo = "https://github.com/EnzymeAD/Reactant.jl.git"
9-
reactant_commit = "5a3c3bcd10eae483bd63d93cb1f75487b0c54423"
10-
version = v"0.0.246"
9+
reactant_commit = "d3cee1ac27e3dd9f90779c84e0a6848a802b6878"
10+
version = v"0.0.252"
1111

1212
sources = [
1313
GitSource(repo, reactant_commit),
@@ -20,8 +20,6 @@ enzyme_jax_commit = get(ENV, "ENZYME_JAX_COMMIT", "")
2020

2121
# Bash recipe for building across all platforms
2222
script = raw"""
23-
ccache -s
24-
2523
cd ${WORKSPACE}/srcdir
2624
tar xzf OpenJDK21U-jdk_x64_alpine-linux_hotspot_21.0.7_6.tar.gz
2725
tar xzf Bazel.v7.6.1.x86_64-linux-musl-cxx03.tar.gz
@@ -111,7 +109,15 @@ BAZEL_BUILD_FLAGS+=(--verbose_failures)
111109
BAZEL_BUILD_FLAGS+=(--action_env=TMP=$TMPDIR --action_env=TEMP=$TMPDIR --action_env=TMPDIR=$TMPDIR --sandbox_tmpfs_path=$TMPDIR)
112110
BAZEL_BUILD_FLAGS+=(--host_cpu=k8)
113111
BAZEL_BUILD_FLAGS+=(--host_platform=//:linux_x86_64)
114-
BAZEL_BUILD_FLAGS+=(--host_crosstool_top=@//:ygg_cross_compile_toolchain_suite)
112+
BAZEL_BUILD_FLAGS+=(--host_crosstool_top=@//:ygg_host_toolchain_suite)
113+
114+
# `using_clang` comes from Enzyme-JAX, to handle clang-specific options.
115+
BAZEL_BUILD_FLAGS+=(--define=using_clang=true)
116+
117+
if [[ "${bb_full_target}" == *gpu+none* ]]; then
118+
BAZEL_BUILD_FLAGS+=(--crosstool_top=@//:ygg_cross_compile_toolchain_suite)
119+
fi
120+
115121
# BAZEL_BUILD_FLAGS+=(--extra_execution_platforms=@xla//tools/toolchains/cross_compile/config:linux_x86_64)
116122
117123
if [[ "${target}" == x86_64-apple-darwin* ]]; then
@@ -158,10 +164,7 @@ if [[ "${target}" == *-darwin* ]]; then
158164
echo "register_toolchains(\\"//:cc_toolchain_for_ygg_darwin_arm64\\")" >> WORKSPACE
159165
fi
160166
BAZEL_BUILD_FLAGS+=(--linkopt=-twolevel_namespace)
161-
BAZEL_BUILD_FLAGS+=(--crosstool_top=@//:ygg_cross_compile_toolchain_suite)
162167
BAZEL_BUILD_FLAGS+=(--define=clang_macos_x86_64=true)
163-
# `using_clang` comes from Enzyme-JAX, to handle clang-specific options.
164-
BAZEL_BUILD_FLAGS+=(--define=using_clang=true)
165168
BAZEL_BUILD_FLAGS+=(--define HAVE_LINK_H=0)
166169
BAZEL_BUILD_FLAGS+=(--macos_minimum_os=${MACOSX_DEPLOYMENT_TARGET})
167170
BAZEL_BUILD_FLAGS+=(--action_env=MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET})
@@ -179,8 +182,6 @@ if [[ "${target}" == *-mingw* ]]; then
179182
BAZEL_BUILD_FLAGS+=(--copt=-DPTHREADPOOL_USE_PTHREADS=1)
180183
BAZEL_BUILD_FLAGS+=(--copt=-DWIN32_LEAN_AND_MEAN)
181184
BAZEL_BUILD_FLAGS+=(--copt=-DNOGDI)
182-
# BAZEL_BUILD_FLAGS+=(--compiler=clang)
183-
BAZEL_BUILD_FLAGS+=(--define=using_clang=true)
184185
if [[ "${target}" == x86_64* ]]; then
185186
BAZEL_BUILD_FLAGS+=(--platforms=@//:win_x86_64)
186187
BAZEL_BUILD_FLAGS+=(--cpu=${BAZEL_CPU})
@@ -205,7 +206,6 @@ if [[ "${target}" == *-linux-* ]]; then
205206
BAZEL_BUILD_FLAGS+=(--platforms=@//:linux_x86_64)
206207
echo "register_toolchains(\\"//:cc_toolchain_for_ygg_x86\\")" >> WORKSPACE
207208
elif [[ "${target}" == aarch64-* ]]; then
208-
BAZEL_BUILD_FLAGS+=(--crosstool_top=@//:ygg_cross_compile_toolchain_suite)
209209
BAZEL_BUILD_FLAGS+=(--platforms=@//:linux_aarch64)
210210
BAZEL_BUILD_FLAGS+=(--cpu=${BAZEL_CPU})
211211
BAZEL_BUILD_FLAGS+=(--@xla//xla/tsl/framework/contraction:disable_onednn_contraction_kernel=True)
@@ -225,18 +225,9 @@ if [[ "${bb_full_target}" == *gpu+cuda* ]]; then
225225
BAZEL_BUILD_FLAGS+=(--config=cuda)
226226
BAZEL_BUILD_FLAGS+=(--repo_env=HERMETIC_CUDA_VERSION="${HERMETIC_CUDA_VERSION}")
227227
if [[ "${HERMETIC_CUDA_VERSION}" == *13.* ]]; then
228-
BAZEL_BUILD_FLAGS+=(--repo_env=HERMETIC_CUDNN_VERSION="9.12.0")
229-
BAZEL_BUILD_FLAGS+=(--repo_env=HERMETIC_NVSHMEM_VERSION="3.3.20")
230-
BAZEL_BUILD_FLAGS+=(--repo_env HERMETIC_CUDA_COMPUTE_CAPABILITIES="sm_75,sm_80,sm_90,sm_100,compute_120")
231-
fi
232-
233-
if [[ "${GCC_MAJOR_VERSION}" -le 12 && "${target}" == x86_64-* ]]; then
234-
# Someone wants to compile some code which requires flags not understood by GCC 12.
235-
BAZEL_BUILD_FLAGS+=(--define=xnn_enable_avxvnniint8=false)
236-
fi
237-
if [[ "${GCC_MAJOR_VERSION}" -le 11 && "${target}" == x86_64-* ]]; then
238-
# Someone wants to compile some code which requires flags not understood by GCC 11.
239-
BAZEL_BUILD_FLAGS+=(--define=xnn_enable_avx512fp16=false)
228+
BAZEL_BUILD_FLAGS+=(--config=cuda13)
229+
else
230+
BAZEL_BUILD_FLAGS+=(--config=cuda12)
240231
fi
241232
242233
if [[ "${target}" != x86_64-linux-gnu ]]; then
@@ -259,7 +250,6 @@ if [[ "${bb_full_target}" == *gpu+cuda* ]]; then
259250
fi
260251
BAZEL_BUILD_FLAGS+=(
261252
--action_env=CLANG_CUDA_COMPILER_PATH=$(which clang)
262-
--define=using_clang=true
263253
)
264254
fi
265255
@@ -304,13 +294,6 @@ if [[ "${target}" == *-darwin* ]]; then
304294
sed -i 's/12.0.1-iains/12.1.0/' "/opt/bin/x86_64-linux-musl-cxx11/x86_64-linux-musl-clang"*
305295
fi
306296
307-
# sed -i.bak1 -e "s/\\"k8|/\\"${BAZEL_CPU}\\": \\":cc-compiler-k8\\", \\"k8|/g" \
308-
# -e "s/cpu = \\"k8\\"/cpu = \\"${BAZEL_CPU}\\"/g" \
309-
# /workspace/bazel_root/*/external/bazel_tools~cc_configure_extension~local_config_cc/BUILD
310-
311-
# sed -i.bak2 -e "s/\\":cpu_aarch64\\":/\\"@platforms\/\/cpu:aarch64\\":/g" \
312-
# /workspace/bazel_root/*/external/xla/third_party/highwayhash/highwayhash.BUILD
313-
314297
# We expect the following bazel build command to fail to link at the end, because the
315298
# build system insists on linking with `-whole_archive` also on macOS. Until we figure
316299
# out how to make it stop doing this we have to manually do this. Any other error
@@ -322,15 +305,11 @@ if [[ "${target}" == *-darwin* ]]; then
322305
-e "/gc-sections/d" \
323306
bazel-bin/libReactantExtra.so-2.params
324307
325-
# # Show the params file for debugging, but convert newlines to spaces
326-
# cat bazel-bin/libReactantExtra.so-2.params | tr '\n' ' '
327-
# echo ""
328-
329308
cc @bazel-bin/libReactantExtra.so-2.params
330309
elif [[ "${target}" == *mingw32* ]]; then
331-
$BAZEL ${BAZEL_FLAGS[@]} build --repo_env=CC ${BAZEL_BUILD_FLAGS[@]} :libReactantExtra.so || echo stage1
310+
$BAZEL ${BAZEL_FLAGS[@]} build ${BAZEL_BUILD_FLAGS[@]} :libReactantExtra.so || echo stage1
332311
sed -i.bak1 -e "s/PTHREADPOOL_WEAK//g" /workspace/bazel_root/*/external/pthreadpool/src/portable-api.c
333-
$BAZEL ${BAZEL_FLAGS[@]} build --repo_env=CC ${BAZEL_BUILD_FLAGS[@]} :libReactantExtra.so || echo stage2
312+
$BAZEL ${BAZEL_FLAGS[@]} build ${BAZEL_BUILD_FLAGS[@]} :libReactantExtra.so || echo stage2
334313
sed -i.bak1 -e "/start-lib/d" \
335314
-e "/end-lib/d" \
336315
bazel-bin/libReactantExtra.so-2.params
@@ -339,20 +318,20 @@ elif [[ "${target}" == *mingw32* ]]; then
339318
-e "s/^ntdll.lib/-lntdll/g" \
340319
bazel-bin/libReactantExtra.so-2.params
341320
342-
echo "-lole32" >> bazel-bin/libReactantExtra.so-2.params
343-
echo "-lshlwapi" >> bazel-bin/libReactantExtra.so-2.params
344-
echo "-lshell32" >> bazel-bin/libReactantExtra.so-2.params
345-
echo "-lshdocvw" >> bazel-bin/libReactantExtra.so-2.params
346-
echo "-lshcore" >> bazel-bin/libReactantExtra.so-2.params
347-
echo "-lcrypt32" >> bazel-bin/libReactantExtra.so-2.params
348-
echo "-lbcrypt" >> bazel-bin/libReactantExtra.so-2.params
349-
echo "-lmsvcrt" >> bazel-bin/libReactantExtra.so-2.params
350-
echo "-luuid" >> bazel-bin/libReactantExtra.so-2.params
321+
echo "-lole32" >> bazel-bin/libReactantExtra.so-2.params
322+
echo "-lshlwapi" >> bazel-bin/libReactantExtra.so-2.params
323+
echo "-lshell32" >> bazel-bin/libReactantExtra.so-2.params
324+
echo "-lshdocvw" >> bazel-bin/libReactantExtra.so-2.params
325+
echo "-lshcore" >> bazel-bin/libReactantExtra.so-2.params
326+
echo "-lcrypt32" >> bazel-bin/libReactantExtra.so-2.params
327+
echo "-lbcrypt" >> bazel-bin/libReactantExtra.so-2.params
328+
echo "-lmsvcrt" >> bazel-bin/libReactantExtra.so-2.params
329+
echo "-luuid" >> bazel-bin/libReactantExtra.so-2.params
351330
352331
353332
clang @bazel-bin/libReactantExtra.so-2.params
354333
else
355-
$BAZEL ${BAZEL_FLAGS[@]} build --repo_env=CC ${BAZEL_BUILD_FLAGS[@]} :libReactantExtra.so
334+
$BAZEL ${BAZEL_FLAGS[@]} build ${BAZEL_BUILD_FLAGS[@]} :libReactantExtra.so
356335
fi
357336
358337
rm -f bazel-bin/libReactantExtraLib*
@@ -365,7 +344,6 @@ if [[ "${bb_full_target}" == *gpu+cuda* ]]; then
365344
cp -v bazel-ReactantExtra/external/nvidia_nvshmem/lib/libnvshmem_device.bc ${libdir}
366345
find bazel-bin
367346
find ${libdir}
368-
# cp -v /workspace/bazel_root/*/external/cuda_nccl/lib/libnccl.so.2 ${libdir}
369347
370348
if [[ "${target}" == x86_64-linux-gnu ]]; then
371349
NVCC_DIR=(bazel-bin/libReactantExtra.so.runfiles/cuda_nvcc)
@@ -390,8 +368,6 @@ fi
390368
391369
install -Dvm 755 bazel-bin/libReactantExtra.so "${libdir}/libReactantExtra.${dlext}"
392370
install_license ../../LICENSE
393-
394-
ccache -s
395371
"""
396372

397373
# determine exactly which tarballs we should build
@@ -515,8 +491,8 @@ for gpu in ("none", "cuda"), mode in ("opt", "dbg"), cuda_version in ("none", "1
515491
platform_sources = BinaryBuilder.AbstractSource[sources...]
516492
if Sys.isapple(platform)
517493
push!(platform_sources,
518-
ArchiveSource("https://github.com/realjf/MacOSX-SDKs/releases/download/v0.0.1/MacOSX12.3.sdk.tar.xz",
519-
"a511c1cf1ebfe6fe3b8ec005374b9c05e89ac28b3d4eb468873f59800c02b030"))
494+
ArchiveSource("https://github.com/realjf/MacOSX-SDKs/releases/download/v0.0.1/MacOSX12.3.sdk.tar.xz",
495+
"a511c1cf1ebfe6fe3b8ec005374b9c05e89ac28b3d4eb468873f59800c02b030"))
520496
end
521497

522498
if arch(platform) == "aarch64" && gpu == "cuda"

0 commit comments

Comments
 (0)