Merge changes Ic4be41eb,I48db2385 into main

* changes:
  devshells: only enable pch for clang
  build: expose option to enable or disable precompiled std headers
This commit is contained in:
Qyriad 2024-06-06 22:21:52 +00:00 committed by Gerrit Code Review
commit ec768df004
11 changed files with 39 additions and 16 deletions

View file

@ -129,6 +129,20 @@ endif
cxx = meson.get_compiler('cpp') cxx = meson.get_compiler('cpp')
# clangd breaks when GCC is using precompiled headers lmao
# https://git.lix.systems/lix-project/lix/issues/374
should_pch = get_option('enable-pch-std')
summary('PCH C++ stdlib', should_pch, bool_yn : true)
if should_pch
# Unlike basically everything else that takes a file, Meson requires the arguments to
# cpp_pch : to be strings and doesn't accept files(). So absolute path it is.
cpp_pch = [meson.project_source_root() / 'src/pch/precompiled-headers.hh']
else
cpp_pch = []
endif
# Translate some historical and Mesony CPU names to Lixy CPU names. # Translate some historical and Mesony CPU names to Lixy CPU names.
# FIXME(Qyriad): the 32-bit x86 code is not tested right now, because cross compilation for Lix # FIXME(Qyriad): the 32-bit x86 code is not tested right now, because cross compilation for Lix
# to those architectures is currently broken for other reasons, namely: # to those architectures is currently broken for other reasons, namely:

View file

@ -64,3 +64,7 @@ option('internal-api-docs', type : 'feature', value : 'auto',
option('profile-dir', type : 'string', value : 'etc/profile.d', option('profile-dir', type : 'string', value : 'etc/profile.d',
description : 'the path to install shell profile files', description : 'the path to install shell profile files',
) )
option('enable-pch-std', type : 'boolean', value : true,
description : 'whether to use precompiled headers for C++\'s standard library (breaks clangd if you\'re using GCC)',
)

View file

@ -436,9 +436,14 @@ stdenv.mkDerivation (finalAttrs: {
# For Meson to find Boost. # For Meson to find Boost.
env = finalAttrs.env; env = finalAttrs.env;
# I guess this is necessary because mesonFlags to mkDerivation doesn't propagate in inputsFrom, mesonFlags =
# which only propagates stuff set in hooks? idk. # I guess this is necessary because mesonFlags to mkDerivation doesn't propagate in inputsFrom,
inherit (finalAttrs) mesonFlags; # which only propagates stuff set in hooks? idk.
finalAttrs.mesonFlags
# Clangd breaks when GCC is using precompiled headers, so for the devshell specifically
# we make precompiled C++ stdlib conditional on using Clang.
# https://git.lix.systems/lix-project/lix/issues/374
++ [ (lib.mesonBool "enable-pch-std" stdenv.cc.isClang) ];
packages = packages =
lib.optional (stdenv.cc.isClang && hostPlatform == buildPlatform) clang-tools_llvm lib.optional (stdenv.cc.isClang && hostPlatform == buildPlatform) clang-tools_llvm

View file

@ -54,7 +54,7 @@ libcmd = library(
nlohmann_json, nlohmann_json,
lix_doc lix_doc
], ],
cpp_pch : ['../pch/precompiled-headers.hh'], cpp_pch : cpp_pch,
install : true, install : true,
# FIXME(Qyriad): is this right? # FIXME(Qyriad): is this right?
install_rpath : libdir, install_rpath : libdir,

View file

@ -145,7 +145,7 @@ libexpr = library(
include_directories : [ include_directories : [
'../libmain', '../libmain',
], ],
cpp_pch : ['../pch/precompiled-headers.hh'], cpp_pch : cpp_pch,
install : true, install : true,
# FIXME(Qyriad): is this right? # FIXME(Qyriad): is this right?
install_rpath : libdir, install_rpath : libdir,

View file

@ -30,7 +30,7 @@ libfetchers = library(
liblixutil, liblixutil,
nlohmann_json, nlohmann_json,
], ],
cpp_pch : ['../pch/precompiled-headers.hh'], cpp_pch : cpp_pch,
install : true, install : true,
# FIXME(Qyriad): is this right? # FIXME(Qyriad): is this right?
install_rpath : libdir, install_rpath : libdir,

View file

@ -20,7 +20,7 @@ libmain = library(
liblixutil, liblixutil,
liblixstore, liblixstore,
], ],
cpp_pch : ['../pch/precompiled-headers.hh'], cpp_pch : cpp_pch,
install : true, install : true,
# FIXME(Qyriad): is this right? # FIXME(Qyriad): is this right?
install_rpath : libdir, install_rpath : libdir,

View file

@ -220,7 +220,7 @@ libstore = library(
nlohmann_json, nlohmann_json,
], ],
cpp_args : cpp_args, cpp_args : cpp_args,
cpp_pch : ['../pch/precompiled-headers.hh'], cpp_pch : cpp_pch,
install : true, install : true,
# FIXME(Qyriad): is this right? # FIXME(Qyriad): is this right?
install_rpath : libdir, install_rpath : libdir,

View file

@ -129,7 +129,7 @@ libutil = library(
openssl, openssl,
nlohmann_json, nlohmann_json,
], ],
cpp_pch : ['../pch/precompiled-headers.hh'], cpp_pch : cpp_pch,
implicit_include_directories : true, implicit_include_directories : true,
install : true, install : true,
) )

View file

@ -89,7 +89,7 @@ nix = executable(
boehm, boehm,
nlohmann_json, nlohmann_json,
], ],
cpp_pch : ['../pch/precompiled-headers.hh'], cpp_pch : cpp_pch,
install : true, install : true,
# FIXME(Qyriad): is this right? # FIXME(Qyriad): is this right?
install_rpath : libdir, install_rpath : libdir,

View file

@ -68,7 +68,7 @@ libutil_tester = executable(
liblixutil_test_support, liblixutil_test_support,
nlohmann_json, nlohmann_json,
], ],
cpp_pch : ['../../src/pch/precompiled-headers.hh'], cpp_pch : cpp_pch,
) )
test( test(
@ -103,7 +103,7 @@ libstore_test_support = library(
include_directories : include_directories( include_directories : include_directories(
'libstore-support', 'libstore-support',
), ),
cpp_pch : ['../../src/pch/precompiled-headers.hh'], cpp_pch : cpp_pch,
) )
liblixstore_test_support = declare_dependency( liblixstore_test_support = declare_dependency(
include_directories : include_directories('libstore-support'), include_directories : include_directories('libstore-support'),
@ -137,7 +137,7 @@ libstore_tester = executable(
gtest, gtest,
nlohmann_json, nlohmann_json,
], ],
cpp_pch : ['../../src/pch/precompiled-headers.hh'], cpp_pch : cpp_pch,
) )
test( test(
@ -169,7 +169,7 @@ libexpr_test_support = library(
include_directories : include_directories( include_directories : include_directories(
'libexpr-support', 'libexpr-support',
), ),
cpp_pch : ['../../src/pch/precompiled-headers.hh'], cpp_pch : cpp_pch,
) )
liblixexpr_test_support = declare_dependency( liblixexpr_test_support = declare_dependency(
include_directories : include_directories('libexpr-support'), include_directories : include_directories('libexpr-support'),
@ -203,7 +203,7 @@ libexpr_tester = executable(
gtest, gtest,
nlohmann_json, nlohmann_json,
], ],
cpp_pch : ['../../src/pch/precompiled-headers.hh'], cpp_pch : cpp_pch,
) )
test( test(
@ -230,7 +230,7 @@ libcmd_tester = executable(
gtest, gtest,
boost, boost,
], ],
cpp_pch : ['../../src/pch/precompiled-headers.hh'], cpp_pch : cpp_pch,
) )
test( test(