clang_15: fix build!=(host==target) cross compilation

clang_15 appears to not cross compile in the build!=(host==target)
case due to two problems, which this commit fixes:

- It trips -Wmaybe-uninitialized on recent gcc, but only in the
  build!=host case (likely due to #ifdefs)

- Two more buildPlatform tools have been added:
  clang-tidy-confusable-chars-gen and clang-pseudo-gen

Co-authored-by: Rahul Butani <rrbutani@users.noreply.github.com>
This commit is contained in:
Adam Joseph 2023-04-16 16:59:18 -07:00 committed by Alyssa Ross
parent ac413afd08
commit 2e77eb8190
2 changed files with 26 additions and 4 deletions

View File

@ -36,9 +36,14 @@ let
"-DSPHINX_OUTPUT_MAN=ON"
"-DSPHINX_OUTPUT_HTML=OFF"
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
"-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen"
# Added in LLVM15:
# `clang-tidy-confusable-chars-gen`: https://github.com/llvm/llvm-project/commit/c3574ef739fbfcc59d405985a3a4fa6f4619ecdb
# `clang-pseudo-gen`: https://github.com/llvm/llvm-project/commit/cd2292ef824591cc34cc299910a3098545c840c7
"-DCLANG_TIDY_CONFUSABLE_CHARS_GEN=${buildLlvmTools.libclang.dev}/bin/clang-tidy-confusable-chars-gen"
"-DCLANG_PSEUDO_GEN=${buildLlvmTools.libclang.dev}/bin/clang-pseudo-gen"
];
patches = [
@ -60,6 +65,12 @@ let
outputs = [ "out" "lib" "dev" "python" ];
env = lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
# The following warning is triggered with (at least) gcc >=
# 12, but appears to occur only for cross compiles.
NIX_CFLAGS_COMPILE = "-Wno-maybe-uninitialized";
};
postInstall = ''
ln -sv $out/bin/clang $out/bin/cpp
@ -80,7 +91,7 @@ let
patchShebangs $python/bin
mkdir -p $dev/bin
cp bin/clang-tblgen $dev/bin
cp bin/{clang-tblgen,clang-tidy-confusable-chars-gen,clang-pseudo-gen} $dev/bin
'';
passthru = {

View File

@ -36,9 +36,14 @@ let
"-DSPHINX_OUTPUT_MAN=ON"
"-DSPHINX_OUTPUT_HTML=OFF"
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
"-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen"
# Added in LLVM15:
# `clang-tidy-confusable-chars-gen`: https://github.com/llvm/llvm-project/commit/c3574ef739fbfcc59d405985a3a4fa6f4619ecdb
# `clang-pseudo-gen`: https://github.com/llvm/llvm-project/commit/cd2292ef824591cc34cc299910a3098545c840c7
"-DCLANG_TIDY_CONFUSABLE_CHARS_GEN=${buildLlvmTools.libclang.dev}/bin/clang-tidy-confusable-chars-gen"
"-DCLANG_PSEUDO_GEN=${buildLlvmTools.libclang.dev}/bin/clang-pseudo-gen"
];
patches = [
@ -60,6 +65,12 @@ let
outputs = [ "out" "lib" "dev" "python" ];
env = lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
# The following warning is triggered with (at least) gcc >=
# 12, but appears to occur only for cross compiles.
NIX_CFLAGS_COMPILE = "-Wno-maybe-uninitialized";
};
postInstall = ''
ln -sv $out/bin/clang $out/bin/cpp
@ -80,7 +91,7 @@ let
patchShebangs $python/bin
mkdir -p $dev/bin
cp bin/clang-tblgen $dev/bin
cp bin/{clang-tblgen,clang-tidy-confusable-chars-gen,clang-pseudo-gen} $dev/bin
'';
passthru = {