@@ -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+
86131vcpkg_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
240285case " ${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 ;;
248294esac
0 commit comments