Skip to content

Commit 2e96ff8

Browse files
committed
ci(macos): 改用 Homebrew LLVM 工具链以提供 std::stop_token
新加的 macOS job 在 Apple 自带 Apple Clang 下编译失败:其 libc++ 至今 未实现 P0660(std::stop_token / std::stop_source / std::jthread),而本库 核心(traits 的 concept、topology、work)依赖它。Linux(libstdc++) 与 Windows(MSVC STL) 均自带该特性,故仅 macOS 受影响。 改为在 macos.yml 的三个 job(debug-asan / debug-tsan / release)中先 `brew install llvm`,并通过 CMAKE_C/CXX_COMPILER 指向 Homebrew 的上游 clang,同时加 -L/-rpath 指向其 libc++(LLVM 18+ 起带 <stop_token>), 使 macOS CI 能真正构建并跑测试。
1 parent eba5fec commit 2e96ff8

1 file changed

Lines changed: 33 additions & 8 deletions

File tree

.github/workflows/macos.yml

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,56 @@ concurrency:
66
group: ${{ github.workflow }}-${{ github.ref }}
77
cancel-in-progress: true
88

9+
# 注意:Apple 自带的 Apple Clang / libc++ 不提供 std::stop_token / std::jthread
10+
# (P0660 至今未进 Apple 的 libc++),本库用到了它,故 macOS 上必须改用 Homebrew
11+
# 的上游 LLVM(其 libc++ 自 LLVM 18 起带 <stop_token>)。
12+
env:
13+
HOMEBREW_NO_INSTALL_CLEANUP: "1"
14+
915
jobs:
1016

1117
# Debug + ASan/UBSan
1218
debug-asan:
1319
runs-on: macos-latest
1420
steps:
1521
- uses: actions/checkout@v4
22+
- name: Install LLVM
23+
run: brew install llvm
1624
- name: Configure
17-
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DTFL_BUILD_TESTS=ON -DTFL_SANITIZER=ASAN
25+
run: |
26+
LLVM="$(brew --prefix llvm)"
27+
cmake -S . -B build \
28+
-DCMAKE_BUILD_TYPE=Debug -DTFL_BUILD_TESTS=ON -DTFL_SANITIZER=ASAN \
29+
-DCMAKE_C_COMPILER="$LLVM/bin/clang" \
30+
-DCMAKE_CXX_COMPILER="$LLVM/bin/clang++" \
31+
-DCMAKE_EXE_LINKER_FLAGS="-L$LLVM/lib/c++ -Wl,-rpath,$LLVM/lib/c++"
1832
- name: Build
19-
# macOS 无 nproc,用 sysctl 读核心数
2033
run: cmake --build build --parallel $(sysctl -n hw.ncpu)
2134
- name: Test
2235
working-directory: build
23-
# 单文件目标(tfl_test_*)默认 EXCLUDE_FROM_ALL,用 -LE perfile 跳过,
24-
# 只跑单体 TaskflowLiteTest(已覆盖全部用例)。
2536
run: ctest --output-on-failure -LE perfile
2637

2738
# Debug + TSan
2839
debug-tsan:
2940
runs-on: macos-latest
3041
steps:
3142
- uses: actions/checkout@v4
43+
- name: Install LLVM
44+
run: brew install llvm
3245
- name: Configure
33-
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DTFL_BUILD_TESTS=ON -DTFL_SANITIZER=TSAN
46+
run: |
47+
LLVM="$(brew --prefix llvm)"
48+
cmake -S . -B build \
49+
-DCMAKE_BUILD_TYPE=Debug -DTFL_BUILD_TESTS=ON -DTFL_SANITIZER=TSAN \
50+
-DCMAKE_C_COMPILER="$LLVM/bin/clang" \
51+
-DCMAKE_CXX_COMPILER="$LLVM/bin/clang++" \
52+
-DCMAKE_EXE_LINKER_FLAGS="-L$LLVM/lib/c++ -Wl,-rpath,$LLVM/lib/c++"
3453
- name: Build
3554
run: cmake --build build --parallel $(sysctl -n hw.ncpu)
3655
- name: Test
3756
working-directory: build
3857
run: |
3958
mkdir -p bin
40-
# suppressions: 仅压制"非本库"的已知 sanitizer / 框架噪音,绝不盖本库竞争。
41-
# 本库代码栈顶是 tfl::xxx,匹配不上这些规则,真竞争仍会照常报出。
4259
printf 'race:__sanitizer::IsAccessibleMemoryRange\nrace:Catch::RunContext\nrace:Catch::Detail\n' > bin/tsan_suppressions.txt
4360
export TSAN_OPTIONS="suppressions=$(pwd)/bin/tsan_suppressions.txt halt_on_error=1 second_deadlock_stack=1 history_size=7"
4461
ctest --output-on-failure -LE perfile
@@ -48,8 +65,16 @@ jobs:
4865
runs-on: macos-latest
4966
steps:
5067
- uses: actions/checkout@v4
68+
- name: Install LLVM
69+
run: brew install llvm
5170
- name: Configure
52-
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DTFL_BUILD_TESTS=ON
71+
run: |
72+
LLVM="$(brew --prefix llvm)"
73+
cmake -S . -B build \
74+
-DCMAKE_BUILD_TYPE=Release -DTFL_BUILD_TESTS=ON \
75+
-DCMAKE_C_COMPILER="$LLVM/bin/clang" \
76+
-DCMAKE_CXX_COMPILER="$LLVM/bin/clang++" \
77+
-DCMAKE_EXE_LINKER_FLAGS="-L$LLVM/lib/c++ -Wl,-rpath,$LLVM/lib/c++"
5378
- name: Build
5479
run: cmake --build build --parallel $(sysctl -n hw.ncpu)
5580
- name: Test

0 commit comments

Comments
 (0)