Skip to content

make -isystem behave like -I#15577

Draft
bonzini wants to merge 3 commits intomesonbuild:masterfrom
bonzini:test15478
Draft

make -isystem behave like -I#15577
bonzini wants to merge 3 commits intomesonbuild:masterfrom
bonzini:test15478

Conversation

@bonzini
Copy link
Contributor

@bonzini bonzini commented Feb 23, 2026

Fixes: #2155

…ring

Prior to commit a6ddf2534 ("backend/ninja: Extend IncludeDirs.rel_string_list
for backend use"), when include_directories() was called with
`is_system: true` and multiple directories, the resulting `-isystem`
flags appeared on the command line in the opposite order from what was
specified: the last-listed directory was searched first by the compiler.
This was the opposite convention from non-system -I includes, where the
first-listed directory is searched first.

The asymmetry was not intentional; it was a side effect of how
CompilerArgs.__iadd__ handles flags that are not in prepend_prefixes:

- `-I` is in CLikeCompilerArgs.prepend_prefixes, so `__iadd__`
prepends it.  The ninja backend iterates directories in reversed
order and adds them one at a time; the prepend-on-each-add
counteracts the reversal, producing the original order.

- `-isystem` was not in prepend_prefixes, so __iadd__ appended it.
The same reversed one-at-a-time iteration then produced a reversed
sequence — the last-listed directory ended up first on the command line.

Commit a6ddf25 changed generate_inc_dir to add all directories
in a single bulk commands += call instead of one at a time.  This
preserved the correct order for -I (the double reversal in
__iadd__ still works for a bulk add) but silently broke -isystem,
because appending a list at once preserves input order rather than
reversing it.

Fix this by adding -isystem to CLikeCompilerArgs.prepend_prefixes
so that both -I and -isystem are handled uniformly.  This also
means the bulk generate_inc_dir approach works correctly for both
flag types, so the per-directory reversed loop from before commt
a6ddf25 is no longer needed.

Adding -isystem to prepend_prefixes now makes the ordering
consistent, but projects that relied on the old reversed
behaviour would silently break.  To preserve backwards compatibility,
emit a FeatureBroken and reverse the directory list when 1) `is_system:
true` 2) the project declares meson_version: '>=1.11.0'.
Unlike normal FeatureBroken, the bug with include_directories(is_system: true)
isn't a feature going away, it just suboptimal behaviour that could be fixed.

Introduce a new kind of feature check for something that is fixed and has
a behavior change when meson_version is bumped.  It uses mlog.warning()
instead of mlog.deprecation(), and has the same check as FeatureNew so that
the warning disappears with new versions of Meson.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
@bonzini
Copy link
Contributor Author

bonzini commented Feb 23, 2026

This is a dead end - prepend_prefixes didn't include -isystem in order to support -isystem as a separate flag, i.e. '-isystem' '/usr/local/include', as seen in InternalTests::test_compiler_args_remove_system.

@bonzini
Copy link
Contributor Author

bonzini commented Feb 27, 2026

Related: #2155 - reopening as draft

@bonzini bonzini reopened this Feb 27, 2026
@bonzini bonzini changed the title test for #15478 make -isystem behave like -I Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should de-duplicate -isystem flags just like -I flags

1 participant