Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precompiled header makes custom-target-regenerated header trigger recompilation of all sources #10882

Open
nyorain opened this issue Oct 2, 2022 · 0 comments

Comments

@nyorain
Copy link
Contributor

nyorain commented Oct 2, 2022

I'm building a C/C++ library with a precompiled header. Some of the cpp sources of the lib depend on generated headers, but none of the headers (including the pch) do. Every time any header is re-generated, all cpp files are recompiled, even though most of them have clearly no direct or indirect dependency to the generated headers.
This does not happen when I don't use a precompiled header.

To Reproduce
See a minimal repro here: https://github.com/nyorain/meson-bug-repro

project('buggy', 'cpp')

# very simple generated header
generated = custom_target(
	'generated.h',
	output: 'generated.h',
	input: files('generated.h.in'),
	command: ['cp', '@INPUT@', '@OUTPUT@']
)

# only bar.cpp depends on the generated header
shared_library('blub',
	sources: [files('main.cpp', 'foo.cpp', 'bar.cpp'), generated],
	cpp_pch: 'inc/fwd.hpp')

Every time you change generated.h.in, all cpp files are recompiled. Removing the cpp_pch line fixes that, then only bar.cpp gets recompiled on header change.

Expected behavior
I'd expect only the cpp sources that depend on the newly generated header to be recompiled.
In my case (the generated headers being shaders compiled and transformed into cpp arrays) this is very annoying and prevents me from using precompiled headers (since I have to recompile the whole lib every time I change a shader).

system parameters
On Linux, GCC, native build, my target is a shared library. Might affect other systems/configs.
python --version: 3.10.7
meson --version: 0.63.2
ninja --version: 1.11.1

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

No branches or pull requests

1 participant