diff --git a/nix-meson-build-support/common/meson.build b/nix-meson-build-support/common/meson.build index df8b958c0..bb57ca941 100644 --- a/nix-meson-build-support/common/meson.build +++ b/nix-meson-build-support/common/meson.build @@ -19,6 +19,9 @@ add_project_arguments( language : 'cpp', ) +# GCC doesn't benefit much from precompiled headers. +do_pch = cxx.get_id() == 'clang' + # This is a clang-only option for improving build times. # It forces the instantiation of templates in the PCH itself and # not every translation unit it's included in. diff --git a/src/libcmd/meson.build b/src/libcmd/meson.build index 5c3dd91ee..0cb41b46f 100644 --- a/src/libcmd/meson.build +++ b/src/libcmd/meson.build @@ -92,7 +92,7 @@ this_library = library( link_args: linker_export_flags, prelink : true, # For C++ static initializers install : true, - cpp_pch : ['pch/precompiled-headers.hh'] + cpp_pch : do_pch ? ['pch/precompiled-headers.hh'] : [] ) install_headers(headers, subdir : 'nix/cmd', preserve_path : true) diff --git a/src/libexpr/meson.build b/src/libexpr/meson.build index fe795a607..9c8569293 100644 --- a/src/libexpr/meson.build +++ b/src/libexpr/meson.build @@ -178,7 +178,7 @@ this_library = library( link_args: linker_export_flags, prelink : true, # For C++ static initializers install : true, - cpp_pch : ['pch/precompiled-headers.hh'] + cpp_pch : do_pch ? ['pch/precompiled-headers.hh'] : [] ) install_headers(headers, subdir : 'nix/expr', preserve_path : true) diff --git a/src/libstore/meson.build b/src/libstore/meson.build index c243f19c9..708188178 100644 --- a/src/libstore/meson.build +++ b/src/libstore/meson.build @@ -350,7 +350,7 @@ this_library = library( link_args: linker_export_flags, prelink : true, # For C++ static initializers install : true, - cpp_pch : ['pch/precompiled-headers.hh'] + cpp_pch : do_pch ? ['pch/precompiled-headers.hh'] : [] ) install_headers(headers, subdir : 'nix/store', preserve_path : true) diff --git a/src/libutil/meson.build b/src/libutil/meson.build index ced9c424d..881a8674c 100644 --- a/src/libutil/meson.build +++ b/src/libutil/meson.build @@ -191,7 +191,7 @@ this_library = library( link_args: linker_export_flags, prelink : true, # For C++ static initializers install : true, - cpp_pch : 'pch/precompiled-headers.hh' + cpp_pch : do_pch ? ['pch/precompiled-headers.hh'] : [] ) install_headers(headers, subdir : 'nix/util', preserve_path : true) diff --git a/src/nix/meson.build b/src/nix/meson.build index 586ee15c3..23b876690 100644 --- a/src/nix/meson.build +++ b/src/nix/meson.build @@ -186,7 +186,7 @@ this_exe = executable( include_directories : include_dirs, link_args: linker_export_flags, install : true, - cpp_pch : ['pch/precompiled-headers.hh'] + cpp_pch : do_pch ? ['pch/precompiled-headers.hh'] : [] ) meson.override_find_program('nix', this_exe)