about summary refs log tree commit diff
path: root/pkgs/development/compilers/gcc/10/default.nix
diff options
context:
space:
mode:
authorSergei Trofimovich <slyich@gmail.com>2023-01-05 10:27:57 +0000
committerSergei Trofimovich <slyich@gmail.com>2023-01-05 14:41:35 +0000
commit2c931bd5f404162c15de10dca8e476e5469b2994 (patch)
tree112ea5c1dff064ad399932038ae1c5b07eb0fa5c /pkgs/development/compilers/gcc/10/default.nix
parent4acd5a978ba5047d6a638e310753ae2cf650c439 (diff)
gcc: provide both native and cross forms of gcc.libs libraries
I would like to use --sysroot=/nix/store/does/not/exist hack
for both `gcc` and `clang` drivers to remove default include
(and library) search paths when we override them with libc.

For `gcc` it works as is. But for `clang` it also drops some of
`gcc` search paths`. Let'sconsider 2 lookups.

Successful lookup (no `--sysroot`):

    $ printf "int main(){}" | clang++ -x c++ - -Wl,--verbose |& grep -F stdc++
    attempt to open /nix/store/...-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/libstdc++.so failed
    attempt to open /nix/store/...-gcc-11.3.0-lib/x86_64-unknown-linux-gnu/lib/libstdc++.so failed
    attempt to open /nix/store/...-clang-11.1.0-lib/lib/libstdc++.so failed
    attempt to open /nix/store/...-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/libstdc++.so failed
    attempt to open /nix/store/...-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/../../../../lib64/libstdc++.so failed
    /nix/store/...-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/../../../../lib64/libstdc++.a

Failed lookup (has `--sysroot`):

    $ printf "int main(){}" | clang++ --sysroot=/does/not/exist -x c++ - -Wl,--verbose |& grep -F stdc++
    attempt to open /nix/store/...-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/libstdc++.so failed
    attempt to open /nix/store/...-gcc-11.3.0-lib/x86_64-unknown-linux-gnu/lib/libstdc++.so failed
    attempt to open /nix/store/...-clang-11.1.0-lib/lib/libstdc++.so failed
    attempt to open /nix/store/...-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/libstdc++.so failed
    /nix/store/...-binutils-2.39/bin/ld: cannot find -lstdc++: No such file or directory

Note how `clang` starts the search roughly from
`gcc-11.3.0-lib/x86_64-unknown-linux-gnu/lib` in both cases. I think
it's our preferred location for both native and cross cases.

The change adds such a symlink:

    `gcc-11.3.0-lib` -> `gcc-11.3.0-lib/x86_64-unknown-linux-gnu`
Diffstat (limited to 'pkgs/development/compilers/gcc/10/default.nix')
-rw-r--r--pkgs/development/compilers/gcc/10/default.nix1
1 files changed, 1 insertions, 0 deletions
diff --git a/pkgs/development/compilers/gcc/10/default.nix b/pkgs/development/compilers/gcc/10/default.nix
index e4cebab266e84..afe58e51cdd30 100644
--- a/pkgs/development/compilers/gcc/10/default.nix
+++ b/pkgs/development/compilers/gcc/10/default.nix
@@ -222,6 +222,7 @@ stdenv.mkDerivation ({
   };
 
   targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null;
+  targetPlatformConfig = targetPlatform.config;
 
   buildFlags = optional
     (targetPlatform == hostPlatform && hostPlatform == buildPlatform)