Skip to content

Commit 8963c6f

Browse files
authored
fix(mysql-connector-cpp): state the C++ standard library as a layer requirement (#399)
* fix(mysql-connector-cpp): state the C++ standard library as a layer requirement The install hook cannot see the consumer's standard library: mcpp resolves the toolchain after the dependency graph, so none exists when a dependency installs (mcpp-community/mcpp#613). The descriptor now declares requires = { "mcpp:c++-abi=libstdc++" }, so a libc++ consumer is refused at resolution naming both implementations instead of failing at link. The llvm-leg skip stays with its reason updated. * fix(mysql-connector-cpp): the standard library requirement follows each platform's system compiler The macOS default leg refused the member: install() builds with Apple clang there, so the static libraries are libc++ and the default toolchain's libc++ is the matching one. The requirement moves into the per-platform tables: libstdc++ under linux, libc++ under macosx. Measured locally: a linux-scoped requirement is refused under llvm naming both implementations and satisfied by gcc; mcpp xpkg parse --all-os accepts both sections.
1 parent 194b3c6 commit 8963c6f

2 files changed

Lines changed: 38 additions & 25 deletions

File tree

.github/workflows/validate.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,13 +1206,18 @@ jobs:
12061206
# ld.lld: error: undefined symbol:
12071207
# std::__cxx11::basic_string<...>::_M_create(...)
12081208
#
1209-
# Its install hook cannot adapt, because nothing tells it what the
1210-
# consumer chose: MCPP_CXX_STDLIB is exported only when mcpp runs a
1211-
# BUILD PROGRAM (`src/build/build_program.cppm`), `make_xlings_env`
1212-
# carries `{binary, home, projectDir}` and no toolchain, and a probe
1213-
# in the hook measured `MCPP_CXX_STDLIB=nil` on this very leg (#392).
1214-
# mcpp-community/mcpp#613; when the hook can see the consumer's stdlib,
1215-
# this entry comes out and the descriptor does the work instead.
1209+
# Its install hook cannot adapt: mcpp resolves the toolchain after the
1210+
# dependency graph, so the consumer's standard library does not exist
1211+
# yet when the hook runs, and MCPP_CXX_STDLIB is nil (older mcpp) or
1212+
# empty (2026.9.12.2 and later) there (#392; mcpp-community/mcpp#613,
1213+
# measured by its tests/e2e/648). The descriptor states the
1214+
# requirement instead, `requires = { "mcpp:c++-abi=libstdc++" }` in its
1215+
# `linux` table, and a libc++ consumer is refused at resolution naming
1216+
# both implementations. (On macOS the libraries are built with Apple
1217+
# clang, and the `macosx` table requires libc++, which the default
1218+
# toolchain there resolves.)
1219+
# That refusal follows the hook's source build, so the member stays off
1220+
# this leg: the leg would spend the build to reach a known refusal.
12161221
#
12171222
# SKIPPED, NOT MARKED GREEN: the incompatibility is real for users on
12181223
# a libc++ toolchain. This stops CI from re-measuring a known answer

pkgs/c/compat.mysql-connector-cpp.lua

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,22 @@ package = {
5151
["compat.openssl"] = "3.5.1",
5252
},
5353

54+
-- THE STANDARD LIBRARY THE STATIC LIBRARIES WERE COMPILED AGAINST, per
55+
-- platform, because install() uses each platform's system compiler:
56+
-- g++ with libstdc++ on Linux, Apple clang with libc++ on macOS. A
57+
-- consumer whose toolchain resolves the other one is refused at
58+
-- resolution, naming both, instead of failing at link. An mcpp older
59+
-- than the layer grammar reports the key as unknown and proceeds as
60+
-- before.
5461
linux = {
62+
requires = { "mcpp:c++-abi=libstdc++" },
5563
ldflags = {
5664
"-Llib", "-l:libmysqlcppconnx-static.a",
5765
"-l:libmysqlcppconn-static.a", "-lresolv",
5866
},
5967
},
6068
macosx = {
69+
requires = { "mcpp:c++-abi=libc++" },
6170
ldflags = {
6271
"-Llib", "-lmysqlcppconnx-static",
6372
"-lmysqlcppconn-static", "-lresolv",
@@ -267,8 +276,8 @@ function install()
267276

268277
-- THE STANDARD LIBRARY THIS IS BUILT AGAINST HAS TO MATCH THE CONSUMER'S.
269278
--
270-
-- CMake picks the system compiler below, so the static libs come out
271-
-- against libstdc++ whatever the consumer uses. On the llvm leg, which
279+
-- CMake picks the system compiler below, so on Linux the static libs come
280+
-- out against libstdc++ whatever the consumer uses. On the llvm leg, which
272281
-- links libc++, the member then fails at link with the libstdc++ half of
273282
-- its own dependency undefined:
274283
--
@@ -282,13 +291,12 @@ function install()
282291
-- 1. MEASURED. The probe below logged `MCPP_CXX_STDLIB=nil` on the llvm
283292
-- leg (mcpplibs/mcpp-index#392, `workspace (linux llvm 0/4)`), and
284293
-- the link failed exactly as before.
285-
-- 2. THE ONLY SETTER is `src/build/build_program.cppm` (`e.emplace_back
286-
-- ("MCPP_CXX_STDLIB", env.cxxStdlib)`) -- mcpp exports it when it runs
287-
-- a BUILD PROGRAM. An xlings install hook is not that.
288-
-- 3. THE CALL CARRIES NOTHING ELSE either: `make_xlings_env` builds an
289-
-- `xlings::Env` of `{binary, home, projectDir}`, and
290-
-- `install_packages` is invoked with `XLINGS_HOME` and PATH. No
291-
-- toolchain, no compiler, no stdlib crosses that boundary.
294+
-- 2. BY CONSTRUCTION, NOT BY OMISSION. mcpp 2026.9.12.2 emits
295+
-- MCPP_CXX_STDLIB to a dependency's install hook, and it is empty
296+
-- there: mcpp resolves the toolchain after the dependency graph,
297+
-- because a package in the graph may supply a target-side layer, so no
298+
-- standard library exists yet when this hook runs
299+
-- (mcpp-community/mcpp#613, measured by its tests/e2e/648).
292300
--
293301
-- So neither route is reachable from HERE. `llamacpp` refuses a libc++
294302
-- toolchain by name with `mcpp::cxx_stdlib()`, but that lives in its
@@ -300,17 +308,17 @@ function install()
300308
-- before the linker says it: these are STATIC libraries built by CMake
301309
-- with the system compiler, so `std::__cxx11::` and friends cross the
302310
-- boundary into the consumer. Consuming them from a libc++ toolchain does
303-
-- not work and cannot be made to work from inside this hook. Tracked as
304-
-- mcpp-community/mcpp#613 (install hooks need the consumer's stdlib);
305-
-- until then
306-
-- `validate.yml` keeps this member off the llvm leg, with the same reason
307-
-- written there.
311+
-- not work and cannot be made to work from inside this hook. The
312+
-- descriptor states it instead (`requires` in the per-platform tables of
313+
-- the mcpp segment above), and
314+
-- `validate.yml` keeps this member off the llvm leg, because the refusal
315+
-- follows this hook's source build and the leg would spend the build to
316+
-- reach an answer it already knows.
308317
--
309-
-- The probe stays. It costs one log line, it is the evidence for point 1,
310-
-- and the day mcpp does pass the variable through, this line reports it
311-
-- and the fix becomes a three-line change directly below.
318+
-- The probe stays. It costs one log line and is the evidence for points 1
319+
-- and 2: nil from an mcpp older than 2026.9.12.2, empty from a newer one.
312320
hook_log("MCPP_CXX_STDLIB=" .. tostring(os.getenv("MCPP_CXX_STDLIB"))
313-
.. " (expected nil; see the comment above)")
321+
.. " (expected nil or empty; see the comment above)")
314322
if os.host() == "macosx" then
315323
-- Connector 在 project() 前启动 bootstrap CMake;必须通过环境变量
316324
-- 将最低系统版本同步给 bootstrap 及其后续的内置依赖构建。

0 commit comments

Comments
 (0)