Skip to content

Commit 373e4b3

Browse files
committed
0.14.1: on Linux under a libc++ toolchain, deps-vcpkg and deps-cmake build with mcpp's clang, and each vcpkg triplet is its own installation
1 parent a0aad3b commit 373e4b3

9 files changed

Lines changed: 209 additions & 36 deletions

File tree

‎.agents/docs/2026-09-26-deps-vcpkg-rules-qt-plan.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,20 @@ GalTranslPP 在 0.13.1 上构建成功后仍有两个手动步骤(解压嵌入
8585

8686
实测:库包中的 `artifact` 输出经 `mcpp::deploy` 传播到依赖它的程序的 `bin/` 与 `mcpp pack` 目录;依赖包中无下游
8787
消费者的 `artifact` action 随下游构建执行。
88+
89+
## 7. 0.14.1:Linux 上依赖的 C++ 标准库与程序一致
90+
91+
Windows 上 MSVC ABI 的编译器共用 Microsoft 的标准库,macOS 上共用 libc++;Linux 上主机编译器使用
92+
libstdc++,mcpp 的 clang 使用 libc++,两者的 `std::` 符号互不链接。0.14.1 在 Linux 的 libc++ 工具链下:
93+
94+
| 交付 | 机制 |
95+
|---|---|
96+
| `deps-vcpkg` 生成的 triplet | 默认 triplet 为 `<arch>-linux-libcxx`,经 `VCPKG_CHAINLOAD_TOOLCHAIN_FILE` 以 mcpp 的 clang 编译端口,再接 vcpkg 自身的 Linux 工具链;clang 的配置文件给出 libc++ 与 mcpp 链接的 C 库 |
97+
| 每个 triplet 一个 vcpkg 安装 | vcpkg 的清单模式从安装中移除其余 triplet 的包;前缀改为 `<install root>/<triplet>/<triplet>`,两个工具链的前缀并存,切换不重装 |
98+
| `deps-cmake` | 未经 `cache_args` 指定编译器或工具链文件时,传入 mcpp 的 clang |
99+
100+
判据(Linux CI `vcpkg-libcxx`):llvm 下 `libfmt.a` 含 `std::__1::` 符号且程序运行;默认工具链构建后 libc++
101+
前缀仍在;切回 llvm 不重跑安装;deps-cmake 子项目的 `CMAKE_CXX_COMPILER` 为 mcpp 的 clang。
102+
103+
GalTranslPP 上游仅支持 Windows(README 所述,代码直接调用 WinAPI),Linux 的判据由本仓库的 fixture 承担;
104+
GalTranslPP PR2 作为 Windows 回归验证。

‎.github/scripts/check-deps-and-qt.sh‎

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ vcpkg_consumer() {
7272

7373
if is_windows; then
7474
# The pack collects it from the runtime search directory.
75-
ls target/vcpkg_installed/x64-windows/bin/fmt.dll > /dev/null || fail "x64-windows built no fmt.dll"
75+
ls target/vcpkg_installed/x64-windows/x64-windows/bin/fmt.dll > /dev/null || fail "x64-windows built no fmt.dll"
7676
run_directly vcpkg-consumer | tee target/ci/direct.log
7777
grep -qE '^vcpkg-consumer: fmt [0-9]+ says 42$' target/ci/direct.log ||
7878
fail "started from the build directory, the program did not find fmt.dll"
@@ -83,6 +83,51 @@ vcpkg_consumer() {
8383
fi
8484
}
8585

86+
# LINUX UNDER A libc++ TOOLCHAIN. The host compiler vcpkg and CMake find uses
87+
# libstdc++, whose `std::` symbols a libc++ program cannot link. The default
88+
# triplet is then the generated `x64-linux-libcxx`, whose ports build with
89+
# mcpp's clang; fmt's interface returns `std::string`, so the link itself is the
90+
# criterion. The prefix is then shown to survive the default toolchain's own
91+
# installation, which vcpkg would remove if the two triplets shared one.
92+
vcpkg_libcxx() {
93+
local llvm="${MCPP_LLVM:-llvm@22.1.8}" gen=x64-linux-libcxx
94+
[ "$(uname -m)" = aarch64 ] && gen=arm64-linux-libcxx
95+
cd "$ROOT/tests/vcpkg-consumer"
96+
rm -rf target vcpkg_installed
97+
mkdir -p target/ci
98+
"$MCPP" build --toolchain "$llvm" 2>&1 | tee target/ci/libcxx-build.log
99+
"$MCPP" run --toolchain "$llvm" | tee target/ci/libcxx-run.log
100+
grep -qE '^vcpkg-consumer: fmt [0-9]+ says 42$' target/ci/libcxx-run.log || fail "the libc++ program did not print through fmt"
101+
local lib; lib=$(find target/vcpkg_installed -path "*/$gen/$gen/lib/libfmt.a" | head -1)
102+
[ -n "$lib" ] || fail "no $gen prefix with libfmt.a"
103+
grep -q 'std::__1::' <(nm -C "$lib") || fail "$lib is not built against libc++"
104+
echo "ok: under $llvm the ports build with mcpp's clang and the program links them"
105+
106+
"$MCPP" build 2>&1 | tee target/ci/default-build.log
107+
"$MCPP" run | tee target/ci/default-run.log
108+
grep -qE '^vcpkg-consumer: fmt [0-9]+ says 42$' target/ci/default-run.log || fail "the default toolchain's program did not print through fmt"
109+
[ -f "$lib" ] || fail "the default toolchain's installation removed the $gen prefix"
110+
local stamp; stamp=$(find target -path '*deps-vcpkg*' -name "$gen.stamp" | head -1)
111+
[ -n "$stamp" ] || fail "no $gen installation stamp"
112+
touch -r "$stamp" target/ci/before-switch-back
113+
sleep 1
114+
"$MCPP" build --toolchain "$llvm" --profile dev > target/ci/switch-back.log 2>&1 ||
115+
{ cat target/ci/switch-back.log; fail "the build switched back to $llvm failed"; }
116+
[ -z "$(find "$stamp" -newer target/ci/before-switch-back)" ] ||
117+
fail "switching back to $llvm re-ran its installation"
118+
echo "ok: the two toolchains' prefixes coexist, and switching back installs nothing"
119+
120+
# deps-cmake takes the same compilers.
121+
cd "$ROOT/tests/cmake-consumer"
122+
rm -rf target
123+
mkdir -p target/ci
124+
"$MCPP" build --toolchain "$llvm" 2>&1 | tee target/ci/libcxx-build.log
125+
"$MCPP" run --toolchain "$llvm" | grep -q '^cmake-consumer: greet says 42$' || fail "the libc++ cmake-consumer did not run"
126+
grep -rqs 'CMAKE_CXX_COMPILER:[A-Z]*=.*xim-x-llvm.*/clang++' target --include=CMakeCache.txt ||
127+
fail "deps-cmake configured the subproject without mcpp's clang"
128+
echo "ok: deps-cmake configures the subproject with mcpp's clang under $llvm"
129+
}
130+
86131
vcpkg_workspace() {
87132
cd "$ROOT/tests/vcpkg-workspace"
88133
rm -rf target app-a/target app-b/target vcpkg_installed
@@ -239,10 +284,11 @@ qt_widgets_consumer() {
239284

240285
case "${1:-}" in
241286
vcpkg-consumer) vcpkg_consumer ;;
287+
vcpkg-libcxx) vcpkg_libcxx ;;
242288
archive-consumer) archive_consumer ;;
243289
vcpkg-workspace) vcpkg_workspace ;;
244290
cmake-consumer) cmake_consumer ;;
245291
qt-consumer) qt_consumer ;;
246292
qt-widgets-consumer) qt_widgets_consumer ;;
247-
*) echo "usage: $0 vcpkg-consumer|archive-consumer|vcpkg-workspace|cmake-consumer|qt-consumer|qt-widgets-consumer"; exit 2 ;;
293+
*) echo "usage: $0 vcpkg-consumer|vcpkg-libcxx|archive-consumer|vcpkg-workspace|cmake-consumer|qt-consumer|qt-widgets-consumer"; exit 2 ;;
248294
esac

‎.github/workflows/ci.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,6 +1650,13 @@ jobs:
16501650
- name: deps-vcpkg installs a manifest as an action, and planning installs nothing
16511651
run: bash .github/scripts/check-deps-and-qt.sh vcpkg-consumer
16521652

1653+
# Linux has two C++ standard libraries. Under a libc++ toolchain the
1654+
# ports build with mcpp's clang, and the two toolchains' prefixes coexist.
1655+
- name: deps-vcpkg and deps-cmake build with mcpp's clang under a libc++ toolchain
1656+
run: |
1657+
"$MCPP" toolchain install llvm 22.1.8
1658+
bash .github/scripts/check-deps-and-qt.sh vcpkg-libcxx
1659+
16531660
- name: deps-archive extracts a zip the project keeps and deploys its tree beside the program
16541661
run: bash .github/scripts/check-deps-and-qt.sh archive-consumer
16551662

0 commit comments

Comments
 (0)