From fcceca5976993f8986099953315ce5d6617a0fde Mon Sep 17 00:00:00 2001 From: Logan McNaughton <848146+loganmc10@users.noreply.github.com> Date: Thu, 12 Mar 2026 12:49:59 +0100 Subject: [PATCH] fix mac build (#676) * fix mac build * add freetype * set deployment target * test * test * more * test * more * more * more * more * test * put back * link CoreFoundation * more * more * more --- .cargo/config.toml | 4 +++- .github/workflows/build.yml | 12 ++++++++---- build.rs | 13 +++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index dad69719..d901dc4b 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,7 +1,7 @@ [target.'cfg(all(target_arch = "aarch64", target_os = "linux"))'] rustflags = ["-C", "link-arg=-fuse-ld=lld"] -[target.'cfg(target_os = "windows")'] +[target.'cfg(any(target_os = "windows", target_os = "macos"))'] linker = "rust-lld" [target.'cfg(target_arch = "x86_64")'] @@ -14,3 +14,5 @@ rustflags = ["-C", "target-cpu=cortex-a76"] CC = "clang" CXX = "clang++" AR = "llvm-ar" +MACOSX_DEPLOYMENT_TARGET = "15.0" +SDKROOT = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3ccce3ed..ccca7ef6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -129,16 +129,14 @@ jobs: wait-for-completion: false build-macos: - if: false runs-on: macos-15 strategy: fail-fast: false matrix: include: - - target: x86_64-apple-darwin - arch: mac-x86_64 - target: aarch64-apple-darwin arch: mac-aarch64 + llvm: ARM64 steps: - uses: actions/checkout@v6 with: @@ -147,13 +145,19 @@ jobs: with: target: ${{ matrix.target }} rustflags: "" + - name: Set LLVM_VERSION + run: echo "LLVM_VERSION=$(rustc --version --verbose | grep "LLVM version" | cut -d':' -f2 | xargs)" >> $GITHUB_ENV + - name: Install LLVM and Clang + uses: KyleMayes/install-llvm-action@v2 + with: + version: ${{ env.LLVM_VERSION }} + force-url: https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ env.LLVM_VERSION }}/LLVM-${{ env.LLVM_VERSION }}-macOS-${{ matrix.llvm }}.tar.xz - name: Build run: | cargo build --release -v --target=${{ matrix.target }} mkdir output cp target/${{ matrix.target }}/release/gopher64 output/gopher64-${{ matrix.arch }} env: - AR: ar NETPLAY_ID: ${{ secrets.NETPLAY_ID }} - name: Upload file uses: actions/upload-artifact@v7 diff --git a/build.rs b/build.rs index ad87a950..e3fbd9c7 100644 --- a/build.rs +++ b/build.rs @@ -94,6 +94,19 @@ fn main() { .set_icon("data/icon/icon.ico") .compile() .unwrap(); + } else if os == "macos" { + println!("cargo:rustc-link-search=native=/opt/homebrew/opt/freetype/lib"); + println!("cargo:rustc-link-lib=freetype"); + + let output = std::process::Command::new("clang") + .args(["--print-runtime-dir"]) + .output() + .unwrap(); + + let runtime_dir = String::from_utf8_lossy(&output.stdout).trim().to_string(); + + println!("cargo:rustc-link-search=native={}", runtime_dir); + println!("cargo:rustc-link-lib=static=clang_rt.osx"); } volk_build.flag("-flto=thin");