2021-02-05 17:12:51 +00:00
|
|
|
{ lib, stdenv, crossStageStatic, langD ? false, libcCross, threadsCross }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
2021-02-05 17:12:51 +00:00
|
|
|
inherit (stdenv) hostPlatform targetPlatform;
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2020-05-29 06:06:01 +00:00
|
|
|
# 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.
|
2020-06-18 07:06:33 +00:00
|
|
|
EXTRA_FLAGS_FOR_TARGET = let
|
2020-05-29 06:06:01 +00:00
|
|
|
mkFlags = dep: langD: lib.optionals (targetPlatform != hostPlatform && dep != null && !langD) ([
|
|
|
|
"-O2 -idirafter ${lib.getDev dep}${dep.incdir or "/include"}"
|
2021-02-05 17:12:51 +00:00
|
|
|
] ++ lib.optionals (! crossStageStatic) [
|
2020-04-24 23:36:52 +00:00
|
|
|
"-B${lib.getLib dep}${dep.libdir or "/lib"}"
|
|
|
|
]);
|
2020-05-29 06:06:01 +00:00
|
|
|
in mkFlags libcCross langD
|
2022-11-21 17:40:18 +00:00
|
|
|
++ lib.optionals (!crossStageStatic) (mkFlags (threadsCross.package or null) langD)
|
2020-04-24 23:36:52 +00:00
|
|
|
;
|
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
EXTRA_LDFLAGS_FOR_TARGET = let
|
2020-04-24 23:36:52 +00:00
|
|
|
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
|
2022-11-21 17:40:18 +00:00
|
|
|
++ lib.optionals (!crossStageStatic) (mkFlags (threadsCross.package or null))
|
2020-04-24 23:36:52 +00:00
|
|
|
;
|
|
|
|
}
|