Repository navigation
Report compile-only flags on CMake link lines as a warning - #43
Open
anakanemison wants to merge 1 commit into
Open
anakanemison wants to merge 1 commit into
anakanemison wants to merge 1 commit into
Conversation
CMake passes CMAKE_<LANG>_FLAGS to the link line as well as the compile line, so warning flags, -pedantic and -D/-U defines (including the -DNDEBUG of Release builds) appear in the File API's link flags. The driver ignores them when linking, and Bazel's link lines do not carry them, so each one was a link_flags_diff error that every migration had to suppress by hand in ignore.link_flags. Measured in any2bazel-lab: every converged migration of three small projects suppressed the same kinds of flag, each agent rediscovering and justifying them in its own words (-Wall -Wextra -Wformat-security -pedantic on one, -Wno-format-truncation on another, -DNDEBUG on a third). Agents also suppressed front-end flags by hand: -fexceptions on lensfun, -w and -fno-common on CMake's sources, -fvisibility=hidden on GDAL and QGIS. A hand suppression is also where a reviewer can wave a real difference through. _diff_link_flags now sends these missing CMake link flags to a new WARN kind, link_compile_only_flags, which does not block `converged`: - warnings and -Wp, preprocessor pass-throughs (-W..., but not -Wl, or -Wa,, the latter because an LTO link runs the assembler), -w and -pedantic*; - -D and -U; - front-end -f flags that steer only the compiler, listed one by one: -fexceptions, -fno-exceptions, -fcommon, -fno-common, -fvisibility-inlines-hidden and -fvisibility=. Everything else stays a link_flags_diff error. Most -f flags matter at link time, so the list is explicit rather than a prefix, and -fopenmp, -pthread, -static*, -fsanitize* and -flto* are not in it. When an -flto* flag is on either side of a link, warning controls and the front-end flags stay errors, because LTO runs code generation, and diagnostics such as -Werror=lto-type-mismatch, at link time. ignore.link_flags still silences any of them entirely. SKILL.md lists the new kind, and the front-end flags, with the other no-action WARNs. The upstream test that used -fvisibility=hidden as its example of a link error now uses -Wl,--no-undefined. A built-in list is a design choice the maintainers may prefer to own; this one is reported rather than dropped, so nothing disappears silently. Not done: raising an unreferenced <target>_EXPORTS define only when a source reads it, which would need the differ to read source files. In the lab's runs with this change, the first version of the list (without the front-end flags) still left agents suppressing -fexceptions on lensfun and -w and -fno-common on CMake. With the list above, neither project's next run suppressed a link flag by hand. Lab-Proposal: P11 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Part 8 of 23 of a stacked series (tracking issue: #35). Based on
U07-align-executables-by-basename, the previous part: review and merge that first.Kind: report. Lab proposal: P11.
What the migration runs showed
Every converged lensfun, jansson and pono migration suppressed the same compile flags by hand on link lines. After this change and its revision, neither lensfun (run 092) nor cmake (094) suppressed a link flag by hand.
The change
CMake passes CMAKE__FLAGS to the link line as well as the compile
line, so warning flags, -pedantic and -D/-U defines (including the -DNDEBUG
of Release builds) appear in the File API's link flags. The driver ignores
them when linking, and Bazel's link lines do not carry them, so each one was
a link_flags_diff error that every migration had to suppress by hand in
ignore.link_flags.
Measured in any2bazel-lab: every converged migration of three small
projects suppressed the same kinds of flag, each agent rediscovering and
justifying them in its own words (-Wall -Wextra -Wformat-security -pedantic
on one, -Wno-format-truncation on another, -DNDEBUG on a third). Agents also
suppressed front-end flags by hand: -fexceptions on lensfun, -w and
-fno-common on CMake's sources, -fvisibility=hidden on GDAL and QGIS. A hand
suppression is also where a reviewer can wave a real difference through.
_diff_link_flags now sends these missing CMake link flags to a new WARN
kind, link_compile_only_flags, which does not block
converged:-Wa,, the latter because an LTO link runs the assembler), -w and
-pedantic*;
-fexceptions, -fno-exceptions, -fcommon, -fno-common,
-fvisibility-inlines-hidden and -fvisibility=.
Everything else stays a link_flags_diff error. Most -f flags matter at link
time, so the list is explicit rather than a prefix, and -fopenmp, -pthread,
-static*, -fsanitize* and -flto* are not in it. When an -flto* flag is on
either side of a link, warning controls and the front-end flags stay errors,
because LTO runs code generation, and diagnostics such as
-Werror=lto-type-mismatch, at link time. ignore.link_flags still silences
any of them entirely. SKILL.md lists the new kind, and the front-end flags,
with the other no-action WARNs. The upstream test that
used -fvisibility=hidden as its example of a link error now uses
-Wl,--no-undefined.
A built-in list is a design choice the maintainers may prefer to own; this
one is reported rather than dropped, so nothing disappears silently. Not
done: raising an unreferenced _EXPORTS define only when a source
reads it, which would need the differ to read source files.
In the lab's runs with this change, the first version of the list (without
the front-end flags) still left agents suppressing -fexceptions on lensfun
and -w and -fno-common on CMake. With the list above, neither project's
next run suppressed a link flag by hand.
Testing
pytest tests/at this commit: 191 passed (130 onmain).🤖 Generated with Claude Code