cc-wrapper: fix linking against GCC libs for non-GCC
Currently, clang++ statically links against libstdc++ instead of dynamically links, because the -L path included in the cc-wrapper is incorrect. The gccForLibs.lib output only contains the architecture subdirectory if the target and host platform are not the same. (See targetConfig set in gcc/<version>/default.nix and the gcc/builder.nix) This fixes the incorrect linking by using the correct path for both the cross and native cases. This also matches the cc_solib set above in cc-wrapper/default.nix Tested by compiling a simple cpp binary and noting that it now correctly dynamically links against libstdc++, natively on x86_64 and arm64, as well as x86_64 -> arm64 cross compilation. Co-Authored-By: Sebastian Ullrich <sebasti@nullri.ch>
This commit is contained in:
parent
3524da2f0a
commit
2946b819c2
1 changed files with 3 additions and 1 deletions
|
@ -70,6 +70,8 @@ let
|
|||
&& !(stdenv.targetPlatform.useAndroidPrebuilt or false)
|
||||
&& !(stdenv.targetPlatform.isiOS or false)
|
||||
&& gccForLibs != null;
|
||||
gccForLibs_solib = getLib gccForLibs
|
||||
+ optionalString (targetPlatform != hostPlatform) "/${targetPlatform.config}";
|
||||
|
||||
# older compilers (for example bootstrap's GCC 5) fail with -march=too-modern-cpu
|
||||
isGccArchSupported = arch:
|
||||
|
@ -311,7 +313,7 @@ stdenv.mkDerivation {
|
|||
|
||||
echo "-B${gccForLibs}/lib/gcc/${targetPlatform.config}/${gccForLibs.version}" >> $out/nix-support/cc-cflags
|
||||
echo "-L${gccForLibs}/lib/gcc/${targetPlatform.config}/${gccForLibs.version}" >> $out/nix-support/cc-ldflags
|
||||
echo "-L${gccForLibs.lib}/${targetPlatform.config}/lib" >> $out/nix-support/cc-ldflags
|
||||
echo "-L${gccForLibs_solib}/lib" >> $out/nix-support/cc-ldflags
|
||||
''
|
||||
|
||||
# TODO We would like to connect this to `useGccForLibs`, but we cannot yet
|
||||
|
|
Loading…
Reference in a new issue