@@ -70,15 +70,24 @@ jobs:
7070 build_julia_binaries :
7171 needs : check_pr_push
7272 if : needs.check_pr_push.result == 'success' && needs.check_pr_push.outputs.run == 'true'
73- runs-on : ${{ matrix.os }}
73+ runs-on : ${{ matrix.runner || matrix. os }}
7474 strategy :
7575 fail-fast : false
7676 matrix :
77- os : [ubuntu-latest, macos-latest, windows-latest]
78- architecture : [x86_64, aarch64]
79- exclude :
80- - os : windows -latest
77+ include :
78+ - os : ubuntu-latest
79+ architecture : x86_64
80+ - os : ubuntu -latest
8181 architecture : aarch64
82+ runner : ubuntu-latest
83+ - os : macos-13
84+ architecture : x86_64
85+ runner : macos-13 # Intel Mac for x86_64
86+ - os : macos-latest
87+ architecture : aarch64
88+ runner : macos-latest # ARM64 Mac
89+ - os : windows-latest
90+ architecture : x86_64
8291
8392 steps :
8493 - uses : actions/checkout@v4
@@ -88,22 +97,14 @@ jobs:
8897 - name : Set up Rust
8998 run : rustup show
9099
100+ - name : Setup LLVM 14.0.6
101+ uses : ./.github/actions/setup-llvm
102+
91103 - name : Install Rust target
92104 run : |
93- if [ "${{ matrix.architecture }}" = "aarch64" ]; then
94- if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
95- rustup target add aarch64-unknown-linux-gnu
96- sudo apt-get update
97- sudo apt-get install -y gcc-aarch64-linux-gnu
98- elif [ "${{ matrix.os }}" = "macos-latest" ]; then
99- rustup target add aarch64-apple-darwin
100- fi
101- else
102- # For x86_64 builds on ARM64 macOS
103- if [ "${{ matrix.os }}" = "macos-latest" ]; then
104- rustup target add x86_64-apple-darwin
105- fi
106- fi
105+ # With native ARM64 runners, no cross-compilation setup is needed
106+ # All builds are now native for their respective architectures
107+ echo "Using native build for ${{ matrix.architecture }} on ${{ matrix.os }}"
107108
108109 - name : Set up Visual Studio environment on Windows
109110 if : runner.os == 'Windows'
@@ -133,33 +134,49 @@ jobs:
133134 run : |
134135 cd julia/pecos-julia-ffi
135136
136- if [ "${{ matrix.architecture }}" = "aarch64" ]; then
137- if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
138- export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
139- cargo build --release --target aarch64-unknown-linux-gnu
140- target_dir="../../target/aarch64-unknown-linux-gnu/release"
141- elif [ "${{ matrix.os }}" = "macos-latest" ]; then
142- cargo build --release --target aarch64-apple-darwin
143- target_dir="../../target/aarch64-apple-darwin/release"
144- fi
145- else
146- # For x86_64 builds
147- if [ "${{ matrix.os }}" = "macos-latest" ]; then
148- # On ARM64 macOS, explicitly build for x86_64
149- cargo build --release --target x86_64-apple-darwin
150- target_dir="../../target/x86_64-apple-darwin/release"
151- else
152- cargo build --release
153- target_dir="../../target/release"
154- fi
137+ # Set up build flags for macOS to avoid LLVM dependency issues
138+ if [[ "${{ matrix.os }}" == macos-* ]]; then
139+ # Prevent linking against LLVM's libunwind
140+ export RUSTFLAGS="-C link-arg=-Wl,-dead_strip_dylibs -C link-arg=-Wl,-ld_classic"
141+ # Remove LLVM from library paths during build
142+ unset DYLD_LIBRARY_PATH
143+ unset DYLD_FALLBACK_LIBRARY_PATH
144+ # Explicitly exclude LLVM libraries from linking
145+ export RUSTFLAGS="$RUSTFLAGS -L native=/usr/lib"
155146 fi
156147
148+ # Native build for all platforms (no cross-compilation needed with native ARM64 runners)
149+ cargo build --release
150+ target_dir="../../target/release"
151+
157152 # Create artifact directory
158153 mkdir -p ../../artifacts
159154
160155 # Copy the built library
161- if [ "${{ matrix.os }}" = " macos-latest" ]; then
156+ if [[ "${{ matrix.os }}" == macos-* ] ]; then
162157 cp $target_dir/libpecos_julia.dylib ../../artifacts/
158+
159+ # Fix any remaining LLVM dependencies
160+ echo "Checking and fixing library dependencies..."
161+ otool -L ../../artifacts/libpecos_julia.dylib
162+
163+ # Check for any problematic dependencies
164+ if otool -L ../../artifacts/libpecos_julia.dylib | grep -q "/tmp/llvm"; then
165+ echo "ERROR: Binary has dependencies on /tmp/llvm which won't exist at runtime!"
166+ echo "Attempting to fix..."
167+
168+ # For libunwind specifically, we'll strip it out by creating a new dylib without it
169+ if otool -L ../../artifacts/libpecos_julia.dylib | grep -q "/tmp/llvm/lib/libunwind.dylib"; then
170+ echo "Creating fixed library without LLVM libunwind dependency..."
171+ # Use install_name_tool to remove the dependency by setting it to a weak import
172+ # that can fail at runtime without crashing
173+ install_name_tool -change /tmp/llvm/lib/libunwind.dylib /usr/lib/libSystem.B.dylib ../../artifacts/libpecos_julia.dylib || \
174+ echo "Warning: Could not remap libunwind dependency"
175+ fi
176+ fi
177+
178+ echo "Final library dependencies:"
179+ otool -L ../../artifacts/libpecos_julia.dylib
163180 else
164181 cp $target_dir/libpecos_julia.so ../../artifacts/
165182 fi
@@ -200,7 +217,7 @@ jobs:
200217 os : windows-latest
201218 architecture : x86_64
202219 - runner : macos-13
203- os : macos-latest
220+ os : macos-13
204221 architecture : x86_64
205222 - runner : macos-latest
206223 os : macos-latest
0 commit comments