@@ -29,9 +29,44 @@ steps:
2929 echo "build_config=${{ parameters.build_config }}"
3030 displayName : ' Print Parameters'
3131
32+ - bash : |
33+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
34+ echo '##vso[task.prependpath]$HOME/.cargo/bin'
35+ source "$HOME/.cargo/env"
36+ rustup toolchain install 1.86.0
37+ rustup override set 1.86.0
38+ if [ "$(arch)" = "arm64" ]; then
39+ rustup target add aarch64-apple-darwin --toolchain 1.86.0
40+ fi
41+ rustc --version
42+ rustup show active-toolchain
43+ displayName : ' Install Rust Toolchain'
44+ workingDirectory : ' $(Build.Repository.LocalPath)'
45+
46+ - bash : |
47+ brew update --quiet
48+ brew install --quiet llvm@18
49+ LLVM_PREFIX="$(brew --prefix llvm@18)"
50+ echo "##vso[task.setvariable variable=LLVM_PREFIX]$LLVM_PREFIX"
51+ echo "##vso[task.prependpath]$LLVM_PREFIX/bin"
52+ displayName : ' Install LLVM'
53+ workingDirectory : ' $(Build.Repository.LocalPath)'
54+
3255- powershell : |
3356 $env:MACOSX_DEPLOYMENT_TARGET = "12.0" # Monterey
34- cmake --preset macos_$(arch)_$(ep)_$(build_config)
57+ $env:CC="$env:LLVM_PREFIX\bin\clang"
58+ $env:CXX="$env:LLVM_PREFIX\bin\clang++"
59+ if ("$(arch)" -eq "arm64") {
60+ $env:CARGO_BUILD_TARGET = "aarch64-apple-darwin"
61+ $env:CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER = $env:CC
62+ $env:CC_aarch64_apple_darwin = $env:CC
63+ $env:CXX_aarch64_apple_darwin = $env:CXX
64+ Remove-Item Env:CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER -ErrorAction SilentlyContinue
65+ Remove-Item Env:CC_x86_64_apple_darwin -ErrorAction SilentlyContinue
66+ cmake --preset macos_$(arch)_$(ep)_$(build_config) -DCMAKE_OSX_ARCHITECTURES=arm64 -DRust_CARGO_TARGET=aarch64-apple-darwin
67+ } else {
68+ cmake --preset macos_$(arch)_$(ep)_$(build_config)
69+ }
3570 displayName : ' Configure CMake C API'
3671 workingDirectory : ' $(Build.Repository.LocalPath)'
3772
4681 displayName: 'Install wheel'
4782
4883 - powershell : |
84+ $env:RUSTFLAGS="-C link-arg=-undefined -C link-arg=dynamic_lookup"
4985 cmake --build --preset macos_$(arch)_$(ep)_$(build_config) --target package
5086 displayName: 'Package C/C++ API'
5187 workingDirectory: '$(Build.Repository.LocalPath)'
@@ -95,6 +131,7 @@ steps:
95131 displayName: 'Install wheel'
96132
97133 - powershell : |
134+ $env:RUSTFLAGS="-C link-arg=-undefined -C link-arg=dynamic_lookup"
98135 # From: https://github.com/pypa/cibuildwheel/blob/93542c397cfe940bcbb8f1eff5c37d345ea16653/cibuildwheel/macos.py#L247-L260
99136 if ("$(arch)" -eq "arm64") {
100137 $env:_PYTHON_HOST_PLATFORM = "macosx-12.0-arm64"
0 commit comments