1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-22 18:29:36 +01:00

meson: Add option for controlling PCH

In practice it turns out that turning off PCH is pretty
useful when debugging incorrect includes. I didn't want
to add this option initially because of the sheer amount
of copy-pasta that meson requires. But considering that
this is useful and the cost of copying the option a single
time is not too high this seems acceptable.
This commit is contained in:
Sergei Zimmerman 2025-10-08 02:51:19 +03:00
parent fb117e0cac
commit c105846646
No known key found for this signature in database
11 changed files with 106 additions and 2 deletions

View file

@ -27,3 +27,13 @@ option(
value : false,
description : 'Build benchmarks (requires gbenchmark)',
)
# Emulating 'auto' options, since we don't want auto_features to affect this
# and there's no other way of conditionally defaulting the value.
option(
'pch',
type : 'combo',
choices : [ 'auto', 'enabled', 'disabled' ],
value : 'auto',
description : 'Use C++ Precompiled Headers to speed up compilation',
)

View file

@ -29,7 +29,11 @@ add_project_arguments(
)
# GCC doesn't benefit much from precompiled headers.
if get_option('pch') == 'auto'
do_pch = cxx.get_id() == 'clang'
else
do_pch = get_option('pch') == 'enabled'
endif
# This is a clang-only option for improving build times.
# It forces the instantiation of templates in the PCH itself and
@ -38,7 +42,7 @@ do_pch = cxx.get_id() == 'clang'
# bother checking the version.
# This feature helps in particular with the expensive nlohmann::json template
# instantiations in libutil and libstore.
if cxx.get_id() == 'clang'
if cxx.get_id() == 'clang' and do_pch
add_project_arguments('-fpch-instantiate-templates', language : 'cpp')
endif

View file

@ -13,3 +13,13 @@ option(
value : 'editline',
description : 'Which library to use for nice line editing with the Nix language REPL',
)
option(
'pch',
type : 'combo',
choices : [ 'auto', 'enabled', 'disabled' ],
value : 'auto',
description : 'Use C++ Precompiled Headers to speed up compilation',
yield : true,
)

View file

@ -0,0 +1,10 @@
# vim: filetype=meson
option(
'pch',
type : 'combo',
choices : [ 'auto', 'enabled', 'disabled' ],
value : 'auto',
description : 'Use C++ Precompiled Headers to speed up compilation',
yield : true,
)

View file

@ -3,3 +3,13 @@ option(
type : 'feature',
description : 'enable garbage collection in the Nix expression evaluator (requires Boehm GC)',
)
option(
'pch',
type : 'combo',
choices : [ 'auto', 'enabled', 'disabled' ],
value : 'auto',
description : 'Use C++ Precompiled Headers to speed up compilation',
yield : true,
)

View file

@ -0,0 +1,10 @@
# vim: filetype=meson
option(
'pch',
type : 'combo',
choices : [ 'auto', 'enabled', 'disabled' ],
value : 'auto',
description : 'Use C++ Precompiled Headers to speed up compilation',
yield : true,
)

View file

@ -7,3 +7,13 @@ option(
description : 'Build benchmarks (requires gbenchmark)',
yield : true,
)
option(
'pch',
type : 'combo',
choices : [ 'auto', 'enabled', 'disabled' ],
value : 'auto',
description : 'Use C++ Precompiled Headers to speed up compilation',
yield : true,
)

View file

@ -40,3 +40,13 @@ option(
value : 'disabled',
description : 'Enable curl-based S3 binary cache store support (requires aws-crt-cpp and curl >= 7.75.0)',
)
option(
'pch',
type : 'combo',
choices : [ 'auto', 'enabled', 'disabled' ],
value : 'auto',
description : 'Use C++ Precompiled Headers to speed up compilation',
yield : true,
)

View file

@ -0,0 +1,10 @@
# vim: filetype=meson
option(
'pch',
type : 'combo',
choices : [ 'auto', 'enabled', 'disabled' ],
value : 'auto',
description : 'Use C++ Precompiled Headers to speed up compilation',
yield : true,
)

View file

@ -5,3 +5,13 @@ option(
type : 'feature',
description : 'determine microarchitecture levels with libcpuid (only relevant on x86_64)',
)
option(
'pch',
type : 'combo',
choices : [ 'auto', 'enabled', 'disabled' ],
value : 'auto',
description : 'Use C++ Precompiled Headers to speed up compilation',
yield : true,
)

View file

@ -7,3 +7,13 @@ option(
value : 'etc/profile.d',
description : 'the path to install shell profile files',
)
option(
'pch',
type : 'combo',
choices : [ 'auto', 'enabled', 'disabled' ],
value : 'auto',
description : 'Use C++ Precompiled Headers to speed up compilation',
yield : true,
)