Skip to content

Commit b28e319

Browse files
committed
Fix macOS LLVM toolchain setup
1 parent 10a82ea commit b28e319

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

.github/workflows/build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ jobs:
148148
sudo apt-get update
149149
sudo apt-get install -y liblzma-dev
150150
151-
- name: Install liblzma (macOS)
151+
- name: Install macOS dependencies
152152
if: ${{ runner.os == 'macOS' && steps.ccache-cache.outputs.cache-hit != 'true' }}
153-
run: brew install xz
153+
run: brew install llvm@18 xz
154154

155155
- name: Install liblzma (Windows)
156156
if: ${{ matrix.os == 'windows-latest' && steps.ccache-cache.outputs.cache-hit != 'true' }}
@@ -159,7 +159,7 @@ jobs:
159159
- name: Set LLVM_ROOT (macOS)
160160
if: ${{ runner.os == 'macOS' && steps.ccache-cache.outputs.cache-hit != 'true' }}
161161
shell: bash
162-
run: echo "LLVM_ROOT_PARAM=-DLLVM_ROOT=$(brew --prefix llvm)" >> "$GITHUB_ENV"
162+
run: echo "LLVM_ROOT_PARAM=-DLLVM_ROOT=$(brew --prefix llvm@18)" >> "$GITHUB_ENV"
163163

164164
- name: Configure cmake
165165
if: steps.ccache-cache.outputs.cache-hit != 'true'
@@ -210,7 +210,7 @@ jobs:
210210
shell: bash
211211
run: |
212212
if [[ "$RUNNER_OS" == "macOS" ]]; then
213-
brew install ccache
213+
brew install ccache llvm@18
214214
else
215215
sudo apt-get update && sudo apt-get install -y ccache
216216
fi
@@ -503,10 +503,10 @@ jobs:
503503
sudo apt-get update
504504
sudo apt-get install -y liblzma-dev
505505
506-
- name: Install liblzma (MacOS)
506+
- name: Install macOS dependencies
507507
if: ${{ matrix.os == 'macos-latest' }}
508508
run: |
509-
brew install xz
509+
brew install llvm@18 xz
510510
511511
- name: Install liblzma (Windows)
512512
if: ${{ matrix.os == 'windows-latest' }}

CMakeLists.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,27 @@ endif ()
9797

9898
if (UNIX)
9999
if(APPLE)
100+
set(LLVM_HOMEBREW_FORMULA "llvm@18")
100101
if(DEFINED LLVM_ROOT)
101102
message(STATUS "Using provided LLVM_ROOT: ${LLVM_ROOT}")
102103
else()
103-
message(WARNING "LLVM_ROOT not provided via -DLLVM_ROOT. Falling back to Homebrew's llvm.")
104-
# Fallback to LLVM 15 install path from Homebrew
104+
message(WARNING "LLVM_ROOT not provided via -DLLVM_ROOT. Falling back to Homebrew's ${LLVM_HOMEBREW_FORMULA}.")
105105
execute_process(
106-
COMMAND brew --prefix llvm
106+
COMMAND brew --prefix ${LLVM_HOMEBREW_FORMULA}
107107
OUTPUT_VARIABLE LLVM_ROOT
108108
OUTPUT_STRIP_TRAILING_WHITESPACE
109109
)
110110

111-
if(NOT EXISTS "${LLVM_ROOT}/bin/clang++")
112-
message(FATAL_ERROR "Failed to locate llvm@15 via Homebrew. Please install it or provide LLVM_ROOT manually.")
113-
endif()
114-
115111
message(STATUS "Using fallback LLVM_ROOT: ${LLVM_ROOT}")
116112
endif()
117113

114+
if(NOT EXISTS "${LLVM_ROOT}/bin/clang" OR NOT EXISTS "${LLVM_ROOT}/bin/clang++")
115+
message(FATAL_ERROR
116+
"Failed to locate ${LLVM_HOMEBREW_FORMULA} compilers under LLVM_ROOT='${LLVM_ROOT}'. "
117+
"Install it with 'brew install ${LLVM_HOMEBREW_FORMULA}' or provide LLVM_ROOT manually."
118+
)
119+
endif()
120+
118121
add_compile_options(
119122
"$<$<CONFIG:Debug>:-gfull>"
120123
-Wno-nullability-completeness

0 commit comments

Comments
 (0)