Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build for linux-ppc64le #44

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
4 changes: 4 additions & 0 deletions .azure-pipelines/azure-pipelines-linux.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .azure-pipelines/azure-pipelines-osx.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions .ci_support/linux_ppc64le_.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
c_compiler:
- gcc
c_compiler_version:
- '13'
c_stdlib:
- sysroot
c_stdlib_version:
- '2.28'
cdt_name:
- cos7
channel_sources:
- conda-forge
channel_targets:
- conda-forge main
cxx_compiler:
- gxx
cxx_compiler_version:
- '13'
docker_image:
- quay.io/condaforge/linux-anvil-cos7-x86_64
target_platform:
- linux-ppc64le
zip_keys:
- - c_compiler_version
- cxx_compiler_version
- - c_stdlib_version
- cdt_name
zlib:
- '1'
zstd:
- '1.5'
7 changes: 7 additions & 0 deletions README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 28 additions & 3 deletions azure-pipelines.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions conda-forge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ conda_build:
build_platform:
linux_aarch64: linux_64
osx_arm64: osx_64
linux_ppc64le: linux_64
test: native_and_emulated
provider:
linux_ppc64le: default
3 changes: 3 additions & 0 deletions recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ case "${target_platform}" in
linux-aarch64)
bash "${RECIPE_DIR}"/build_scripts/cross-"${builder}"-linux-aarch64.sh
;;
linux-ppc64le)
bash "${RECIPE_DIR}"/build_scripts/cross-"${builder}"-linux-ppc64le.sh
;;
osx-arm64)
bash "${RECIPE_DIR}"/build_scripts/cross-"${builder}"-osx-arm64.sh
;;
Expand Down
67 changes: 67 additions & 0 deletions recipe/build_scripts/cross-zig-linux-ppc64le.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
set -euxo pipefail

# --- Functions ---

source "${RECIPE_DIR}/build_scripts/_functions.sh"

# --- Main ---

export ZIG_GLOBAL_CACHE_DIR="${PWD}/zig-global-cache"
export ZIG_LOCAL_CACHE_DIR="${PWD}/zig-local-cache"

cmake_build_dir="${SRC_DIR}/build-release"
cmake_install_dir="${SRC_DIR}/cmake-built-install"

mkdir -p "${cmake_build_dir}" && cp -r "${SRC_DIR}"/zig-source/* "${cmake_build_dir}"
mkdir -p "${cmake_install_dir}"
mkdir -p "${SRC_DIR}"/build-level-patches
cp -r "${RECIPE_DIR}"/patches/xxxx* "${SRC_DIR}"/build-level-patches

SYSROOT_ARCH="powerpc64le"

zig="${BUILD_PREFIX}/bin/zig"

_BUILD_SYSROOT_ARCH="x86_64"

patchelf --set-interpreter "${BUILD_PREFIX}/${_BUILD_SYSROOT_ARCH}-conda-linux-gnu/sysroot/lib64/ld-2.28.so" "${BUILD_PREFIX}/bin/zig"
patchelf --set-rpath "${BUILD_PREFIX}/${_BUILD_SYSROOT_ARCH}-conda-linux-gnu/sysroot/lib64" "${BUILD_PREFIX}/bin/zig"
patchelf --add-rpath "${BUILD_PREFIX}/${_BUILD_SYSROOT_ARCH}-conda-linux-gnu/sysroot/usr/lib64" "${BUILD_PREFIX}/bin/zig"
patchelf --add-rpath "${BUILD_PREFIX}/lib" "${BUILD_PREFIX}/bin/zig"
patchelf --shrink-rpath --allowed-rpath-prefixes "${BUILD_PREFIX}" "${BUILD_PREFIX}/bin/zig"

patchelf --remove-needed librt.so.1 "${BUILD_PREFIX}/bin/zig"
patchelf --remove-needed libdl.so.2 "${BUILD_PREFIX}/bin/zig"
patchelf --remove-needed libm.so.6 "${BUILD_PREFIX}/bin/zig"
patchelf --add-needed "${BUILD_PREFIX}/${_BUILD_SYSROOT_ARCH}-conda-linux-gnu/sysroot/lib64/librt-2.28.so" "${BUILD_PREFIX}/bin/zig"
patchelf --add-needed "${BUILD_PREFIX}/${_BUILD_SYSROOT_ARCH}-conda-linux-gnu/sysroot/lib64/libdl-2.28.so" "${BUILD_PREFIX}/bin/zig"
patchelf --add-needed "${BUILD_PREFIX}/${_BUILD_SYSROOT_ARCH}-conda-linux-gnu/sysroot/lib64/libm-2.28.so" "${BUILD_PREFIX}/bin/zig"

EXTRA_CMAKE_ARGS+=( \
"-DZIG_SHARED_LLVM=ON" \
"-DZIG_USE_LLVM_CONFIG=ON" \
"-DZIG_TARGET_TRIPLE=${SYSROOT_ARCH}-linux-gnu" \
)
# Zig searches for libm.so/libc.so in incorrect paths (libm.so with hard-coded /usr/lib64/libmvec_nonshared.a)
modify_libc_libm_for_zig "${BUILD_PREFIX}"

# When using installed c++ libs, zig needs libzigcpp.a
configure_cmake_zigcpp "${cmake_build_dir}" "${cmake_install_dir}"

# Zig needs the config.h to correctly (?) find the conda installed llvm, etc
EXTRA_ZIG_ARGS+=( \
"-Dconfig_h=${cmake_build_dir}/config.h" \
"-Doptimize=ReleaseFast"
"-Denable-llvm" \
"-Dstrip" \
"-Duse-zig-libcxx=false" \
"-Dtarget=${SYSROOT_ARCH}-linux-gnu" \
"-fqemu"
"--glibc-runtimes" "${PREFIX}/${SYSROOT_ARCH}-conda-linux-gnu/sysroot/lib64/libc.so.6"
)

mkdir -p "${SRC_DIR}/conda-zig-source" && cp -r "${SRC_DIR}"/zig-source/* "${SRC_DIR}/conda-zig-source"
remove_failing_langref "${SRC_DIR}/conda-zig-source"
# Cross-compiling with linux-64 zig, thus not using the emulator
CROSSCOMPILING_EMULATOR='' build_zig_with_zig "${SRC_DIR}/conda-zig-source" "${zig}" "${PREFIX}"
patchelf_installed_zig "${PREFIX}" "${PREFIX}"
10 changes: 5 additions & 5 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ source:
- url: https://github.com/ziglang/zig/archive/refs/tags/{{ version }}.tar.gz
sha256: d3912858003e340f315224bf177d0f441d86b81f62854f5c141b6d51ab6b5516
patches:
- patches/0001-cross-findllvm.patch # [linux and aarch64]
- patches/0001-cross-findllvm.patch # [linux and (aarch64 or ppc64le)]
folder: zig-source

# We may need to use the upstream binary dist if conda ZIG cannot build a newer version
Expand All @@ -25,7 +25,7 @@ source:
# sha256: d45312e61ebcc48032b77bc4cf7fd6915c11fa16e4aad116b66c9468211230ea # [linux]

build:
number: 3
number: 4
skip: true # [not linux and not osx]
script_env:
- BUILD_WITH_CMAKE=1 # [(linux or osx) and x86_64]
Expand All @@ -36,7 +36,7 @@ requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- {{ c_stdlib }}_{{ build_platform }} >={{ c_stdlib_version }} # [linux and aarch64]
- {{ c_stdlib }}_{{ build_platform }} >={{ c_stdlib_version }} # [linux and (aarch64 or ppc64le)]
- {{ stdlib("c") }}
- cmake >=3.5
- ninja
Expand All @@ -48,11 +48,11 @@ requirements:
- llvmdev {{ llvm_version }}
- llvm {{ llvm_version }}
- lld {{ llvm_version }}
- sysroot_{{ target_platform }} >=2.28 # [linux and aarch64]
- sysroot_{{ target_platform }} >=2.28 # [linux and (aarch64 or ppc64le)]
- zlib
- zstd
run:
- sysroot_{{ target_platform }} >=2.28 # [linux and aarch64]
- sysroot_{{ target_platform }} >=2.28 # [linux and (aarch64 or ppc64le)]

test:
commands:
Expand Down
Loading