Skip to content

Commit

Permalink
Merge pull request #158 from mattip/v2.20.0
Browse files Browse the repository at this point in the history
Cross-compile for osx-arm64
  • Loading branch information
mattip authored Jul 3, 2024
2 parents b0979da + 02c440f commit e1979f5
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .azure-pipelines/azure-pipelines-osx.yml

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

40 changes: 40 additions & 0 deletions .ci_support/osx_arm64_python3.10.____cpython.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
MACOSX_DEPLOYMENT_TARGET:
- '11.0'
MACOSX_SDK_VERSION:
- '11.0'
c_compiler:
- clang
c_compiler_version:
- '16'
c_stdlib:
- macosx_deployment_target
c_stdlib_version:
- '11.0'
channel_sources:
- conda-forge
channel_targets:
- conda-forge main
curl:
- '8'
cxx_compiler:
- clangxx
cxx_compiler_version:
- '16'
libgrpc:
- '1.62'
macos_machine:
- arm64-apple-darwin20.0.0
nodejs:
- '18'
- '20'
pin_run_as_build:
python:
min_pin: x.x
max_pin: x.x
python:
- 3.10.* *_cpython
target_platform:
- osx-arm64
zip_keys:
- - c_compiler_version
- cxx_compiler_version
40 changes: 40 additions & 0 deletions .ci_support/osx_arm64_python3.11.____cpython.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
MACOSX_DEPLOYMENT_TARGET:
- '11.0'
MACOSX_SDK_VERSION:
- '11.0'
c_compiler:
- clang
c_compiler_version:
- '16'
c_stdlib:
- macosx_deployment_target
c_stdlib_version:
- '11.0'
channel_sources:
- conda-forge
channel_targets:
- conda-forge main
curl:
- '8'
cxx_compiler:
- clangxx
cxx_compiler_version:
- '16'
libgrpc:
- '1.62'
macos_machine:
- arm64-apple-darwin20.0.0
nodejs:
- '18'
- '20'
pin_run_as_build:
python:
min_pin: x.x
max_pin: x.x
python:
- 3.11.* *_cpython
target_platform:
- osx-arm64
zip_keys:
- - c_compiler_version
- cxx_compiler_version
40 changes: 40 additions & 0 deletions .ci_support/osx_arm64_python3.9.____cpython.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
MACOSX_DEPLOYMENT_TARGET:
- '11.0'
MACOSX_SDK_VERSION:
- '11.0'
c_compiler:
- clang
c_compiler_version:
- '16'
c_stdlib:
- macosx_deployment_target
c_stdlib_version:
- '11.0'
channel_sources:
- conda-forge
channel_targets:
- conda-forge main
curl:
- '8'
cxx_compiler:
- clangxx
cxx_compiler_version:
- '16'
libgrpc:
- '1.62'
macos_machine:
- arm64-apple-darwin20.0.0
nodejs:
- '18'
- '20'
pin_run_as_build:
python:
min_pin: x.x
max_pin: x.x
python:
- 3.9.* *_cpython
target_platform:
- osx-arm64
zip_keys:
- - c_compiler_version
- cxx_compiler_version
21 changes: 21 additions & 0 deletions README.md

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

2 changes: 2 additions & 0 deletions conda-forge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ conda_forge_output_validation: true
github:
branch_name: main
tooling_branch_name: main
build_platform:
osx_arm64: osx_64
test: native_and_emulated
18 changes: 18 additions & 0 deletions recipe/build-core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ if [[ "$target_platform" == osx* ]]; then
# make sure the vendored redis OSX build can find the correct toolchain. the SDKROOT is
# also passed as we are using at least OSX 10.15 which moves the include directory out
# of /usr/include to ${SDKROOT}/MacOSX.sdk/usr/include
if [[ "$target_platform" == osx-arm64 ]]; then
# https://github.com/conda-forge/bazel-toolchain-feedstock/issues/18
# delete the line from the template and the CXXFLAGS
export CXXFLAGS=${CXXFLAGS/-stdlib=libc++ /}
export LDFLAGS="$LDFLAGS -undefined dynamic_lookup -Wl,-framework,Foundation"
sed -e"/stdlib=libc/d" -i'' $CONDA_PREFIX/share/bazel_toolchain/CROSSTOOL.template
source gen-bazel-toolchain
fi
cat >> .bazelrc <<EOF
build --define CONDA_CC=${CC}
build --define CONDA_CFLAGS="${CFLAGS}"
Expand All @@ -13,6 +21,15 @@ build --define CONDA_NM=${NM}
build --define CONDA_RANLIB=${RANLIB}
build --define CONDA_SDKROOT=${SDKROOT}
EOF
if [[ "$target_platform" == osx-arm64 ]]; then
cat >> .bazelrc <<EOF
# build --subcommands
build --crosstool_top=//bazel_toolchain:toolchain
build --cpu=darwin_arm64
build --platforms=//bazel_toolchain:target_platform
build --host_platform=//bazel_toolchain:build_platform
EOF
fi
fi

if [[ -e $CONDA_PREFIX/include/crypt.h ]]; then
Expand All @@ -23,6 +40,7 @@ fi

cd python/
export SKIP_THIRDPARTY_INSTALL=1

"${PYTHON}" setup.py build
# bazel by default makes everything read-only,
# which leads to patchelf failing to fix rpath in binaries.
Expand Down
3 changes: 3 additions & 0 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ source:
- patches/0002-Disable-making-entry-scripts.patch
- patches/0003-Ignore-warnings-in-event.cc-and-logging.cc.patch
- patches/0004-Remove-all-dependencies-from-setup.py.patch
- patches/0006-remove-stdlib-libc-from-.bazelrc.patch # [osx and arm64]
# See https://github.com/conda-forge/ray-packages-feedstock/issues/136
# Keep in sync with current or active migration of libgrpc to avoid
# ABI breakage
- patches/0005-Vendor-grpc-1.62.2.patch
Expand Down Expand Up @@ -62,6 +64,7 @@ outputs:
- {{ stdlib("c") }}
- {{ compiler('cxx') }}
- bazel 6.5
- bazel-toolchain # [not win]
- patchelf # [linux]
- colorama
- curl
Expand Down
29 changes: 29 additions & 0 deletions recipe/patches/0006-remove-stdlib-libc-from-.bazelrc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
From 4491cf3e9e181bcffb09a891128c5f51e4adde6e Mon Sep 17 00:00:00 2001
From: Matti Picus <[email protected]>
Date: Thu, 9 May 2024 05:13:50 +1000
Subject: [PATCH] remove stdlib=libc++ from .bazelrc

---
.bazelrc | 3 ---
1 file changed, 3 deletions(-)

diff --git a/.bazelrc b/.bazelrc
index c9ba801319..3151efbd1d 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -92,9 +92,9 @@ build:manylinux2010 --linkopt="-lrt"

# LLVM (clang & libc++) build flags common across Linux installations and systems.
# On Ubuntu, the remaining configurations can be generated by running ci/env/install-llvm-binaries.sh
-build:llvm --action_env=CXXFLAGS=-stdlib=libc++
-build:llvm --action_env=LDFLAGS=-stdlib=libc++
-build:llvm --action_env=BAZEL_CXXOPTS=-stdlib=libc++
+build:llvm --action_env=CXXFLAGS=-Wno-error=unused-command-line-argument
+build:llvm --action_env=LDFLAGS=-Wno-error=unused-command-line-argument
+build:llvm --action_env=BAZEL_CXXOPTS=-Wno-error=unused-command-line-argument
build:llvm --action_env=BAZEL_LINKLIBS=-l%:libc++.a:-l%:libc++abi.a
build:llvm --action_env=BAZEL_LINKOPTS=-lm:-pthread
build:llvm --define force_libcpp=enabled
--
2.39.3 (Apple Git-146)

0 comments on commit e1979f5

Please sign in to comment.