Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci_support/linux_64_cross_target_platform_linux-64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ docker_image:
libxml2_devel:
- '2.14'
llvm_version:
- '20'
- '21'
target_platform:
- linux-64
zip_keys:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ docker_image:
libxml2_devel:
- '2.14'
llvm_version:
- '20'
- '21'
target_platform:
- linux-64
zip_keys:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ docker_image:
libxml2_devel:
- '2.14'
llvm_version:
- '20'
- '21'
target_platform:
- linux-64
zip_keys:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ docker_image:
libxml2_devel:
- '2.14'
llvm_version:
- '20'
- '21'
target_platform:
- linux-64
zip_keys:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ docker_image:
libxml2_devel:
- '2.14'
llvm_version:
- '20'
- '21'
target_platform:
- linux-aarch64
zip_keys:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ docker_image:
libxml2_devel:
- '2.14'
llvm_version:
- '20'
- '21'
target_platform:
- linux-ppc64le
zip_keys:
Expand Down
6 changes: 3 additions & 3 deletions .ci_support/osx_64_cross_target_platform_osx-64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MACOSX_SDK_VERSION:
c_compiler:
- clang
c_compiler_version:
- '20'
- '21'
c_stdlib:
- macosx_deployment_target
c_stdlib_version:
Expand All @@ -19,11 +19,11 @@ cross_target_platform_:
cxx_compiler:
- clangxx
cxx_compiler_version:
- '20'
- '21'
libxml2_devel:
- '2.14'
llvm_version:
- '20'
- '21'
macos_machine:
- x86_64-apple-darwin13.4.0
target_platform:
Expand Down
6 changes: 3 additions & 3 deletions .ci_support/osx_64_cross_target_platform_osx-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MACOSX_SDK_VERSION:
c_compiler:
- clang
c_compiler_version:
- '20'
- '21'
c_stdlib:
- macosx_deployment_target
c_stdlib_version:
Expand All @@ -19,11 +19,11 @@ cross_target_platform_:
cxx_compiler:
- clangxx
cxx_compiler_version:
- '20'
- '21'
libxml2_devel:
- '2.14'
llvm_version:
- '20'
- '21'
macos_machine:
- x86_64-apple-darwin13.4.0
target_platform:
Expand Down
6 changes: 3 additions & 3 deletions .ci_support/osx_arm64_cross_target_platform_osx-64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MACOSX_SDK_VERSION:
c_compiler:
- clang
c_compiler_version:
- '20'
- '21'
c_stdlib:
- macosx_deployment_target
c_stdlib_version:
Expand All @@ -19,11 +19,11 @@ cross_target_platform_:
cxx_compiler:
- clangxx
cxx_compiler_version:
- '20'
- '21'
libxml2_devel:
- '2.14'
llvm_version:
- '20'
- '21'
macos_machine:
- arm64-apple-darwin20.0.0
target_platform:
Expand Down
6 changes: 3 additions & 3 deletions .ci_support/osx_arm64_cross_target_platform_osx-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MACOSX_SDK_VERSION:
c_compiler:
- clang
c_compiler_version:
- '20'
- '21'
c_stdlib:
- macosx_deployment_target
c_stdlib_version:
Expand All @@ -19,11 +19,11 @@ cross_target_platform_:
cxx_compiler:
- clangxx
cxx_compiler_version:
- '20'
- '21'
libxml2_devel:
- '2.14'
llvm_version:
- '20'
- '21'
macos_machine:
- arm64-apple-darwin20.0.0
target_platform:
Expand Down
2 changes: 1 addition & 1 deletion .ci_support/win_64_cross_target_platform_win-64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cxx_compiler:
libxml2_devel:
- '2.14'
llvm_version:
- '20'
- '21'
target_platform:
- win-64
zlib:
Expand Down
2 changes: 1 addition & 1 deletion .ci_support/win_64_cross_target_platform_win-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cxx_compiler:
libxml2_devel:
- '2.14'
llvm_version:
- '20'
- '21'
target_platform:
- win-64
zlib:
Expand Down
42 changes: 38 additions & 4 deletions recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ fi

# --- Main ---

# On osx-arm64 we ship an upstream pre-built zig as the bootstrap (conda-forge
# zig_impl 0.15.2 pins libcxx 20 and conflicts with the LLVM-21 toolchain
# required by 0.16). Symlink the extracted binary into a dir on PATH under
# the name CONDA_ZIG_BUILD expects.
if is_osx && [[ -d "${SRC_DIR}/zig-bootstrap" ]]; then
_bootstrap_root="$(find "${SRC_DIR}/zig-bootstrap" -maxdepth 1 -type d -name 'zig-*' -print -quit)"
if [[ -n "${_bootstrap_root}" && -x "${_bootstrap_root}/zig" ]]; then
_bootstrap_bin_dir="${SRC_DIR}/zig-bootstrap-bin"
mkdir -p "${_bootstrap_bin_dir}"
ln -sf "${_bootstrap_root}/zig" "${_bootstrap_bin_dir}/${CONDA_ZIG_BUILD}"
export PATH="${_bootstrap_bin_dir}:${PATH}"
echo "=== Using upstream zig bootstrap: ${_bootstrap_root}/zig ==="
fi
fi

# Bootstrap zig runs on the build machine — always use CONDA_ZIG_BUILD
BUILD_ZIG="${CONDA_ZIG_BUILD}"

Expand All @@ -63,7 +78,13 @@ export ZIG_LOCAL_CACHE_DIR="${SRC_DIR}/zig-local-cache"

cmake_source_dir="${SRC_DIR}/zig-source"
cmake_build_dir="${SRC_DIR}/build-release"
cmake_install_dir="${SRC_DIR}/cmake-built-install"
# Point the cmake install prefix directly at ${PREFIX}. Zig's upstream
# cmake/install.cmake bakes the configure-time CMAKE_INSTALL_PREFIX into
# the install script (it invokes `zig build --prefix ${CMAKE_INSTALL_PREFIX}`
# via install(CODE ...)), so `cmake --install . --prefix X` at install time
# is silently ignored. Using ${PREFIX} here ensures the CMake fallback path
# lands files where the rest of build.sh expects them.
cmake_install_dir="${PREFIX}"
zig_build_dir="${SRC_DIR}/conda-zig-source"

mkdir -p "${zig_build_dir}" && cp -r "${cmake_source_dir}"/* "${zig_build_dir}"
Expand Down Expand Up @@ -135,7 +156,7 @@ fi
if is_linux; then
source "${RECIPE_DIR}/building/_libc_tuning.sh"
create_gcc14_glibc28_compat_lib

is_cross && rm "${PREFIX}"/bin/llvm-config && cp "${BUILD_PREFIX}"/bin/llvm-config "${PREFIX}"/bin/llvm-config
fi

Expand All @@ -148,6 +169,17 @@ is_linux && is_cross && perl -pi -e "s@(ZIG_LLVM_LIBRARIES \".*)\"@\$1;-lzstd;-l
is_osx && is_cross && perl -pi -e "s@(ZIG_LLVM_\w+ \")${BUILD_PREFIX}@\$1${PREFIX}@" "${cmake_build_dir}"/config.h
is_osx && perl -pi -e "s@(ZIG_LLVM_LIBRARIES \".*)\"@\$1;${PREFIX}/lib/libc++.dylib\"@" "${cmake_build_dir}"/config.h

# zig2.c (the pre-generated C bootstrap from 0.16) calls getrandom,
# copy_file_range, and statx — all absent from conda-forge's glibc 2.17
# sysroot. Compile weak-symbol syscall() stubs and inject the .o into
# both the zig-build path (via config.h's ZIG_LLVM_LIBRARIES) and the
# CMake fallback path (via cmake/0002 target_link_libraries).
if is_linux; then
source "${RECIPE_DIR}/building/_glibc217_syscall_stubs.sh"
create_glibc217_syscall_stubs "${CC}" "${ZIG_LOCAL_CACHE_DIR}"
perl -pi -e "s|(#define ZIG_LLVM_LIBRARIES \".*)\"|\$1;${ZIG_LOCAL_CACHE_DIR}/glibc217_syscall_stubs.o\"|g" "${cmake_build_dir}/config.h"
fi

is_debug && echo "=== DEBUG ===" && cat "${cmake_build_dir}"/config.h && echo "=== DEBUG ==="

# --- Cross-build setup (must happen BEFORE Stage 1 since EXTRA_ZIG_ARGS has --libc) ---
Expand All @@ -174,9 +206,11 @@ if is_linux && [[ "${BUILD_NATIVE_ZIG:-0}" == "1" ]]; then
fi


is_debug && echo "=== Building with ZIG ==="
is_debug && echo "=== Building with ZIG ===" || true
if build_zig_with_zig "${zig_build_dir}" "${BUILD_ZIG}" "${PREFIX}"; then
is_debug && echo "SUCCESS: zig build completed successfully"
# NB: `|| true` — in non-debug is_debug returns 1 and that becomes the
# branch's last-executed exit status, which trips `set -e` in build.sh.
is_debug && echo "SUCCESS: zig build completed successfully" || true
elif [[ "${CMAKE_FALLBACK:-1}" == "1" ]]; then
source "${RECIPE_DIR}/building/_cmake.sh" # cmake_fallback_build
cmake_fallback_build "${cmake_source_dir}" "${cmake_build_dir}" "${PREFIX}"
Expand Down
7 changes: 5 additions & 2 deletions recipe/building/_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function apply_cmake_patches() {
done
popd > /dev/null

is_debug && echo "All cmake patches applied successfully"
is_debug && echo "All cmake patches applied successfully" || true
return 0
}

Expand Down Expand Up @@ -102,7 +102,10 @@ function cmake_fallback_build() {
apply_cmake_patches "${source_dir}"

if cmake_build_install "${build_dir}" "${install_prefix}"; then
is_debug && echo "SUCCESS: cmake fallback build completed successfully"
# NB: trailing `|| true` — in non-debug `is_debug` returns 1, which would
# otherwise become the function's exit status and trip `set -e` in the
# caller. Force a 0 return on the success path.
is_debug && echo "SUCCESS: cmake fallback build completed successfully" || true
else
echo "ERROR: Both zig build and cmake build failed" >&2
exit 1
Expand Down
120 changes: 120 additions & 0 deletions recipe/building/_glibc217_syscall_stubs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
function create_glibc217_syscall_stubs() {
# Create syscall stubs for glibc < 2.25/2.27/2.28 compatibility
#
# zig2.c (the pre-generated C bootstrap) calls glibc wrapper functions that
# don't exist in conda-forge's glibc 2.17 sysroot:
# - getrandom() — glibc 2.25 (syscall since Linux 3.17)
# - copy_file_range() — glibc 2.27 (syscall since Linux 4.5)
# - statx() — glibc 2.28 (syscall since Linux 4.11)
#
# These stubs use the raw syscall() interface (available in all glibc versions)
# to provide the missing functions at link time.

local cc_compiler="${1}"
local output_dir="${2:-${SRC_DIR}}"

is_debug && echo "Creating glibc 2.17 syscall stubs (getrandom, copy_file_range, statx)"

cat > "${output_dir}/glibc217_syscall_stubs.c" << 'EOF'
/*
* Syscall stubs for glibc < 2.28 (conda-forge glibc 2.17 baseline).
*
* zig2.c references getrandom, copy_file_range, and statx which are
* glibc wrappers added in 2.25/2.27/2.28 respectively. On glibc 2.17
* these symbols don't exist, causing link failures. We provide them
* via raw syscall() which is available in all glibc versions.
*
* Weak symbols so they're overridden if a newer glibc provides them.
*/
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
#include <errno.h>
#include <sys/types.h>

/* ---- getrandom (glibc 2.25, Linux 3.17) ---- */
#ifndef SYS_getrandom
# if defined(__x86_64__)
# define SYS_getrandom 318
# elif defined(__aarch64__)
# define SYS_getrandom 278
# elif defined(__powerpc64__)
# define SYS_getrandom 359
# elif defined(__riscv)
# define SYS_getrandom 278
# elif defined(__s390x__)
# define SYS_getrandom 349
# endif
#endif

__attribute__((weak))
ssize_t getrandom(void *buf, size_t buflen, unsigned int flags) {
long ret = syscall(SYS_getrandom, buf, buflen, flags);
return ret;
}

/* ---- copy_file_range (glibc 2.27, Linux 4.5) ---- */
#ifndef SYS_copy_file_range
# if defined(__x86_64__)
# define SYS_copy_file_range 326
# elif defined(__aarch64__)
# define SYS_copy_file_range 285
# elif defined(__powerpc64__)
# define SYS_copy_file_range 379
# elif defined(__riscv)
# define SYS_copy_file_range 285
# elif defined(__s390x__)
# define SYS_copy_file_range 375
# endif
#endif

__attribute__((weak))
ssize_t copy_file_range(int fd_in, off_t *off_in, int fd_out,
off_t *off_out, size_t len, unsigned int flags) {
long ret = syscall(SYS_copy_file_range, fd_in, off_in,
fd_out, off_out, len, flags);
return ret;
}

/* ---- statx (glibc 2.28, Linux 4.11) ---- */
#ifndef SYS_statx
# if defined(__x86_64__)
# define SYS_statx 332
# elif defined(__aarch64__)
# define SYS_statx 291
# elif defined(__powerpc64__)
# define SYS_statx 383
# elif defined(__riscv)
# define SYS_statx 291
# elif defined(__s390x__)
# define SYS_statx 379
# endif
#endif

/* Forward-declare statx struct to avoid pulling in kernel headers
that may conflict with glibc headers on older systems. */
struct statx;

__attribute__((weak))
int statx(int dirfd, const char *pathname, int flags,
unsigned int mask, struct statx *statxbuf) {
/* syscall() handles errno conversion: returns -1 and sets errno on error */
long ret = syscall(SYS_statx, dirfd, pathname, flags, mask, statxbuf);
return (int)ret;
}
EOF

"${cc_compiler}" -c "${output_dir}/glibc217_syscall_stubs.c" \
-o "${output_dir}/glibc217_syscall_stubs.o" || {
echo "ERROR: Failed to compile glibc 2.17 syscall stubs" >&2
return 1
}

if [[ ! -f "${output_dir}/glibc217_syscall_stubs.o" ]]; then
echo "ERROR: glibc217_syscall_stubs.o was not created" >&2
return 1
fi

is_debug && echo "glibc 2.17 syscall stubs created: ${output_dir}/glibc217_syscall_stubs.o"
return 0
}
Loading
Loading