From 0e9ef0a07d9723c8e6b4f0cdbd81cbcf3407046a Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sun, 7 May 2023 01:27:01 -0700 Subject: [PATCH 1/3] cc-wrapper: when merging gcc32 and gcc64, merge libgcc as well Our gcc_multi and glibc_multi expressions merge together a 32-bit-targeted and 64-bit-targeted gcc. However they do not thread through the passthru.libgcc from these merged gccs. This commit corrects that. It also extends passthru.libgcc to allow a *list* rather than just a single outpath. Resolves part of #221891 (at least getting it back to the error message it gave before). --- pkgs/build-support/cc-wrapper/default.nix | 6 +++--- pkgs/development/compilers/llvm/multi.nix | 2 +- pkgs/development/libraries/glibc/multi.nix | 13 +++++++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index bc9c199f778d..77ecaf098eac 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -364,9 +364,9 @@ stdenv.mkDerivation { '' # this ensures that when clang passes -lgcc_s to lld (as it does # when building e.g. firefox), lld is able to find libgcc_s.so - + lib.optionalString (gccForLibs?libgcc) '' - echo "-L${gccForLibs.libgcc}/lib" >> $out/nix-support/cc-ldflags - '') + + concatMapStrings (libgcc: '' + echo "-L${libgcc}/lib" >> $out/nix-support/cc-ldflags + '') (lib.toList (gccForLibs.libgcc or []))) ## ## General libc support diff --git a/pkgs/development/compilers/llvm/multi.nix b/pkgs/development/compilers/llvm/multi.nix index ecea5d440378..7906f2b2bd6c 100644 --- a/pkgs/development/compilers/llvm/multi.nix +++ b/pkgs/development/compilers/llvm/multi.nix @@ -46,7 +46,7 @@ let libc = gcc_multi_sysroot; }; - gccForLibs = gcc_multi_sysroot; + gccForLibs = gcc_multi_sysroot // { inherit (glibc_multi) libgcc; }; }; in clangMulti diff --git a/pkgs/development/libraries/glibc/multi.nix b/pkgs/development/libraries/glibc/multi.nix index be190d77c736..5cd48958ec2c 100644 --- a/pkgs/development/libraries/glibc/multi.nix +++ b/pkgs/development/libraries/glibc/multi.nix @@ -1,4 +1,5 @@ -{ runCommand, glibc, glibc32 +{ lib +, runCommand, glibc, glibc32 }: let @@ -7,7 +8,15 @@ let in runCommand "${nameVersion.name}-multi-${nameVersion.version}" # out as the first output is an exception exclusive to glibc - { outputs = [ "out" "bin" "dev" ]; } # TODO: no static version here (yet) + { + outputs = [ "out" "bin" "dev" ]; # TODO: no static version here (yet) + passthru = { + libgcc = lib.lists.filter (x: x!=null) [ + (glibc64.libgcc or null) + (glibc32.libgcc or null) + ]; + }; + } '' mkdir -p "$out/lib" ln -s '${glibc64.out}'/lib/* "$out/lib" From c02c5f0860ee5ea791a1a839fbbb872ef7072b73 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Tue, 9 May 2023 00:10:04 -0700 Subject: [PATCH 2/3] wrapClangMulti: set gcc_multi_sysroot.langCC The phoney gcc that we construct for multilib was missing the `langCC` attribute, which `cc-wrapper` needs in order to decide whether or not to add gcc's `libstdc++` headers as an `-isystem` for `clang`. --- pkgs/development/compilers/llvm/multi.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/llvm/multi.nix b/pkgs/development/compilers/llvm/multi.nix index 7906f2b2bd6c..d579e001563a 100644 --- a/pkgs/development/compilers/llvm/multi.nix +++ b/pkgs/development/compilers/llvm/multi.nix @@ -46,7 +46,13 @@ let libc = gcc_multi_sysroot; }; - gccForLibs = gcc_multi_sysroot // { inherit (glibc_multi) libgcc; }; + gccForLibs = gcc_multi_sysroot // { + inherit (glibc_multi) libgcc; + langCC = + assert (gcc64.cc.langCC != gcc32.cc.langCC) + -> throw "(gcc64.cc.langCC=${gcc64.cc.langCC}) != (gcc32.cc.langCC=${gcc32.cc.langCC})"; + gcc64.cc.langCC; + }; }; in clangMulti From 62794bf2bbab395dc841db4227079e7bba86dcc8 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Tue, 9 May 2023 00:11:37 -0700 Subject: [PATCH 3/3] wrapClangMulti: link include/c++ into gcc_multi_sysroot The phoney gcc that we construct for multilib was missing the `$out/include/c++` directory which `cc-wrapper` needs to pass as an `-isystem` to `clang`. Closes #221891 --- pkgs/development/compilers/llvm/multi.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/llvm/multi.nix b/pkgs/development/compilers/llvm/multi.nix index d579e001563a..136e13ba21f5 100644 --- a/pkgs/development/compilers/llvm/multi.nix +++ b/pkgs/development/compilers/llvm/multi.nix @@ -28,7 +28,9 @@ let # includes - ln -s ${glibc_multi.dev}/include $out/ + mkdir -p $out/include + ln -s ${glibc_multi.dev}/include/* $out/include + ln -s ${gcc64.cc}/include/c++ $out/include/c++ # dynamic linkers mkdir -p $out/lib/32