Compare commits

...

1 Commits

Author SHA1 Message Date
Sergei Zimmerman
c105846646 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.
2025-10-08 02:56:16 +03:00
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.
do_pch = cxx.get_id() == 'clang'
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,
)