Repository navigation
pkg-config: stop forcing a language mode in Cflags (issue #13) - #16
Merged
Merged
Conversation
…t as a variable Issue #13: `Cflags` named `-std=c++17`, and this file has no business doing that. Two consequences, both measured on this machine (Win64, MinGW GCC 16.1.0, pkgconf 3.0.11, install prefix .tmp/pkg-prefix): * pkg-config has no per-language flag channel, so the flag reached a C compiler too -- and this package serves a C header (`ext/c_api.h`). Compiled as C with `pkg-config --cflags` as the only flags, clang rejects the option outright ("error: invalid argument '-std=c++17' not allowed with 'C'") while gcc only warns ("command-line option '-std=c++17' is valid for C++/ObjC++ but not for C"). A C consumer's build therefore depended on which compiler it used -- and this repository's own manylinux step 10 is exactly such a consumer: it compiles c_api.h with gcc and would have gone red under clang. * pkg-config cannot express "at least 17": a consumer that put its own `-std=c++20` FIRST and the package's flags second was dropped back to 17, because the last option on a command line wins. Reproduced with a TU that asserts `#if __cplusplus < 202002L`: it passes after this change and fails with the old `-std=c++17` appended. The requirement did not disappear with the flag. cpp-pinyin2.pc now exports `cxx_std=-std=c++17`, which `pkg-config --variable=cxx_std cpp-pinyin2` answers with and which nothing applies unless the consumer copies it onto its own command line; README's consumer section and the RELEASE_RUNBOOK's step 4.2b say where to find it. The CMake target is untouched: `cxx_std_17` already means "at least", which is what the headers need. `-DCPP_PINYIN2_STATIC` STAYS in Cflags. It is a PUBLIC compile definition (it selects the no-dllimport branch of PinyinGlobal.h), so a pkg-config consumer of a static install that does not get it compiles against the wrong branch -- a different kind of fact from a language mode, and one pkg-config can express correctly. The install-consumer gate is INVERTED rather than deleted: it fails if `Cflags` names any standard mode and fails if `cxx_std` is missing. It was shown able to fail -- doctoring the generated .pc back to `Cflags: -I${includedir} -std=c++17` makes it exit 1 with "Cflags names a language standard mode". Measured: `pkg-config --cflags` -> -I.../include, no -std=; `--variable=cxx_std` -> -std=c++17; `--variable=dictdir` -> .../share/cpp-pinyin2/dict; `ctest -R InstallConsumerSmoke` -> 3/3 passed; `tools/run_all_gates.py` -> 17 build-free gates pass (5 need a build tree); `tools/check_doc_claims.py --ctest-inventory` -> "every recognised claim matches what the tree measures". The public headers also compile clean in C++20 (`g++ -std=c++20 -fsyntax-only` on core/Engine.h). docs/RELEASE_CHECKLIST.md's pkg-config row keeps its 2026-10-21 reading and gains dated corrections instead of a rewrite: the Windows leg no longer excludes InstallConsumerSmoke (withdrawn 2026-10-27, c3a728c), and the static-consumer face is no longer a gap (Libs.private landed 746a67e, measured by step 10).
…tic leg's first run
Two CI-side follow-ups, one per workflow:
* ci_manylinux_aarch64.sh step 10 asserted only the LINK exit code, so a failing compile still read as a
link verdict. It now asserts the C compile too, and compiles the two shapes issue #13 describes: a C++ TU
that asks for C++20 first and takes the package's flags second (asserting `#if __cplusplus < 202002L`), and
the same C consumer under clang when the image has one -- clang errors on a C++ standard option in C mode
while gcc only warns, so the gcc compile that was already there could not see that case. clang absent
prints NOT MEASURED and is not a failure: the same distinction the ninja probe in that file draws.
* ci.yml's macOS static leg comment said no run had confirmed it. Run 44859037261 (push of 9938d3d) ran it:
step 10 of the `macos` job is green there, as it is in #15's own run 44858155866 -- which is also the
first independent confirmation that #14 fixed Apple's archive step, because this build reaches that step
and passes no `D`.
Verified here: `python -B tools/check_parsable.py --require` -> exit 0 (bash -n over both tracked scripts,
yaml.safe_load over the five workflows). NOT verified: the container step itself, which only runs inside
manylinux.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13. Scope: this branch touches no source file, no dictionary, and nothing from the vcpkg port other
than what #14 already upstreamed --
vcpkg-dict-layout.patchis deliberately untouched.The problem.
Cflagsnamed-std=c++17. pkg-config has no per-language flag channel and cannot express"at least 17", so that one flag did two measurably bad things (compiled as C with
pkg-config --cflagsas theonly flags, on Win64 with MinGW GCC 16.1.0 + pkgconf 3.0.11):
ext/c_api.h) built by clangerror: invalid argument '-std=c++17' not allowed with 'C''-std=c++17' is valid for C++/ObjC++ but not for C-std=c++20comes firstThe change.
Cflags: -I${includedir}@CPP_PINYIN2_PC_EXTRA_CFLAGS@. The requirement moves to acxx_stdvariable (
pkg-config --variable=cxx_std cpp-pinyin2->-std=c++17), which nothing applies unless theconsumer copies it.
-DCPP_PINYIN2_STATICstays: it is a PUBLIC compile definition, not a language mode. TheCMake target is untouched --
cxx_std_17already means "at least", which is what the headers need.The gate.
check_install_consumer.cmakeasserted the flag was PRESENT; it now asserts that noCflagsentry names a standard mode and that
cxx_stdis exported. It was shown able to fail: doctoring the generated.pcback toCflags: ... -std=c++17makes it exit 1 with "Cflags names a language standard mode".Measured here: the table above;
pkg-config --cflagsprints no-std=;--variable=cxx_std->-std=c++17;--variable=dictdir-> the installed dictionary root;ctest -R InstallConsumerSmoke3/3;tools/run_all_gates.py17 build-free gates pass;tools/check_doc_claims.py --ctest-inventoryclean; thepublic headers also compile clean in C++20.
Not measurable here: the manylinux step-10 additions (compile exit code, C++20 non-downgrade probe, clang C
consumer) run only inside the container, so this PR's CI is their first execution. Docs: README gained a
pkg-config consumer section, RELEASE_RUNBOOK 4.2/4.2b gained the two criteria, and RELEASE_CHECKLIST's
pkg-config row got dated corrections rather than a rewrite.