2be2b5328c
`libstdc++` and a few other libraries are comiled with the options set in `EXTRA_TARGET_FLAGS`. Normally, this is filled form `EXTRA_FLAGS` inside of `builder.sh`, from which it inherits its optimization option. For cross compilers `EXTRA_TARGET_FLAGS` is set by a dedicated function that does not specify any optimization, leading to sub-par runtime performance of many C++ programs.
34 lines
1.3 KiB
Nix
34 lines
1.3 KiB
Nix
{ stdenv, crossStageStatic, langD ? false, libcCross, threadsCross }:
|
|
|
|
let
|
|
inherit (stdenv) lib hostPlatform targetPlatform;
|
|
in
|
|
|
|
{
|
|
# For non-cross builds these flags are currently assigned in builder.sh.
|
|
# It would be good to consolidate the generation of makeFlags
|
|
# ({C,CXX,LD}FLAGS_FOR_{BUILD,TARGET}, etc...) at some point.
|
|
EXTRA_TARGET_FLAGS = let
|
|
mkFlags = dep: langD: lib.optionals (targetPlatform != hostPlatform && dep != null && !langD) ([
|
|
"-O2 -idirafter ${lib.getDev dep}${dep.incdir or "/include"}"
|
|
] ++ stdenv.lib.optionals (! crossStageStatic) [
|
|
"-B${lib.getLib dep}${dep.libdir or "/lib"}"
|
|
]);
|
|
in mkFlags libcCross langD
|
|
++ lib.optionals (!crossStageStatic) (mkFlags threadsCross langD)
|
|
;
|
|
|
|
EXTRA_TARGET_LDFLAGS = let
|
|
mkFlags = dep: lib.optionals (targetPlatform != hostPlatform && dep != null) ([
|
|
"-Wl,-L${lib.getLib dep}${dep.libdir or "/lib"}"
|
|
] ++ (if crossStageStatic then [
|
|
"-B${lib.getLib dep}${dep.libdir or "/lib"}"
|
|
] else [
|
|
"-Wl,-rpath,${lib.getLib dep}${dep.libdir or "/lib"}"
|
|
"-Wl,-rpath-link,${lib.getLib dep}${dep.libdir or "/lib"}"
|
|
]));
|
|
in mkFlags libcCross
|
|
++ lib.optionals (!crossStageStatic) (mkFlags threadsCross)
|
|
;
|
|
}
|