depot/third_party/nixpkgs/pkgs/development/compilers/gcc/common/extra-target-flags.nix
Default email 8ac5e011d6 Project import generated by Copybara.
GitOrigin-RevId: 2c3273caa153ee8eb5786bc8141b85b859e7efd7
2020-04-24 19:36:52 -04:00

30 lines
1 KiB
Nix

{ stdenv, crossStageStatic, libcCross, threadsCross }:
let
inherit (stdenv) lib hostPlatform targetPlatform;
in
{
EXTRA_TARGET_FLAGS = let
mkFlags = dep: lib.optionals (targetPlatform != hostPlatform && dep != null) ([
"-idirafter ${lib.getDev dep}${dep.incdir or "/include"}"
] ++ stdenv.lib.optionals (! crossStageStatic) [
"-B${lib.getLib dep}${dep.libdir or "/lib"}"
]);
in mkFlags libcCross
++ lib.optionals (!crossStageStatic) (mkFlags threadsCross)
;
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)
;
}