Skip to content

move /showIncludes from always_args to ninja_compile_args#15960

Open
peterh wants to merge 1 commit into
mesonbuild:masterfrom
peterh:showIncludes
Open

move /showIncludes from always_args to ninja_compile_args#15960
peterh wants to merge 1 commit into
mesonbuild:masterfrom
peterh:showIncludes

Conversation

@peterh

@peterh peterh commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

The /showIncludes flag is required by ninja, but not by any of the other backends. Since this is a ninja-specific requirement, it makes sense to include it with the ninja backend.

Fixes a compile performance regression with the vs backend when using Visual Studio 2026 version 18.7

Fixes #15959

Comment thread mesonbuild/backend/ninjabackend.py Outdated
commands = self.generate_basic_compiler_args(target, compiler)
# /showIncludes is needed for build dependency tracking in Ninja
# See: https://ninja-build.org/manual.html#_deps
if compiler.id in {'msvc', 'clang-cl', 'intel-cl'}:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are removing the flag from VisualStudioLikeCompiler, please use isinstance(compiler, VisualStudioLikeCompiler).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's much better.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately that means unconditionally importing additional modules on unix in order to check identity, which is something we mostly switched away from in favor of compiler.id equality comparisons out of concern for performance.

@dcbaker

dcbaker commented Jun 26, 2026

Copy link
Copy Markdown
Member

We have lots of operations in the Compiler classes that exist for only one backend. What issue are you solving by moving this to the ninja backend instead of being a property of the compiler?

@peterh

peterh commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

What issue are you solving by moving this to the ninja backend instead of being a property of the compiler?

Short version: Compiles take 40% longer than they should with backend=vs.

Long version: See #15959

@dcbaker

dcbaker commented Jun 26, 2026

Copy link
Copy Markdown
Member

I'd prefer if we added a new method to the Compiler class for that, implemented it as return [] for the base compiler, and then specialized it in the VisualStudioLikeMixin, then the ninja backend can call that method to get /showIncludes and the vs and xcode backends can just not call it.

@bonzini

bonzini commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Oh indeed that's the better implementation! Sorry for missing the obvious

@peterh peterh changed the title move /showIncludes from mixins/visualstudio to backend/ninja move /showIncludes from always_args to ninja_compile_args Jun 27, 2026
Comment thread mesonbuild/compilers/compilers.py Outdated
"""Where is the libdir for the current machine located"""
raise EnvironmentException(f'{self.get_id()} does not support Rust target libdir')

def get_ninja_compile_args(self) -> T.List[str]:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes more sense to name this something like get_show_dep_args(), with a docstring like:

Arguments for printing depfile information in MSVC compatible format.

Only the base class needs the docstring.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I respectfully disagree. That's what this function does, but it's not why this function does what it does.

If we were adding something to support a b_include_list option and there was a gcc version that returned ['-MD'], I would agree with you. But in this case, we're returning a list of arguments that ninja needs for this backend to work properly. We're not returning a flag that shows the end user the include files. (Well, we are, but that's not why we're returning that flag).

All that said, it's your project, so I'll change the name to whatever you like.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterh,

I agree with your high level explanation but the function does not actually have anything to do with ninja!

It is a "not_vsbackend_compile_args" and should be used on any backend that isn't visual studio, surely. It just so happens that the only such backend today is Ninja, but if we ever added another one then surely we would want to have showincludes in use.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eli did a better job of explaining what I meant than I did, haha. Thanks Eli

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with naming it something like get_show_dep_args or get_msvc_dep_args.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a "not_vsbackend_compile_args" and should be used on any backend that isn't visual studio, surely.

Once again, I respectfully disagree. /showIncludes is a ninja-specific thing, not a "not VS" thing. For example, if we ever add a Code::Blocks back-end, it won't use /showIncludes. I know that meson will never have a make backend, but make doesn't know what to do with /showIncludes. Are there any other possible back-ends that I should take a look at?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A make backend would use /showIncludes, with a wrapper around cl.exe that converts the result into make dependencies. What's wrong with get_msvc_dep_args?

@eli-schwartz eli-schwartz Jul 5, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it's true that it needs postprocessing in order to be utilized, I don't know of a theoretical process for getting the cl.exe compiler to produce dependency information in any other format or output stream 1, so...

... it is literally "showincludes or bust".

The process for a different backend would likely center around wrapping the compiler in a program that parses include lines itself, redirecting include lines to a genuine depfile and emitting all other lines to stdout. This is exactly what ninja does, except ninja does it in-process and merges them to .ninja_deps which it uses anyway, instead of taking a temporary detour to depfiles.

Bazel uses showincludes internally too.

It's not totally beyond the realm of possibility that GNU Make will add code to windows builds that parses buffered rule outputs as well. ;) The current status is simply that people using cl.exe with GNU Make cannot get augmented dependencies at all (unless they write their own run_cl_and_emit_depfile.py --depfile=blah.d -- cl.exe /showincludes /other /args).

Footnotes

  1. tlog files don't count as they are produced by filetracker.exe, which is literally "inject a dll into the program to be run, then watch what files get opened".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterh I appreciate that you don't agree with us, but the three most active maintainers are all asking for the same very specific and frankly very minor change and then we're ready to press merge.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

frankly very minor change

Sorry for the delay. I've been too busy to even read the replies in this issue for the past few days, much less make (and test) the minor change.

@dcbaker dcbaker added this to the 1.12 milestone Jun 29, 2026
The /showIncludes flag is required by ninja, but not by msbuild. Since this
is a backend-specific requirement, it makes sense to separate it from the
rest of the always_args.

Fixes a compile performance regression with the vs backend when using
Visual Studio 2026 version 18.7

Fixes mesonbuild#15959
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.

/showIncludes log spam since Visual Studio 2026 version 18.7

4 participants