llvmPackages.libclang: add enableClangToolsExtra flag

rocmPackages needs a clang at runtime but has no need to include
clang-tidy.

The approach in this change avoids rebuilds and is messy, I will
make a followup in staging that changes this to more idiomatic
optionalString usage if this is merged

Luna 1f462661 5364a5ff

Changed files
+13 -3
pkgs
development
compilers
llvm
common
clang
+13 -3
pkgs/development/compilers/llvm/common/clang/default.nix
···
buildLlvmTools,
fixDarwinDylibNames,
enableManpages ? false,
+
enableClangToolsExtra ? true,
devExtraCmakeFlags ? [ ],
replaceVars,
getVersionFile,
fetchpatch,
+
# for tests
+
libclang,
}:
stdenv.mkDerivation (
finalAttrs:
···
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/clang "$out"
-
cp -r ${monorepoSrc}/clang-tools-extra "$out"
+
${lib.optionalString enableClangToolsExtra "cp -r ${monorepoSrc}/clang-tools-extra \"$out\""}
'')
else
src;
···
mkdir -p $dev/bin
''
-
+ (
+
# TODO(@LunNova): Clean up this rebuild avoidance in staging
+
+ lib.optionalString enableClangToolsExtra (
if lib.versionOlder release_version "20" then
''
cp bin/{clang-tblgen,clang-tidy-confusable-chars-gen,clang-pseudo-gen} $dev/bin
···
''
cp bin/{clang-tblgen,clang-tidy-confusable-chars-gen} $dev/bin
''
-
);
+
)
+
+ lib.optionalString (!enableClangToolsExtra) ''
+
cp bin/clang-tblgen $dev/bin
+
'';
env =
lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform && !stdenv.hostPlatform.useLLVM)
···
) "stackclashprotection"
++ lib.optional (!(targetPlatform.isx86_64 || targetPlatform.isAarch64)) "zerocallusedregs"
++ (finalAttrs.passthru.hardeningUnsupportedFlags or [ ]);
+
tests.withoutOptionalFeatures = libclang.override {
+
enableClangToolsExtra = false;
+
};
};
requiredSystemFeatures = [ "big-parallel" ];