-
Notifications
You must be signed in to change notification settings - Fork 28
macos matrix #280
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
base: main
Are you sure you want to change the base?
macos matrix #280
Conversation
WalkthroughAdds a macOS matrix build (x64, arm64) to the GitHub Actions CMake workflow with per-architecture Homebrew/LLVM setup, split CMake configure steps guarded by arch that set compilers, CMAKE flags, REDUMPER_ARCH, and updates artifact names to include the architecture. Changes
Sequence Diagram(s)sequenceDiagram
participant GH as GitHub Actions
participant Job as build-macos (matrix)
participant Runner as macOS Runner
participant Brew as Homebrew
participant CMake as CMake
GH->>Job: start (matrix: x64, arm64)
loop per matrix.arch
Job->>Runner: checkout + setup
alt arch == x64
Runner->>Brew: install llvm@18 via arch -x86_64 Homebrew
Runner->>CMake: configure with x86_64 clang++, set CMAKE_OSX_ARCHITECTURES=x86_64, REDUMPER_ARCH=x64, libcpp link opts
else arch == arm64
Runner->>Brew: install llvm@18 via standard Homebrew
Runner->>CMake: configure with arm64 clang++, REDUMPER_ARCH=arm64, libcpp link opts
end
Runner->>CMake: build / test / package
Runner-->>GH: upload artifact macos_${{ matrix.arch }}
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (3)
.github/workflows/cmake.yml (3)
126-127
: Optional: Avoid Intel Homebrew by using the system toolchain for x64 cross-compileYou can simplify the x64 path by using /usr/bin/clang++ with -DCMAKE_OSX_ARCHITECTURES=x86_64 and rely on the SDK’s libc++, removing the need for Intel Homebrew and custom link flags.
Example (alternative to your current x64 configure step):
- name: CMake Configure (x64 - system toolchain) if: ${{ matrix.arch == 'x64' }} run: CXX=/usr/bin/clang++ cmake -B ${{github.workspace}}/BUILD -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DREDUMPER_VERSION_BUILD=${{needs.check.outputs.build_number}} -DCMAKE_OSX_ARCHITECTURES=x86_64 -DREDUMPER_OS=macos -DREDUMPER_ARCH=x64This typically produces x86_64 binaries that run under Rosetta without extra rpath juggling.
112-114
: Prevent matrix cancelation cascade by setting fail-fast: falseIf one arch fails, the other will be canceled by default. Disable fail-fast to always get results for both macOS arches.
Apply this diff:
build-macos: needs: check - strategy: + strategy: + fail-fast: false matrix: arch: [x64, arm64]
117-123
: Consider ensuring Ninja is present explicitlyNinja is usually preinstalled on GitHub macOS runners, but if the image changes, the build will break. Installing it is quick and makes the job more robust.
Add after the existing brew installs:
- name: Ensure Ninja if: ${{ matrix.arch == 'arm64' }} run: brew install ninja - name: Ensure Ninja (x64) if: ${{ matrix.arch == 'x64' }} run: arch -x86_64 /usr/local/bin/brew install ninja
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
.github/workflows/cmake.yml
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: build-windows (x64, x64)
- GitHub Check: build-linux (x64, ubuntu-24.04)
- GitHub Check: build-windows (x86, Win32)
- GitHub Check: build-windows (arm64, ARM64)
- GitHub Check: build-linux (arm64, ubuntu-24.04-arm)
- GitHub Check: build-linux (x86, ubuntu-24.04)
🔇 Additional comments (1)
.github/workflows/cmake.yml (1)
142-143
: Artifact naming by architecture looks goodmacOS artifacts now disambiguate x64 vs arm64. This will make the release aggregation cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (2)
.github/workflows/cmake.yml (2)
118-122
: x64 path: ensure Rosetta and Intel Homebrew exist; make install non-interactiveAs-is, arch -x86_64 commands will likely fail on macOS-14 runners without Rosetta and /usr/local Homebrew. Also make the installer non-interactive and avoid redundant reinstalls.
- name: Customize Software if: ${{ matrix.arch == 'x64' }} run: | - arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - arch -x86_64 /usr/local/bin/brew install llvm@18 + # Ensure Rosetta 2 is available (required for x64 toolchain & tests) + sudo /usr/sbin/softwareupdate --install-rosetta --agree-to-license + export NONINTERACTIVE=1 + # Ensure Intel Homebrew exists at /usr/local (idempotent) + if [ ! -x /usr/local/bin/brew ]; then + arch -x86_64 /bin/bash -lc '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' + fi + arch -x86_64 /usr/local/bin/brew update + arch -x86_64 /usr/local/bin/brew install llvm@18
128-132
: Add rpath for LLVM’s libc++ and set CC too; enable install rpath in CMakeWithout an rpath, tests/binaries may fail at runtime due to unresolved libc++ dylibs. Also set CC to the same toolchain to avoid mixed compilers.
- name: CMake Configure if: ${{ matrix.arch == 'x64' }} - run: CXX=$(arch -x86_64 /usr/local/bin/brew --prefix llvm@18)/bin/clang++ cmake -B ${{github.workspace}}/BUILD -G "Ninja" -DREDUMPER_CLANG_USE_LIBCPP=ON -DREDUMPER_CLANG_LINK_OPTIONS="-L$(arch -x86_64 /usr/local/bin/brew --prefix llvm@18)/lib/c++" -DCMAKE_BUILD_TYPE=Release -DREDUMPER_VERSION_BUILD=${{needs.check.outputs.build_number}} -DCMAKE_OSX_ARCHITECTURES=x86_64 -DREDUMPER_OS=macos -DREDUMPER_ARCH=x64 + run: CC=$(arch -x86_64 /usr/local/bin/brew --prefix llvm@18)/bin/clang CXX=$(arch -x86_64 /usr/local/bin/brew --prefix llvm@18)/bin/clang++ cmake -B ${{github.workspace}}/BUILD -G "Ninja" -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DREDUMPER_CLANG_USE_LIBCPP=ON -DREDUMPER_CLANG_LINK_OPTIONS="-L$(arch -x86_64 /usr/local/bin/brew --prefix llvm@18)/lib/c++ -Wl,-rpath,$(arch -x86_64 /usr/local/bin/brew --prefix llvm@18)/lib/c++" -DCMAKE_BUILD_TYPE=Release -DREDUMPER_VERSION_BUILD=${{needs.check.outputs.build_number}} -DCMAKE_OSX_ARCHITECTURES=x86_64 -DREDUMPER_OS=macos -DREDUMPER_ARCH=x64 @@ - name: CMake Configure if: ${{ matrix.arch == 'arm64' }} - run: CXX=$(brew --prefix llvm@18)/bin/clang++ cmake -B ${{github.workspace}}/BUILD -G "Ninja" -DREDUMPER_CLANG_USE_LIBCPP=ON -DREDUMPER_CLANG_LINK_OPTIONS="-L$(brew --prefix llvm@18)/lib/c++" -DCMAKE_BUILD_TYPE=Release -DREDUMPER_VERSION_BUILD=${{needs.check.outputs.build_number}} -DREDUMPER_OS=macos -DREDUMPER_ARCH=arm64 + run: CC=$(brew --prefix llvm@18)/bin/clang CXX=$(brew --prefix llvm@18)/bin/clang++ cmake -B ${{github.workspace}}/BUILD -G "Ninja" -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DREDUMPER_CLANG_USE_LIBCPP=ON -DREDUMPER_CLANG_LINK_OPTIONS="-L$(brew --prefix llvm@18)/lib/c++ -Wl,-rpath,$(brew --prefix llvm@18)/lib/c++)" -DCMAKE_BUILD_TYPE=Release -DREDUMPER_VERSION_BUILD=${{needs.check.outputs.build_number}} -DREDUMPER_OS=macos -DREDUMPER_ARCH=arm64
🧹 Nitpick comments (4)
.github/workflows/cmake.yml (4)
112-115
: Consider setting fail-fast: false so arm64 still runs if x64 failsThis avoids losing signal from one arch when the other breaks.
strategy: + fail-fast: false matrix: arch: [x64, arm64]
123-124
: Update Homebrew before installing llvm@18 on arm64Prevents transient failures from stale brew metadata.
- run: brew install llvm@18 + run: | + brew update + brew install llvm@18
128-132
: Optional: explicitly set CMAKE_OSX_ARCHITECTURES=arm64 for clarityNot required (defaults to host arch), but improves readability symmetry with the x64 path.
- run: CC=$(brew --prefix llvm@18)/bin/clang CXX=$(brew --prefix llvm@18)/bin/clang++ cmake -B ${{github.workspace}}/BUILD -G "Ninja" -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DREDUMPER_CLANG_USE_LIBCPP=ON -DREDUMPER_CLANG_LINK_OPTIONS="-L$(brew --prefix llvm@18)/lib/c++ -Wl,-rpath,$(brew --prefix llvm@18)/lib/c++)" -DCMAKE_BUILD_TYPE=Release -DREDUMPER_VERSION_BUILD=${{needs.check.outputs.build_number}} -DREDUMPER_OS=macos -DREDUMPER_ARCH=arm64 + run: CC=$(brew --prefix llvm@18)/bin/clang CXX=$(brew --prefix llvm@18)/bin/clang++ cmake -B ${{github.workspace}}/BUILD -G "Ninja" -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DREDUMPER_CLANG_USE_LIBCPP=ON -DREDUMPER_CLANG_LINK_OPTIONS="-L$(brew --prefix llvm@18)/lib/c++ -Wl,-rpath,$(brew --prefix llvm@18)/lib/c++)" -DCMAKE_BUILD_TYPE=Release -DREDUMPER_VERSION_BUILD=${{needs.check.outputs.build_number}} -DCMAKE_OSX_ARCHITECTURES=arm64 -DREDUMPER_OS=macos -DREDUMPER_ARCH=arm64
118-132
: Alternative approach: avoid Intel Homebrew by cross-compiling with Apple toolchainIf LLVM@18 isn’t strictly required, you can skip installing Intel Homebrew and build x64 using Apple Clang with -arch x86_64, which is faster and simpler on macOS-14 ARM runners.
Example configure (no Intel brew):
- Ensure Xcode tools: xcode-select -p (preinstalled on runners)
- Use: cmake ... -DCMAKE_OSX_ARCHITECTURES=x86_64 (and rely on Apple libc++)
- Or with Homebrew LLVM (arm64) as the compiler: set CXX=$(brew --prefix llvm@18)/bin/clang++ and add -target x86_64-apple-darwin to CMAKE_CXX_FLAGS, plus SDK-based link flags. This avoids Intel brew entirely but requires careful SDK flags. Happy to draft this if you want to go this route.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
.github/workflows/cmake.yml
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: build-windows (x64, x64)
- GitHub Check: build-macos (x64)
- GitHub Check: build-windows (arm64, ARM64)
- GitHub Check: build-macos (arm64)
- GitHub Check: build-windows (x86, Win32)
- GitHub Check: build-linux (x64, ubuntu-24.04)
- GitHub Check: build-linux (x86, ubuntu-24.04)
🔇 Additional comments (1)
.github/workflows/cmake.yml (1)
144-144
: Artifact naming with arch suffix looks goodClearer release assets and aligns with the matrix.
@coderabbitai explain "Or with Homebrew LLVM (arm64) as the compiler: set CXX=$(brew --prefix llvm@18)/bin/clang++ and add -target x86_64-apple-darwin to CMAKE_CXX_FLAGS, plus SDK-based link flags. This avoids Intel brew entirely but requires careful SDK flags. Happy to draft this if you want to go this route." |
Tip For best results, initiate chat on the files or code changes. @superg: This approach describes cross-compilation from an ARM64 macOS host to produce x86_64 binaries using a single ARM64 Homebrew installation, rather than maintaining separate Intel and ARM64 brew environments. Here's how it works: The Cross-Compilation StrategyCompiler Setup:
Target Architecture:
SDK and Linking:
Comparison with Current PR ApproachCurrent PR (dual brew): - x64: arch -x86_64 brew install llvm@18 # Intel brew
- arm64: brew install llvm@18 # ARM64 brew Proposed approach (cross-compilation): # Single ARM64 brew, cross-compile for x64
- brew install llvm@18 # ARM64 only
- CXX=$(brew --prefix llvm@18)/bin/clang++
- CMAKE_CXX_FLAGS="-target x86_64-apple-darwin ..." Benefits:
Challenges:
This approach leverages clang++'s excellent cross-compilation capabilities rather than running Intel binaries under Rosetta 2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (2)
.github/workflows/cmake.yml (2)
118-122
: x64 setup likely fails without Rosetta and a guaranteed Intel Homebrew prefixOn macOS-14 (Apple Silicon) runners,
/usr/local/bin/brew
is not present by default and Rosetta may not be installed. Running the Intel Brew install script underarch -x86_64
can fail without Rosetta; subsequent uses of/usr/local/bin/brew
will then fail as well.Make the step idempotent and robust by ensuring Rosetta and Intel Homebrew exist before installing
llvm@18
.Apply this diff:
- - name: Customize Software - if: ${{ matrix.arch == 'x64' }} - run: | - arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - arch -x86_64 /usr/local/bin/brew install llvm@18 + - name: Customize Software (x64 - ensure Rosetta + Intel Homebrew + llvm@18) + if: ${{ matrix.arch == 'x64' }} + run: | + # Ensure Rosetta (idempotent) + /usr/sbin/softwareupdate --install-rosetta --agree-to-license || true + # Ensure Intel Homebrew at /usr/local (idempotent) + if [ ! -x /usr/local/bin/brew ]; then + NONINTERACTIVE=1 arch -x86_64 /bin/bash -lc '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' + fi + arch -x86_64 /usr/local/bin/brew update + arch -x86_64 /usr/local/bin/brew install llvm@18
129-132
: Add rpath for LLVM’s libc++ so built binaries can locate the dylibs at runtimeYou pass only -L in REDUMPER_CLANG_LINK_OPTIONS. On macOS, libc++ is dynamically linked; without an rpath, running tests or binaries can fail with missing dylibs.
Apply this diff to both configure steps:
- run: CXX=$(arch -x86_64 /usr/local/bin/brew --prefix llvm@18)/bin/clang++ cmake -B ${{github.workspace}}/BUILD -G "Ninja" -DREDUMPER_CLANG_USE_LIBCPP=ON -DREDUMPER_CLANG_LINK_OPTIONS="-L$(arch -x86_64 /usr/local/bin/brew --prefix llvm@18)/lib/c++" -DCMAKE_BUILD_TYPE=Release -DREDUMPER_VERSION_BUILD=${{needs.check.outputs.build_number}} -DCMAKE_OSX_ARCHITECTURES=x86_64 -DREDUMPER_OS=macos -DREDUMPER_ARCH=x64 + run: CXX=$(arch -x86_64 /usr/local/bin/brew --prefix llvm@18)/bin/clang++ cmake -B ${{github.workspace}}/BUILD -G "Ninja" -DREDUMPER_CLANG_USE_LIBCPP=ON -DREDUMPER_CLANG_LINK_OPTIONS="-L$(arch -x86_64 /usr/local/bin/brew --prefix llvm@18)/lib/c++ -Wl,-rpath,$(arch -x86_64 /usr/local/bin/brew --prefix llvm@18)/lib/c++" -DCMAKE_BUILD_TYPE=Release -DREDUMPER_VERSION_BUILD=${{needs.check.outputs.build_number}} -DCMAKE_OSX_ARCHITECTURES=x86_64 -DREDUMPER_OS=macos -DREDUMPER_ARCH=x64 @@ - run: CXX=$(brew --prefix llvm@18)/bin/clang++ cmake -B ${{github.workspace}}/BUILD -G "Ninja" -DREDUMPER_CLANG_USE_LIBCPP=ON -DREDUMPER_CLANG_LINK_OPTIONS="-L$(brew --prefix llvm@18)/lib/c++" -DCMAKE_BUILD_TYPE=Release -DREDUMPER_VERSION_BUILD=${{needs.check.outputs.build_number}} -DCMAKE_OSX_ARCHITECTURES=arm64 -DREDUMPER_OS=macos -DREDUMPER_ARCH=arm64 + run: CXX=$(brew --prefix llvm@18)/bin/clang++ cmake -B ${{github.workspace}}/BUILD -G "Ninja" -DREDUMPER_CLANG_USE_LIBCPP=ON -DREDUMPER_CLANG_LINK_OPTIONS="-L$(brew --prefix llvm@18)/lib/c++ -Wl,-rpath,$(brew --prefix llvm@18)/lib/c++" -DCMAKE_BUILD_TYPE=Release -DREDUMPER_VERSION_BUILD=${{needs.check.outputs.build_number}} -DCMAKE_OSX_ARCHITECTURES=arm64 -DREDUMPER_OS=macos -DREDUMPER_ARCH=arm64
🧹 Nitpick comments (1)
.github/workflows/cmake.yml (1)
129-132
: Optional: align macOS with Linux by enabling install-time rpath in the build treeLinux configure adds -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON; mirroring that on macOS improves run-from-build reliability.
Apply this diff together with the previous:
- run: CXX=$(arch -x86_64 /usr/local/bin/brew --prefix llvm@18)/bin/clang++ cmake -B ${{github.workspace}}/BUILD -G "Ninja" -DREDUMPER_CLANG_USE_LIBCPP=ON -DREDUMPER_CLANG_LINK_OPTIONS="-L$(arch -x86_64 /usr/local/bin/brew --prefix llvm@18)/lib/c++" -DCMAKE_BUILD_TYPE=Release -DREDUMPER_VERSION_BUILD=${{needs.check.outputs.build_number}} -DCMAKE_OSX_ARCHITECTURES=x86_64 -DREDUMPER_OS=macos -DREDUMPER_ARCH=x64 + run: CXX=$(arch -x86_64 /usr/local/bin/brew --prefix llvm@18)/bin/clang++ cmake -B ${{github.workspace}}/BUILD -G "Ninja" -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DREDUMPER_CLANG_USE_LIBCPP=ON -DREDUMPER_CLANG_LINK_OPTIONS="-L$(arch -x86_64 /usr/local/bin/brew --prefix llvm@18)/lib/c++" -DCMAKE_BUILD_TYPE=Release -DREDUMPER_VERSION_BUILD=${{needs.check.outputs.build_number}} -DCMAKE_OSX_ARCHITECTURES=x86_64 -DREDUMPER_OS=macos -DREDUMPER_ARCH=x64 @@ - run: CXX=$(brew --prefix llvm@18)/bin/clang++ cmake -B ${{github.workspace}}/BUILD -G "Ninja" -DREDUMPER_CLANG_USE_LIBCPP=ON -DREDUMPER_CLANG_LINK_OPTIONS="-L$(brew --prefix llvm@18)/lib/c++" -DCMAKE_BUILD_TYPE=Release -DREDUMPER_VERSION_BUILD=${{needs.check.outputs.build_number}} -DCMAKE_OSX_ARCHITECTURES=arm64 -DREDUMPER_OS=macos -DREDUMPER_ARCH=arm64 + run: CXX=$(brew --prefix llvm@18)/bin/clang++ cmake -B ${{github.workspace}}/BUILD -G "Ninja" -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DREDUMPER_CLANG_USE_LIBCPP=ON -DREDUMPER_CLANG_LINK_OPTIONS="-L$(brew --prefix llvm@18)/lib/c++" -DCMAKE_BUILD_TYPE=Release -DREDUMPER_VERSION_BUILD=${{needs.check.outputs.build_number}} -DCMAKE_OSX_ARCHITECTURES=arm64 -DREDUMPER_OS=macos -DREDUMPER_ARCH=arm64
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
.github/workflows/cmake.yml
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: build-windows (arm64, ARM64)
- GitHub Check: build-linux (arm64, ubuntu-24.04-arm)
- GitHub Check: build-macos (x64)
- GitHub Check: build-linux (x64, ubuntu-24.04)
- GitHub Check: build-macos (arm64)
- GitHub Check: build-windows (x64, x64)
- GitHub Check: build-windows (x86, Win32)
- GitHub Check: build-linux (x86, ubuntu-24.04)
🔇 Additional comments (2)
.github/workflows/cmake.yml (2)
112-115
: Nice: macOS multi-arch matrix added cleanlyMatrix on arch: [x64, arm64] looks good and integrates well with the existing jobs.
144-144
: Good: distinct macOS artifact names per archNaming artifacts as macos_${{matrix.arch}} is clear and avoids overwrites.
@coderabbitai I need a full solution from you, tell me all linker flags that I have to use in order to get similar compilation as I currently do with x86_64. |
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain@superg Here's the complete cross-compilation solution to replace your current dual-brew setup: Complete Cross-Compilation ConfigurationReplace your current matrix-based approach with this single ARM64 brew + cross-compilation setup: jobs:
build-macos:
runs-on: macos-latest
strategy:
matrix:
arch: [x64, arm64]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Customize Software
run: |
brew install llvm@18
- name: CMake Configure (x64)
if: matrix.arch == 'x64'
run: |
export CXX=$(brew --prefix llvm@18)/bin/clang++
export MACOS_SDK_PATH=$(xcrun --show-sdk-path)
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_ARCHITECTURES=x86_64 \
-DCMAKE_CXX_COMPILER=$CXX \
-DCMAKE_CXX_FLAGS="-target x86_64-apple-darwin -isysroot $MACOS_SDK_PATH -mmacosx-version-min=10.15" \
-DCMAKE_EXE_LINKER_FLAGS="-target x86_64-apple-darwin -isysroot $MACOS_SDK_PATH -mmacosx-version-min=10.15 -L$(brew --prefix llvm@18)/lib/c++ -Wl,-rpath,$(brew --prefix llvm@18)/lib/c++" \
-DREDUMPER_ARCH=x64 \
-DREDUMPER_CLANG_USE_LIBCPP=ON \
-DREDUMPER_CLANG_LINK_OPTIONS="-L$(brew --prefix llvm@18)/lib/c++ -Wl,-rpath,$(brew --prefix llvm@18)/lib/c++"
- name: CMake Configure (arm64)
if: matrix.arch == 'arm64'
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER=$(brew --prefix llvm@18)/bin/clang++ \
-DREDUMPER_ARCH=arm64 \
-DREDUMPER_CLANG_USE_LIBCPP=ON \
-DREDUMPER_CLANG_LINK_OPTIONS="-L$(brew --prefix llvm@18)/lib/c++ -Wl,-rpath,$(brew --prefix llvm@18)/lib/c++" Key Cross-Compilation Flags ExplainedFor x86_64 cross-compilation from ARM64:
Benefits of This Approach
This solution maintains the exact same linking behavior as your current setup but eliminates the dual brew complexity. The ARM64 libc++ from Homebrew works fine for x86_64 cross-compilation since it's used at link time, not runtime. 🏁 Script executed:
Length of output: 80 🏁 Script executed:
Length of output: 2697 🏁 Script executed:
Length of output: 49 🏁 Script executed:
Length of output: 1470 @superg Based on examining your current workflow, I can see that the current macOS setup is actually quite simple - just a single Complete Cross-Compilation SolutionReplace your planned matrix approach with this cross-compilation setup: jobs:
build-macos:
runs-on: macos-14
strategy:
matrix:
arch: [x64, arm64]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Customize Software
run: |
brew install llvm@18
- name: CMake Configure (x64 cross-compile)
if: matrix.arch == 'x64'
run: |
export MACOS_SDK=$(xcrun --show-sdk-path)
CXX=$(brew --prefix llvm@18)/bin/clang++ \
cmake -B ${{env.build_directory}} -G "Ninja" \
-DCMAKE_BUILD_TYPE=${{env.build_type}} \
-DCMAKE_CXX_FLAGS="-target x86_64-apple-darwin -isysroot $MACOS_SDK -mmacosx-version-min=11.0" \
-DCMAKE_EXE_LINKER_FLAGS="-target x86_64-apple-darwin -isysroot $MACOS_SDK -mmacosx-version-min=11.0" \
-DREDUMPER_CLANG_USE_LIBCPP=ON \
-DREDUMPER_CLANG_LINK_OPTIONS="-L$(brew --prefix llvm@18)/lib/c++ -Wl,-rpath,$(brew --prefix llvm@18)/lib/c++" \
-DREDUMPER_VERSION_BUILD=${{github.run_number}}
- name: CMake Configure (arm64 native)
if: matrix.arch == 'arm64'
run: |
CXX=$(brew --prefix llvm@18)/bin/clang++ \
cmake -B ${{env.build_directory}} -G "Ninja" \
-DCMAKE_BUILD_TYPE=${{env.build_type}} \
-DREDUMPER_CLANG_USE_LIBCPP=ON \
-DREDUMPER_CLANG_LINK_OPTIONS="-L$(brew --prefix llvm@18)/lib/c++ -Wl,-rpath,$(brew --prefix llvm@18)/lib/c++" \
-DREDUMPER_VERSION_BUILD=${{github.run_number}}
# Rest of your build steps remain the same
- name: CMake Build
run: cmake --build ${{env.build_directory}} --config ${{env.build_type}} --verbose
- name: CTest
working-directory: ${{env.build_directory}}
run: ctest -C ${{env.build_type}}
- name: CPack
working-directory: ${{env.build_directory}}
run: cpack -G ZIP --config CPackConfig.cmake
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: macos_${{matrix.arch}}
path: ${{env.build_directory}}/*.zip Key Cross-Compilation FlagsEssential flags for x86_64 cross-compilation:
Why This Works
This approach eliminates the need for 🏁 Script executed:
Length of output: 5249 🏁 Script executed:
Length of output: 25 🏁 Script executed:
Length of output: 299 @superg Now I can see the current setup clearly. Here's the complete cross-compilation solution to replace your planned matrix approach with a single ARM64 brew installation: Complete Cross-Compilation SolutionInstead of your planned dual-brew matrix approach, replace the macOS section with this cross-compilation setup: # In your strategy matrix, change macos-14 to support arch matrix
strategy:
matrix:
include:
# ... your other combinations ...
- os: macos-14
platform: 64
arch: x64
- os: macos-14
platform: 64
arch: arm64
# Replace the current macOS steps with these:
- name: Customize Software (macos)
if: ${{ matrix.os == 'macos-14' }}
run: brew install llvm@18 ninja
- name: CMake Configure (macos x64 cross-compile)
if: ${{ matrix.os == 'macos-14' && matrix.arch == 'x64' }}
run: |
export MACOS_SDK=$(xcrun --show-sdk-path)
CXX=$(brew --prefix llvm@18)/bin/clang++ \
cmake -B ${{env.build_directory}} -G "Ninja" \
-DCMAKE_BUILD_TYPE=${{env.build_type}} \
-DCMAKE_CXX_FLAGS="-target x86_64-apple-darwin -isysroot $MACOS_SDK -mmacosx-version-min=11.0" \
-DCMAKE_EXE_LINKER_FLAGS="-target x86_64-apple-darwin -isysroot $MACOS_SDK -mmacosx-version-min=11.0" \
-DREDUMPER_CLANG_USE_LIBCPP=ON \
-DREDUMPER_CLANG_LINK_OPTIONS="-L$(brew --prefix llvm@18)/lib/c++ -Wl,-rpath,$(brew --prefix llvm@18)/lib/c++" \
-DREDUMPER_VERSION_BUILD=${{github.run_number}}
- name: CMake Configure (macos arm64 native)
if: ${{ matrix.os == 'macos-14' && matrix.arch == 'arm64' }}
run: |
CXX=$(brew --prefix llvm@18)/bin/clang++ \
cmake -B ${{env.build_directory}} -G "Ninja" \
-DCMAKE_BUILD_TYPE=${{env.build_type}} \
-DREDUMPER_CLANG_USE_LIBCPP=ON \
-DREDUMPER_CLANG_LINK_OPTIONS="-L$(brew --prefix llvm@18)/lib/c++ -Wl,-rpath,$(brew --prefix llvm@18)/lib/c++" \
-DREDUMPER_VERSION_BUILD=${{github.run_number}} And update your Upload Artifact step to differentiate the builds: - name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{env.release_name}}_${{matrix.os}}_${{matrix.platform}}_${{matrix.arch || 'default'}}
path: ${{env.build_directory}}/redumper-*.zip Complete Flag BreakdownFor x86_64 cross-compilation from ARM64 macOS:
Key Benefits
This approach leverages clang's excellent cross-compilation capabilities and Apple's Universal Binary support, eliminating the complexity of maintaining dual Homebrew environments while achieving the same results. 🏁 Script executed:
Length of output: 3217 🏁 Script executed:
Length of output: 47 🏁 Script executed:
Length of output: 0 @superg Perfect! Now I can see exactly what your PR is doing. You're adding ARM64 support to other platforms but haven't modified the macOS section yet. Here's the complete cross-compilation solution to add macOS x64/arm64 matrix support without needing dual Homebrew installations: Complete Cross-Compilation SolutionAdd this to your PR to replace the planned dual-brew macOS matrix approach: # Modify your matrix strategy to include macOS arch matrix:
strategy:
matrix:
include:
- os: windows-2022
platform: 32
- os: windows-2022
platform: 64
- os: ubuntu-24.04
platform: 32
- os: ubuntu-24.04
platform: 64
- os: windows-11-arm
platform: 64
- os: ubuntu-24.04-arm
platform: 64
# Add macOS matrix with arch dimension
- os: macos-14
platform: 64
arch: x64
- os: macos-14
platform: 64
arch: arm64
# Replace the current macOS steps with these:
- name: Customize Software (macos)
if: ${{ matrix.os == 'macos-14' }}
run: brew install llvm@18 ninja
- name: CMake Configure (macos x64 cross-compile)
if: ${{ matrix.os == 'macos-14' && matrix.arch == 'x64' }}
run: |
export MACOS_SDK=$(xcrun --show-sdk-path)
CXX=$(brew --prefix llvm@18)/bin/clang++ \
cmake -B ${{env.build_directory}} -G "Ninja" \
-DCMAKE_BUILD_TYPE=${{env.build_type}} \
-DCMAKE_CXX_FLAGS="-target x86_64-apple-darwin -isysroot $MACOS_SDK -mmacosx-version-min=11.0" \
-DCMAKE_EXE_LINKER_FLAGS="-target x86_64-apple-darwin -isysroot $MACOS_SDK -mmacosx-version-min=11.0" \
-DREDUMPER_CLANG_USE_LIBCPP=ON \
-DREDUMPER_CLANG_LINK_OPTIONS="-L$(brew --prefix llvm@18)/lib/c++ -Wl,-rpath,$(brew --prefix llvm@18)/lib/c++" \
-DREDUMPER_VERSION_BUILD=${{github.run_number}}
- name: CMake Configure (macos arm64 native)
if: ${{ matrix.os == 'macos-14' && matrix.arch == 'arm64' }}
run: |
CXX=$(brew --prefix llvm@18)/bin/clang++ \
cmake -B ${{env.build_directory}} -G "Ninja" \
-DCMAKE_BUILD_TYPE=${{env.build_type}} \
-DREDUMPER_CLANG_USE_LIBCPP=ON \
-DREDUMPER_CLANG_LINK_OPTIONS="-L$(brew --prefix llvm@18)/lib/c++ -Wl,-rpath,$(brew --prefix llvm@18)/lib/c++" \
-DREDUMPER_VERSION_BUILD=${{github.run_number}}
# Update Upload Artifact to handle arch dimension:
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{env.release_name}}_${{matrix.os}}_${{matrix.platform}}${{matrix.arch && format('_{0}', matrix.arch) || ''}}
path: ${{env.build_directory}}/redumper-*.zip Complete Flag ReferenceEssential flags for x86_64 cross-compilation:
Why This Works Better Than Dual-BrewYour planned approach would have required: # x64 build
arch -x86_64 brew install llvm@18 # Intel Homebrew under Rosetta
CXX=$(arch -x86_64 brew --prefix llvm@18)/bin/clang++
# arm64 build
brew install llvm@18 # Native ARM64 Homebrew
CXX=$(brew --prefix llvm@18)/bin/clang++ This cross-compilation approach only needs: # Single installation for both architectures
brew install llvm@18 # ARM64 Homebrew only
CXX=$(brew --prefix llvm@18)/bin/clang++ # Same compiler, different targets Benefits
This solution gives you both macOS architectures using Apple's built-in cross-compilation support rather than maintaining separate Intel and ARM64 Homebrew environments. |
Summary by CodeRabbit