2015-01-09 19:22:12 +00:00
|
|
|
|
# The Nixpkgs CC is not directly usable, since it doesn't know where
|
2014-10-10 11:49:26 +00:00
|
|
|
|
# the C library and standard header files are. Therefore the compiler
|
|
|
|
|
# produced by that package cannot be installed directly in a user
|
|
|
|
|
# environment and used from the command line. So we use a wrapper
|
|
|
|
|
# script that sets up the right environment variables so that the
|
|
|
|
|
# compiler and the linker just "work".
|
2008-06-26 11:07:46 +00:00
|
|
|
|
|
2018-02-01 00:00:00 +00:00
|
|
|
|
{ name ? ""
|
2021-01-24 03:02:59 +00:00
|
|
|
|
, lib
|
2018-09-05 18:33:56 +00:00
|
|
|
|
, stdenvNoCC
|
2017-08-26 15:43:30 +00:00
|
|
|
|
, cc ? null, libc ? null, bintools, coreutils ? null, shell ? stdenvNoCC.shell
|
2020-06-17 20:33:56 +00:00
|
|
|
|
, gccForLibs ? null
|
2019-09-20 10:05:57 +00:00
|
|
|
|
, zlib ? null
|
2018-09-05 18:33:56 +00:00
|
|
|
|
, nativeTools, noLibc ? false, nativeLibc, nativePrefix ? ""
|
|
|
|
|
, propagateDoc ? cc != null && cc ? man
|
2020-03-18 15:28:52 +00:00
|
|
|
|
, extraTools ? [], extraPackages ? [], extraBuildCommands ? ""
|
2022-04-30 02:54:03 +00:00
|
|
|
|
, nixSupport ? {}
|
2018-05-24 21:43:31 +00:00
|
|
|
|
, isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
|
2017-08-21 22:26:08 +00:00
|
|
|
|
, buildPackages ? {}
|
2019-01-26 15:17:57 +00:00
|
|
|
|
, libcxx ? null
|
2008-06-26 11:07:46 +00:00
|
|
|
|
}:
|
|
|
|
|
|
2021-01-24 03:02:59 +00:00
|
|
|
|
with lib;
|
2014-10-10 11:49:26 +00:00
|
|
|
|
|
2018-02-01 00:00:00 +00:00
|
|
|
|
assert nativeTools -> !propagateDoc && nativePrefix != "";
|
2015-12-17 22:02:40 +00:00
|
|
|
|
assert !nativeTools ->
|
2017-08-26 15:43:30 +00:00
|
|
|
|
cc != null && coreutils != null && gnugrep != null;
|
2017-05-23 00:59:39 +00:00
|
|
|
|
assert !(nativeLibc && noLibc);
|
|
|
|
|
assert (noLibc || nativeLibc) == (libc == null);
|
2008-06-26 11:07:46 +00:00
|
|
|
|
|
2009-04-09 15:24:33 +00:00
|
|
|
|
let
|
2017-09-20 15:07:52 +00:00
|
|
|
|
stdenv = stdenvNoCC;
|
2017-07-06 01:47:48 +00:00
|
|
|
|
inherit (stdenv) hostPlatform targetPlatform;
|
|
|
|
|
|
2017-02-13 23:01:04 +00:00
|
|
|
|
# Prefix for binaries. Customarily ends with a dash separator.
|
|
|
|
|
#
|
|
|
|
|
# TODO(@Ericson2314) Make unconditional, or optional but always true by
|
|
|
|
|
# default.
|
2021-01-24 03:02:59 +00:00
|
|
|
|
targetPrefix = lib.optionalString (targetPlatform != hostPlatform)
|
2017-11-25 18:43:57 +00:00
|
|
|
|
(targetPlatform.config + "-");
|
2009-04-09 15:24:33 +00:00
|
|
|
|
|
2021-01-24 03:02:59 +00:00
|
|
|
|
ccVersion = lib.getVersion cc;
|
|
|
|
|
ccName = lib.removePrefix targetPrefix (lib.getName cc);
|
2012-08-03 17:23:51 +00:00
|
|
|
|
|
2017-05-23 00:59:39 +00:00
|
|
|
|
libc_bin = if libc == null then null else getBin libc;
|
|
|
|
|
libc_dev = if libc == null then null else getDev libc;
|
|
|
|
|
libc_lib = if libc == null then null else getLib libc;
|
2019-08-12 22:59:01 +00:00
|
|
|
|
cc_solib = getLib cc
|
|
|
|
|
+ optionalString (targetPlatform != hostPlatform) "/${targetPlatform.config}";
|
|
|
|
|
|
2016-02-03 15:54:03 +00:00
|
|
|
|
# The wrapper scripts use 'cat' and 'grep', so we may need coreutils.
|
2016-04-14 16:00:39 +00:00
|
|
|
|
coreutils_bin = if nativeTools then "" else getBin coreutils;
|
2017-06-08 18:00:40 +00:00
|
|
|
|
|
2020-04-28 04:08:48 +00:00
|
|
|
|
# The "suffix salt" is a arbitrary string added in the end of env vars
|
2017-06-26 04:43:06 +00:00
|
|
|
|
# defined by cc-wrapper's hooks so that multiple cc-wrappers can be used
|
|
|
|
|
# without interfering. For the moment, it is defined as the target triple,
|
|
|
|
|
# adjusted to be a valid bash identifier. This should be considered an
|
|
|
|
|
# unstable implementation detail, however.
|
2020-04-28 04:08:48 +00:00
|
|
|
|
suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config;
|
2017-06-19 15:10:27 +00:00
|
|
|
|
|
2017-08-23 20:23:30 +00:00
|
|
|
|
expand-response-params =
|
2020-08-22 03:20:10 +00:00
|
|
|
|
if (buildPackages.stdenv.hasCC or false) && buildPackages.stdenv.cc != "/dev/null"
|
2017-08-23 20:23:30 +00:00
|
|
|
|
then import ../expand-response-params { inherit (buildPackages) stdenv; }
|
|
|
|
|
else "";
|
2017-06-29 16:06:55 +00:00
|
|
|
|
|
2020-09-07 19:08:11 +00:00
|
|
|
|
useGccForLibs = isClang
|
|
|
|
|
&& libcxx == null
|
2021-05-01 03:03:19 +00:00
|
|
|
|
&& !stdenv.targetPlatform.isDarwin
|
2020-09-07 19:08:11 +00:00
|
|
|
|
&& !(stdenv.targetPlatform.useLLVM or false)
|
|
|
|
|
&& !(stdenv.targetPlatform.useAndroidPrebuilt or false)
|
2021-01-20 18:14:46 +00:00
|
|
|
|
&& !(stdenv.targetPlatform.isiOS or false)
|
2020-09-07 19:08:11 +00:00
|
|
|
|
&& gccForLibs != null;
|
|
|
|
|
|
2019-04-21 16:13:37 +00:00
|
|
|
|
# older compilers (for example bootstrap's GCC 5) fail with -march=too-modern-cpu
|
|
|
|
|
isGccArchSupported = arch:
|
2020-04-14 00:44:43 +00:00
|
|
|
|
if isGNU then
|
2019-05-05 23:40:20 +00:00
|
|
|
|
{ # Intel
|
|
|
|
|
skylake = versionAtLeast ccVersion "6.0";
|
2019-04-21 16:13:37 +00:00
|
|
|
|
skylake-avx512 = versionAtLeast ccVersion "6.0";
|
|
|
|
|
cannonlake = versionAtLeast ccVersion "8.0";
|
|
|
|
|
icelake-client = versionAtLeast ccVersion "8.0";
|
|
|
|
|
icelake-server = versionAtLeast ccVersion "8.0";
|
2020-12-24 00:02:10 +00:00
|
|
|
|
cascadelake = versionAtLeast ccVersion "9.0";
|
|
|
|
|
cooperlake = versionAtLeast ccVersion "10.0";
|
|
|
|
|
tigerlake = versionAtLeast ccVersion "10.0";
|
2019-04-21 16:13:37 +00:00
|
|
|
|
knm = versionAtLeast ccVersion "8.0";
|
2019-05-05 23:40:20 +00:00
|
|
|
|
# AMD
|
|
|
|
|
znver1 = versionAtLeast ccVersion "6.0";
|
2020-08-05 02:32:41 +00:00
|
|
|
|
znver2 = versionAtLeast ccVersion "9.0";
|
2020-12-24 00:02:10 +00:00
|
|
|
|
znver3 = versionAtLeast ccVersion "11.0";
|
2019-04-21 16:13:37 +00:00
|
|
|
|
}.${arch} or true
|
2020-04-14 00:44:43 +00:00
|
|
|
|
else if isClang then
|
2019-05-05 23:40:20 +00:00
|
|
|
|
{ # Intel
|
|
|
|
|
cannonlake = versionAtLeast ccVersion "5.0";
|
2019-04-21 16:13:37 +00:00
|
|
|
|
icelake-client = versionAtLeast ccVersion "7.0";
|
|
|
|
|
icelake-server = versionAtLeast ccVersion "7.0";
|
|
|
|
|
knm = versionAtLeast ccVersion "7.0";
|
2019-05-05 23:40:20 +00:00
|
|
|
|
# AMD
|
|
|
|
|
znver1 = versionAtLeast ccVersion "4.0";
|
2020-08-05 02:32:41 +00:00
|
|
|
|
znver2 = versionAtLeast ccVersion "9.0";
|
2019-04-21 16:13:37 +00:00
|
|
|
|
}.${arch} or true
|
|
|
|
|
else
|
|
|
|
|
false;
|
|
|
|
|
|
2021-04-10 04:11:28 +00:00
|
|
|
|
|
|
|
|
|
darwinPlatformForCC = optionalString stdenv.targetPlatform.isDarwin (
|
|
|
|
|
if (targetPlatform.darwinPlatform == "macos" && isGNU) then "macosx"
|
|
|
|
|
else targetPlatform.darwinPlatform
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
darwinMinVersion = optionalString stdenv.targetPlatform.isDarwin (
|
|
|
|
|
stdenv.targetPlatform.darwinMinVersion
|
|
|
|
|
);
|
2021-04-10 09:06:25 +00:00
|
|
|
|
|
|
|
|
|
darwinMinVersionVariable = optionalString stdenv.targetPlatform.isDarwin
|
|
|
|
|
stdenv.targetPlatform.darwinMinVersionVariable;
|
2009-04-09 15:24:33 +00:00
|
|
|
|
in
|
2009-03-25 17:34:38 +00:00
|
|
|
|
|
2017-08-28 18:56:08 +00:00
|
|
|
|
# Ensure bintools matches
|
|
|
|
|
assert libc_bin == bintools.libc_bin;
|
|
|
|
|
assert libc_dev == bintools.libc_dev;
|
|
|
|
|
assert libc_lib == bintools.libc_lib;
|
|
|
|
|
assert nativeTools == bintools.nativeTools;
|
|
|
|
|
assert nativeLibc == bintools.nativeLibc;
|
|
|
|
|
assert nativePrefix == bintools.nativePrefix;
|
|
|
|
|
|
2012-12-29 14:11:32 +00:00
|
|
|
|
stdenv.mkDerivation {
|
2019-06-24 00:42:48 +00:00
|
|
|
|
pname = targetPrefix
|
|
|
|
|
+ (if name != "" then name else "${ccName}-wrapper");
|
|
|
|
|
version = if cc == null then null else ccVersion;
|
2014-02-04 15:58:12 +00:00
|
|
|
|
|
2014-10-10 11:49:26 +00:00
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
|
2017-08-28 18:56:08 +00:00
|
|
|
|
inherit cc libc_bin libc_dev libc_lib bintools coreutils_bin;
|
2018-09-04 21:13:00 +00:00
|
|
|
|
shell = getBin shell + shell.shellPath or "";
|
2016-02-01 13:42:33 +00:00
|
|
|
|
gnugrep_bin = if nativeTools then "" else gnugrep;
|
2014-02-04 15:58:12 +00:00
|
|
|
|
|
2020-04-28 04:08:48 +00:00
|
|
|
|
inherit targetPrefix suffixSalt;
|
2021-04-10 09:06:25 +00:00
|
|
|
|
inherit darwinPlatformForCC darwinMinVersion darwinMinVersionVariable;
|
2017-06-08 18:00:40 +00:00
|
|
|
|
|
2018-02-01 00:00:00 +00:00
|
|
|
|
outputs = [ "out" ] ++ optionals propagateDoc [ "man" "info" ];
|
2017-06-08 18:00:40 +00:00
|
|
|
|
|
2016-10-07 14:31:37 +00:00
|
|
|
|
passthru = {
|
2017-10-10 23:01:42 +00:00
|
|
|
|
# "cc" is the generic name for a C compiler, but there is no one for package
|
|
|
|
|
# providing the linker and related tools. The two we use now are GNU
|
2017-08-28 18:56:08 +00:00
|
|
|
|
# Binutils, and Apple's "cctools"; "bintools" as an attempt to find an
|
2017-10-10 23:01:42 +00:00
|
|
|
|
# unused middle-ground name that evokes both.
|
2017-08-28 18:56:08 +00:00
|
|
|
|
inherit bintools;
|
2022-05-18 11:50:23 +00:00
|
|
|
|
inherit libc nativeTools nativeLibc nativePrefix isGNU isClang;
|
2016-10-07 14:31:37 +00:00
|
|
|
|
|
|
|
|
|
emacsBufferSetup = pkgs: ''
|
|
|
|
|
; We should handle propagation here too
|
2017-08-28 18:56:08 +00:00
|
|
|
|
(mapc
|
|
|
|
|
(lambda (arg)
|
|
|
|
|
(when (file-directory-p (concat arg "/include"))
|
2020-04-28 04:08:48 +00:00
|
|
|
|
(setenv "NIX_CFLAGS_COMPILE_${suffixSalt}" (concat (getenv "NIX_CFLAGS_COMPILE_${suffixSalt}") " -isystem " arg "/include"))))
|
2017-08-28 18:56:08 +00:00
|
|
|
|
'(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)}))
|
2016-10-07 14:31:37 +00:00
|
|
|
|
'';
|
2022-04-30 02:54:03 +00:00
|
|
|
|
|
2022-07-31 15:26:35 +00:00
|
|
|
|
inherit expand-response-params;
|
|
|
|
|
|
2022-04-30 02:54:03 +00:00
|
|
|
|
inherit nixSupport;
|
2016-10-07 14:31:37 +00:00
|
|
|
|
};
|
2014-10-10 11:49:26 +00:00
|
|
|
|
|
2017-08-23 20:55:55 +00:00
|
|
|
|
dontBuild = true;
|
|
|
|
|
dontConfigure = true;
|
2022-05-14 01:13:49 +00:00
|
|
|
|
enableParallelBuilding = true;
|
2017-08-23 20:55:55 +00:00
|
|
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
|
src=$PWD
|
|
|
|
|
'';
|
|
|
|
|
|
2019-11-27 19:15:56 +00:00
|
|
|
|
wrapper = ./cc-wrapper.sh;
|
|
|
|
|
|
2017-08-23 20:55:55 +00:00
|
|
|
|
installPhase =
|
2014-10-10 11:49:26 +00:00
|
|
|
|
''
|
2018-02-01 00:00:00 +00:00
|
|
|
|
mkdir -p $out/bin $out/nix-support
|
2014-10-10 11:49:26 +00:00
|
|
|
|
|
|
|
|
|
wrap() {
|
|
|
|
|
local dst="$1"
|
|
|
|
|
local wrapper="$2"
|
|
|
|
|
export prog="$3"
|
2021-02-09 01:46:47 +00:00
|
|
|
|
export use_response_file_by_default=${if isClang then "1" else "0"}
|
2014-10-10 11:49:26 +00:00
|
|
|
|
substituteAll "$wrapper" "$out/bin/$dst"
|
|
|
|
|
chmod +x "$out/bin/$dst"
|
|
|
|
|
}
|
|
|
|
|
''
|
|
|
|
|
|
|
|
|
|
+ (if nativeTools then ''
|
2017-08-23 20:55:55 +00:00
|
|
|
|
echo ${if targetPlatform.isDarwin then cc else nativePrefix} > $out/nix-support/orig-cc
|
|
|
|
|
|
2017-05-21 18:51:02 +00:00
|
|
|
|
ccPath="${if targetPlatform.isDarwin then cc else nativePrefix}/bin"
|
2014-10-10 11:49:26 +00:00
|
|
|
|
'' else ''
|
2015-01-09 19:22:12 +00:00
|
|
|
|
echo $cc > $out/nix-support/orig-cc
|
2014-10-10 11:49:26 +00:00
|
|
|
|
|
2016-01-02 10:14:09 +00:00
|
|
|
|
ccPath="${cc}/bin"
|
2014-10-10 11:49:26 +00:00
|
|
|
|
'')
|
|
|
|
|
|
2020-06-30 15:04:10 +00:00
|
|
|
|
# Create symlinks to everything in the bintools wrapper.
|
2014-10-10 11:49:26 +00:00
|
|
|
|
+ ''
|
2017-08-28 18:56:08 +00:00
|
|
|
|
for bbin in $bintools/bin/*; do
|
|
|
|
|
mkdir -p "$out/bin"
|
|
|
|
|
ln -s "$bbin" "$out/bin/$(basename $bbin)"
|
|
|
|
|
done
|
2020-06-30 15:04:10 +00:00
|
|
|
|
''
|
2014-10-10 12:01:38 +00:00
|
|
|
|
|
2020-06-30 15:04:10 +00:00
|
|
|
|
# We export environment variables pointing to the wrapped nonstandard
|
|
|
|
|
# cmds, lest some lousy configure script use those to guess compiler
|
|
|
|
|
# version.
|
|
|
|
|
+ ''
|
2017-11-25 18:43:57 +00:00
|
|
|
|
export named_cc=${targetPrefix}cc
|
|
|
|
|
export named_cxx=${targetPrefix}c++
|
2017-06-26 05:17:09 +00:00
|
|
|
|
|
2017-11-25 18:43:57 +00:00
|
|
|
|
if [ -e $ccPath/${targetPrefix}gcc ]; then
|
2019-11-27 19:15:56 +00:00
|
|
|
|
wrap ${targetPrefix}gcc $wrapper $ccPath/${targetPrefix}gcc
|
2017-11-25 18:43:57 +00:00
|
|
|
|
ln -s ${targetPrefix}gcc $out/bin/${targetPrefix}cc
|
|
|
|
|
export named_cc=${targetPrefix}gcc
|
|
|
|
|
export named_cxx=${targetPrefix}g++
|
2015-01-09 19:22:12 +00:00
|
|
|
|
elif [ -e $ccPath/clang ]; then
|
2019-11-27 19:15:56 +00:00
|
|
|
|
wrap ${targetPrefix}clang $wrapper $ccPath/clang
|
2017-11-25 18:43:57 +00:00
|
|
|
|
ln -s ${targetPrefix}clang $out/bin/${targetPrefix}cc
|
|
|
|
|
export named_cc=${targetPrefix}clang
|
|
|
|
|
export named_cxx=${targetPrefix}clang++
|
2014-10-10 11:49:26 +00:00
|
|
|
|
fi
|
|
|
|
|
|
2017-11-25 18:43:57 +00:00
|
|
|
|
if [ -e $ccPath/${targetPrefix}g++ ]; then
|
2019-11-27 19:15:56 +00:00
|
|
|
|
wrap ${targetPrefix}g++ $wrapper $ccPath/${targetPrefix}g++
|
2017-11-25 18:43:57 +00:00
|
|
|
|
ln -s ${targetPrefix}g++ $out/bin/${targetPrefix}c++
|
2015-01-09 19:22:12 +00:00
|
|
|
|
elif [ -e $ccPath/clang++ ]; then
|
2019-11-27 19:15:56 +00:00
|
|
|
|
wrap ${targetPrefix}clang++ $wrapper $ccPath/clang++
|
2017-11-25 18:43:57 +00:00
|
|
|
|
ln -s ${targetPrefix}clang++ $out/bin/${targetPrefix}c++
|
2014-10-10 13:48:34 +00:00
|
|
|
|
fi
|
|
|
|
|
|
2015-01-09 19:22:12 +00:00
|
|
|
|
if [ -e $ccPath/cpp ]; then
|
2019-11-27 19:15:56 +00:00
|
|
|
|
wrap ${targetPrefix}cpp $wrapper $ccPath/cpp
|
2014-10-10 11:49:26 +00:00
|
|
|
|
fi
|
|
|
|
|
''
|
|
|
|
|
|
2019-05-11 21:16:17 +00:00
|
|
|
|
+ optionalString cc.langAda or false ''
|
|
|
|
|
wrap ${targetPrefix}gnatmake ${./gnat-wrapper.sh} $ccPath/${targetPrefix}gnatmake
|
|
|
|
|
wrap ${targetPrefix}gnatbind ${./gnat-wrapper.sh} $ccPath/${targetPrefix}gnatbind
|
|
|
|
|
wrap ${targetPrefix}gnatlink ${./gnat-wrapper.sh} $ccPath/${targetPrefix}gnatlink
|
gprbuild, xmlada: init at 21.0.0
GPRbuild is a multi language build system developed by AdaCore which
is mostly used for build Ada-related projects using GNAT.
Since GPRbuild is used to build itself and its dependency library
XML/Ada we first build a bootstrap version of it using the provided
bash build script bootstrap.sh as the gprbuild-boot derivation.
gprbuild-boot is then used to build xmlada and the proper gprbuild
derivation.
GPRbuild has its own search path mechanism via GPR_PROJECT_PATH which
we address via a setupHook. It currently works quite similar to the
pkg-config one: It accumulates all inputs into GPR_PROJECT_PATH,
GPR_PROJECT_PATH_FOR_BUILD etc. However this is quite limited at the
moment as we don't have a gprbuild wrapper yet which understands the
_FOR_BUILD suffix. However, we'll need to address this in the future
as it is currently basically impossible to test since the distinction
only affects cross-compilation, but it is not possible to build a GNAT
cross-compiler in nixpkgs at the moment (I'm working on changing that,
however).
Another issue we had to solve was GPRbuild not finding the right GNAT
via its gprconfig tool: GPRbuild has a knowledge base with compiler
definitions which run some checks and collect info about binaries
which are in PATH. In the end the first compiler in PATH that supports
the desired language is selected.
We want GPRbuild to discover our wrapped GNAT since the unwrapped one
is incapable of producing working binaries since it won't find the
crt*.o objects distributed with libc. GPRbuild however needs to find
the Ada runtime distributed with GNAT which is not part of the wrapper
derivation, so it will skip the wrapper and select the unwrapped GNAT.
Symlinking the unwrapped's lib directory into the wrapper fixes this
problem, but breaks linking in some cases (e. g. when linking against
OMP from gcc, the runtime variant will shadow the problem dynamic lib
from buildInputs). Additionally it uses gnatls as an indicator it has
found GNAT which is not part of the wrapper.
The solution we opted to adopt here is to install a custom compiler
description into gprbuild's knowledge base which properly detects the
nixpkgs GNAT wrapper: It uses gnatmake to detect GNAT instead of
gnatls and discovers the runtime via a symlink we add to
`$out/nix-support`. This additional definition is enough to properly
detect GNAT, since the plain wrapped gcc detection works out of the
box. It may, however, be necessary to add special definitions for
other languages in the future where gprbuild also needs to discover
the runtime.
One future improvement would be to install libgpr into a separate
output or split it into a separate derivation (which would require to
link gprbuild statically always since otherwise we end up with a
cyclical dependency).
2021-07-22 11:52:40 +00:00
|
|
|
|
|
|
|
|
|
# this symlink points to the unwrapped gnat's output "out". It is used by
|
|
|
|
|
# our custom gprconfig compiler description to find GNAT's ada runtime. See
|
|
|
|
|
# ../../development/tools/build-managers/gprbuild/{boot.nix, nixpkgs-gnat.xml}
|
|
|
|
|
ln -sf ${cc} $out/nix-support/gprconfig-gnat-unwrapped
|
2019-05-11 21:16:17 +00:00
|
|
|
|
''
|
|
|
|
|
|
2019-09-20 10:05:57 +00:00
|
|
|
|
+ optionalString cc.langD or false ''
|
|
|
|
|
wrap ${targetPrefix}gdc $wrapper $ccPath/${targetPrefix}gdc
|
|
|
|
|
''
|
|
|
|
|
|
2022-08-19 07:08:11 +00:00
|
|
|
|
+ optionalString cc.langFortran or false ''
|
2019-11-27 19:15:56 +00:00
|
|
|
|
wrap ${targetPrefix}gfortran $wrapper $ccPath/${targetPrefix}gfortran
|
2017-11-25 18:43:57 +00:00
|
|
|
|
ln -sv ${targetPrefix}gfortran $out/bin/${targetPrefix}g77
|
|
|
|
|
ln -sv ${targetPrefix}gfortran $out/bin/${targetPrefix}f77
|
2020-07-06 04:22:19 +00:00
|
|
|
|
export named_fc=${targetPrefix}gfortran
|
2014-10-10 11:49:26 +00:00
|
|
|
|
''
|
|
|
|
|
|
2015-01-09 19:22:12 +00:00
|
|
|
|
+ optionalString cc.langJava or false ''
|
2019-11-27 19:15:56 +00:00
|
|
|
|
wrap ${targetPrefix}gcj $wrapper $ccPath/${targetPrefix}gcj
|
2014-10-10 11:49:26 +00:00
|
|
|
|
''
|
|
|
|
|
|
2015-01-09 19:22:12 +00:00
|
|
|
|
+ optionalString cc.langGo or false ''
|
2019-11-27 19:15:56 +00:00
|
|
|
|
wrap ${targetPrefix}gccgo $wrapper $ccPath/${targetPrefix}gccgo
|
2017-08-23 20:55:55 +00:00
|
|
|
|
'';
|
|
|
|
|
|
2018-05-13 15:31:24 +00:00
|
|
|
|
strictDeps = true;
|
2019-09-20 10:05:57 +00:00
|
|
|
|
propagatedBuildInputs = [ bintools ] ++ extraTools ++ optionals cc.langD or false [ zlib ];
|
2020-04-14 00:44:43 +00:00
|
|
|
|
depsTargetTargetPropagated = optional (libcxx != null) libcxx ++ extraPackages;
|
2017-08-23 20:55:55 +00:00
|
|
|
|
|
2018-05-07 17:07:19 +00:00
|
|
|
|
wrapperName = "CC_WRAPPER";
|
|
|
|
|
|
|
|
|
|
setupHooks = [
|
|
|
|
|
../setup-hooks/role.bash
|
2022-10-28 08:28:12 +00:00
|
|
|
|
] ++ lib.optional (cc.langC or true) ./setup-hook.sh
|
2021-01-24 03:02:59 +00:00
|
|
|
|
++ lib.optional (cc.langFortran or false) ./fortran-hook.sh;
|
2017-08-23 20:55:55 +00:00
|
|
|
|
|
|
|
|
|
postFixup =
|
2020-06-30 18:26:37 +00:00
|
|
|
|
# Ensure flags files exists, as some other programs cat them. (That these
|
|
|
|
|
# are considered an exposed interface is a bit dubious, but fine for now.)
|
|
|
|
|
''
|
|
|
|
|
touch "$out/nix-support/cc-cflags"
|
|
|
|
|
touch "$out/nix-support/cc-ldflags"
|
|
|
|
|
''
|
|
|
|
|
|
2020-06-30 15:04:10 +00:00
|
|
|
|
# Backwards compatability for packages expecting this file, e.g. with
|
|
|
|
|
# `$NIX_CC/nix-support/dynamic-linker`.
|
|
|
|
|
#
|
|
|
|
|
# TODO(@Ericson2314): Remove this after stable release and force
|
|
|
|
|
# everyone to refer to bintools-wrapper directly.
|
2020-06-30 18:26:37 +00:00
|
|
|
|
+ ''
|
2017-08-28 18:56:08 +00:00
|
|
|
|
if [[ -f "$bintools/nix-support/dynamic-linker" ]]; then
|
|
|
|
|
ln -s "$bintools/nix-support/dynamic-linker" "$out/nix-support"
|
|
|
|
|
fi
|
|
|
|
|
if [[ -f "$bintools/nix-support/dynamic-linker-m32" ]]; then
|
|
|
|
|
ln -s "$bintools/nix-support/dynamic-linker-m32" "$out/nix-support"
|
|
|
|
|
fi
|
2017-08-23 20:55:55 +00:00
|
|
|
|
''
|
|
|
|
|
|
2020-06-30 15:04:10 +00:00
|
|
|
|
##
|
|
|
|
|
## GCC libs for non-GCC support
|
|
|
|
|
##
|
2020-09-07 19:08:11 +00:00
|
|
|
|
+ optionalString useGccForLibs ''
|
2020-04-14 00:44:43 +00:00
|
|
|
|
|
2020-06-17 20:33:56 +00:00
|
|
|
|
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
|
2020-04-14 00:44:43 +00:00
|
|
|
|
''
|
|
|
|
|
|
2021-01-20 23:45:52 +00:00
|
|
|
|
# TODO We would like to connect this to `useGccForLibs`, but we cannot yet
|
|
|
|
|
# because `libcxxStdenv` on linux still needs this. Maybe someday we'll
|
|
|
|
|
# always set `useLLVM` on Darwin, and maybe also break down `useLLVM` into
|
|
|
|
|
# fine-grained use flags (libgcc vs compiler-rt, ld.lld vs legacy, libc++
|
|
|
|
|
# vs libstdc++, etc.) since Darwin isn't `useLLVM` on all counts. (See
|
|
|
|
|
# https://clang.llvm.org/docs/Toolchain.html for all the axes one might
|
|
|
|
|
# break `useLLVM` into.)
|
2021-04-10 17:39:07 +00:00
|
|
|
|
+ optionalString (isClang
|
2021-02-10 18:38:17 +00:00
|
|
|
|
&& targetPlatform.isLinux
|
|
|
|
|
&& !(stdenv.targetPlatform.useAndroidPrebuilt or false)
|
2021-04-10 17:39:07 +00:00
|
|
|
|
&& !(stdenv.targetPlatform.useLLVM or false)
|
|
|
|
|
&& gccForLibs != null) ''
|
2021-01-20 23:45:52 +00:00
|
|
|
|
echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
|
|
|
|
|
''
|
|
|
|
|
|
2020-06-30 15:04:10 +00:00
|
|
|
|
##
|
|
|
|
|
## General libc support
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
# The "-B${libc_lib}/lib/" flag is a quick hack to force gcc to link
|
|
|
|
|
# against the crt1.o from our own glibc, rather than the one in
|
|
|
|
|
# /usr/lib. (This is only an issue when using an `impure'
|
|
|
|
|
# compiler/linker, i.e., one that searches /usr/lib and so on.)
|
|
|
|
|
#
|
|
|
|
|
# Unfortunately, setting -B appears to override the default search
|
|
|
|
|
# path. Thus, the gcc-specific "../includes-fixed" directory is
|
|
|
|
|
# now longer searched and glibc's <limits.h> header fails to
|
|
|
|
|
# compile, because it uses "#include_next <limits.h>" to find the
|
|
|
|
|
# limits.h file in ../includes-fixed. To remedy the problem,
|
|
|
|
|
# another -idirafter is necessary to add that directory again.
|
2019-11-26 00:55:16 +00:00
|
|
|
|
+ optionalString (libc != null) (''
|
2020-06-30 18:26:37 +00:00
|
|
|
|
touch "$out/nix-support/libc-cflags"
|
|
|
|
|
touch "$out/nix-support/libc-ldflags"
|
2020-07-01 20:55:06 +00:00
|
|
|
|
echo "-B${libc_lib}${libc.libdir or "/lib/"}" >> $out/nix-support/libc-crt1-cflags
|
2019-09-20 10:05:57 +00:00
|
|
|
|
'' + optionalString (!(cc.langD or false)) ''
|
2019-11-26 00:55:16 +00:00
|
|
|
|
echo "-idirafter ${libc_dev}${libc.incdir or "/include"}" >> $out/nix-support/libc-cflags
|
2019-09-20 10:05:57 +00:00
|
|
|
|
'' + optionalString (isGNU && (!(cc.langD or false))) ''
|
2019-11-26 00:55:16 +00:00
|
|
|
|
for dir in "${cc}"/lib/gcc/*/*/include-fixed; do
|
|
|
|
|
echo '-idirafter' ''${dir} >> $out/nix-support/libc-cflags
|
|
|
|
|
done
|
|
|
|
|
'' + ''
|
2017-08-23 20:55:55 +00:00
|
|
|
|
|
|
|
|
|
echo "${libc_lib}" > $out/nix-support/orig-libc
|
|
|
|
|
echo "${libc_dev}" > $out/nix-support/orig-libc-dev
|
2019-11-26 00:55:16 +00:00
|
|
|
|
'')
|
2017-08-23 20:55:55 +00:00
|
|
|
|
|
2020-06-30 15:04:10 +00:00
|
|
|
|
##
|
|
|
|
|
## General libc++ support
|
|
|
|
|
##
|
2020-06-30 18:26:37 +00:00
|
|
|
|
|
|
|
|
|
# We have a libc++ directly, we have one via "smuggled" GCC, or we have one
|
|
|
|
|
# bundled with the C compiler because it is GCC
|
2020-09-07 19:08:11 +00:00
|
|
|
|
+ optionalString (libcxx != null || (useGccForLibs && gccForLibs.langCC or false) || (isGNU && cc.langCC or false)) ''
|
2020-06-30 18:26:37 +00:00
|
|
|
|
touch "$out/nix-support/libcxx-cxxflags"
|
|
|
|
|
touch "$out/nix-support/libcxx-ldflags"
|
2020-06-17 20:33:56 +00:00
|
|
|
|
''
|
2020-09-07 19:08:11 +00:00
|
|
|
|
+ optionalString (libcxx == null && (useGccForLibs && gccForLibs.langCC or false)) ''
|
2022-11-21 12:40:22 +00:00
|
|
|
|
for dir in ${gccForLibs}${lib.optionalString (hostPlatform != targetPlatform) "/${targetPlatform.config}"}/include/c++/*; do
|
2020-04-14 00:44:43 +00:00
|
|
|
|
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
|
|
|
|
|
done
|
2022-11-21 12:40:22 +00:00
|
|
|
|
for dir in ${gccForLibs}${lib.optionalString (hostPlatform != targetPlatform) "/${targetPlatform.config}"}/include/c++/*/${targetPlatform.config}; do
|
2020-04-14 00:44:43 +00:00
|
|
|
|
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
|
|
|
|
|
done
|
|
|
|
|
''
|
|
|
|
|
+ optionalString (libcxx.isLLVM or false) (''
|
llvmPackages: Multuple outputs for everythting
Also begin to start work on cross compilation, though that will have to
be finished later.
The patches are based on the first version of
https://reviews.llvm.org/D99484. It's very annoying to do the
back-porting but the review has uncovered nothing super major so I'm
fine sticking with what I've got.
Beyond making the outputs work, I also strove to re-sync the packages,
as they have been drifting pointlessly apart for some time.
----
Other misc notes, highly incomplete
- lvm-config-native and llvm-config are put in `dev` because they are
tools just for build time.
- Clang no longer has an lld dep. That was introduced in
db29857eb391ed002046090851a44c452b80bdbd, but if clang needs help
finding lld when it is used we should just pass it flags / put in the
resource dir. Providing it at build time increases critical path
length for no good reason.
----
A note on `nativeCC`:
`stdenv` takes tools from the previous stage, so:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.stdenv.cc`: `(?0, ?1, x)`
while:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.targetPackages`: `(x, x, ?2)`
3. `pkgsBuildBuild.targetPackages.stdenv.cc`: `(?1, x, x)`
2020-10-15 08:23:57 +00:00
|
|
|
|
echo "-isystem ${lib.getDev libcxx}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags
|
2020-04-14 00:44:43 +00:00
|
|
|
|
echo "-stdlib=libc++" >> $out/nix-support/libcxx-ldflags
|
|
|
|
|
echo "-lc++abi" >> $out/nix-support/libcxx-ldflags
|
|
|
|
|
'')
|
|
|
|
|
|
2020-06-30 15:04:10 +00:00
|
|
|
|
##
|
|
|
|
|
## Initial CFLAGS
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
# GCC shows ${cc_solib}/lib in `gcc -print-search-dirs', but not
|
|
|
|
|
# ${cc_solib}/lib64 (even though it does actually search there...)..
|
|
|
|
|
# This confuses libtool. So add it to the compiler tool search
|
|
|
|
|
# path explicitly.
|
2017-08-23 20:55:55 +00:00
|
|
|
|
+ optionalString (!nativeTools) ''
|
|
|
|
|
if [ -e "${cc_solib}/lib64" -a ! -L "${cc_solib}/lib64" ]; then
|
|
|
|
|
ccLDFlags+=" -L${cc_solib}/lib64"
|
|
|
|
|
ccCFlags+=" -B${cc_solib}/lib64"
|
|
|
|
|
fi
|
|
|
|
|
ccLDFlags+=" -L${cc_solib}/lib"
|
|
|
|
|
ccCFlags+=" -B${cc_solib}/lib"
|
|
|
|
|
|
2019-05-11 21:16:17 +00:00
|
|
|
|
'' + optionalString cc.langAda or false ''
|
2020-06-30 18:26:37 +00:00
|
|
|
|
touch "$out/nix-support/gnat-cflags"
|
|
|
|
|
touch "$out/nix-support/gnat-ldflags"
|
2019-05-11 21:16:17 +00:00
|
|
|
|
basePath=$(echo $cc/lib/*/*/*)
|
|
|
|
|
ccCFlags+=" -B$basePath -I$basePath/adainclude"
|
|
|
|
|
gnatCFlags="-I$basePath/adainclude -I$basePath/adalib"
|
|
|
|
|
|
2020-06-30 18:26:37 +00:00
|
|
|
|
echo "$gnatCFlags" >> $out/nix-support/gnat-cflags
|
2019-05-11 21:16:17 +00:00
|
|
|
|
'' + ''
|
2020-06-30 18:26:37 +00:00
|
|
|
|
echo "$ccLDFlags" >> $out/nix-support/cc-ldflags
|
|
|
|
|
echo "$ccCFlags" >> $out/nix-support/cc-cflags
|
2019-01-26 15:17:57 +00:00
|
|
|
|
'' + optionalString (targetPlatform.isDarwin && (libcxx != null) && (cc.isClang or false)) ''
|
llvmPackages: Multuple outputs for everythting
Also begin to start work on cross compilation, though that will have to
be finished later.
The patches are based on the first version of
https://reviews.llvm.org/D99484. It's very annoying to do the
back-porting but the review has uncovered nothing super major so I'm
fine sticking with what I've got.
Beyond making the outputs work, I also strove to re-sync the packages,
as they have been drifting pointlessly apart for some time.
----
Other misc notes, highly incomplete
- lvm-config-native and llvm-config are put in `dev` because they are
tools just for build time.
- Clang no longer has an lld dep. That was introduced in
db29857eb391ed002046090851a44c452b80bdbd, but if clang needs help
finding lld when it is used we should just pass it flags / put in the
resource dir. Providing it at build time increases critical path
length for no good reason.
----
A note on `nativeCC`:
`stdenv` takes tools from the previous stage, so:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.stdenv.cc`: `(?0, ?1, x)`
while:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.targetPackages`: `(x, x, ?2)`
3. `pkgsBuildBuild.targetPackages.stdenv.cc`: `(?1, x, x)`
2020-10-15 08:23:57 +00:00
|
|
|
|
echo " -L${lib.getLib libcxx}/lib" >> $out/nix-support/cc-ldflags
|
2020-06-30 15:04:10 +00:00
|
|
|
|
''
|
2017-08-23 20:55:55 +00:00
|
|
|
|
|
2020-06-30 15:04:10 +00:00
|
|
|
|
##
|
|
|
|
|
## Man page and info support
|
|
|
|
|
##
|
|
|
|
|
+ optionalString propagateDoc ''
|
2018-09-05 18:35:16 +00:00
|
|
|
|
ln -s ${cc.man} $man
|
|
|
|
|
ln -s ${cc.info} $info
|
2019-09-20 10:05:57 +00:00
|
|
|
|
'' + optionalString (cc.langD or false) ''
|
|
|
|
|
echo "-B${zlib}${zlib.libdir or "/lib/"}" >> $out/nix-support/libc-cflags
|
2014-10-10 11:49:26 +00:00
|
|
|
|
''
|
|
|
|
|
|
2020-06-30 15:04:10 +00:00
|
|
|
|
##
|
|
|
|
|
## Hardening support
|
|
|
|
|
##
|
2014-10-10 11:49:26 +00:00
|
|
|
|
+ ''
|
2017-09-16 21:54:17 +00:00
|
|
|
|
export hardening_unsupported_flags="${builtins.concatStringsSep " " (cc.hardeningUnsupportedFlags or [])}"
|
2017-06-20 18:04:24 +00:00
|
|
|
|
''
|
|
|
|
|
|
2019-04-09 18:21:54 +00:00
|
|
|
|
# Machine flags. These are necessary to support
|
2016-08-23 16:13:31 +00:00
|
|
|
|
|
2019-04-09 18:21:54 +00:00
|
|
|
|
# TODO: We should make a way to support miscellaneous machine
|
|
|
|
|
# flags and other gcc flags as well.
|
|
|
|
|
|
|
|
|
|
# Always add -march based on cpu in triple. Sometimes there is a
|
|
|
|
|
# discrepency (x86_64 vs. x86-64), so we provide an "arch" arg in
|
|
|
|
|
# that case.
|
2021-03-06 07:23:35 +00:00
|
|
|
|
# TODO: aarch64-darwin has mcpu incompatible with gcc
|
|
|
|
|
+ optionalString ((targetPlatform ? gcc.arch) && (isClang || !(stdenv.isDarwin && stdenv.isAarch64)) &&
|
2021-01-23 01:33:55 +00:00
|
|
|
|
isGccArchSupported targetPlatform.gcc.arch) ''
|
|
|
|
|
echo "-march=${targetPlatform.gcc.arch}" >> $out/nix-support/cc-cflags-before
|
2018-06-24 02:05:26 +00:00
|
|
|
|
''
|
|
|
|
|
|
2019-04-09 18:21:54 +00:00
|
|
|
|
# -mcpu is not very useful. You should use mtune and march
|
|
|
|
|
# instead. It’s provided here for backwards compatibility.
|
2021-03-06 07:23:35 +00:00
|
|
|
|
# TODO: aarch64-darwin has mcpu incompatible with gcc
|
|
|
|
|
+ optionalString ((targetPlatform ? gcc.cpu) && (isClang || !(stdenv.isDarwin && stdenv.isAarch64))) ''
|
2021-01-23 01:33:55 +00:00
|
|
|
|
echo "-mcpu=${targetPlatform.gcc.cpu}" >> $out/nix-support/cc-cflags-before
|
2018-10-15 21:11:20 +00:00
|
|
|
|
''
|
|
|
|
|
|
2019-04-09 18:21:54 +00:00
|
|
|
|
# -mfloat-abi only matters on arm32 but we set it here
|
|
|
|
|
# unconditionally just in case. If the abi specifically sets hard
|
|
|
|
|
# vs. soft floats we use it here.
|
2021-01-23 01:33:55 +00:00
|
|
|
|
+ optionalString (targetPlatform ? gcc.float-abi) ''
|
|
|
|
|
echo "-mfloat-abi=${targetPlatform.gcc.float-abi}" >> $out/nix-support/cc-cflags-before
|
2019-04-09 18:21:54 +00:00
|
|
|
|
''
|
2021-01-23 01:33:55 +00:00
|
|
|
|
+ optionalString (targetPlatform ? gcc.fpu) ''
|
|
|
|
|
echo "-mfpu=${targetPlatform.gcc.fpu}" >> $out/nix-support/cc-cflags-before
|
2019-04-09 18:21:54 +00:00
|
|
|
|
''
|
2021-01-23 01:33:55 +00:00
|
|
|
|
+ optionalString (targetPlatform ? gcc.mode) ''
|
|
|
|
|
echo "-mmode=${targetPlatform.gcc.mode}" >> $out/nix-support/cc-cflags-before
|
2019-04-09 18:21:54 +00:00
|
|
|
|
''
|
2021-09-17 17:12:54 +00:00
|
|
|
|
+ optionalString (targetPlatform ? gcc.thumb) ''
|
|
|
|
|
echo "-m${if targetPlatform.gcc.thumb then "thumb" else "arm"}" >> $out/nix-support/cc-cflags-before
|
|
|
|
|
''
|
2021-01-23 01:33:55 +00:00
|
|
|
|
+ optionalString (targetPlatform ? gcc.tune &&
|
|
|
|
|
isGccArchSupported targetPlatform.gcc.tune) ''
|
|
|
|
|
echo "-mtune=${targetPlatform.gcc.tune}" >> $out/nix-support/cc-cflags-before
|
2018-07-28 16:29:02 +00:00
|
|
|
|
''
|
|
|
|
|
|
2019-04-09 18:21:54 +00:00
|
|
|
|
# TODO: categorize these and figure out a better place for them
|
|
|
|
|
+ optionalString hostPlatform.isCygwin ''
|
|
|
|
|
hardening_unsupported_flags+=" pic"
|
|
|
|
|
'' + optionalString targetPlatform.isMinGW ''
|
2021-08-11 09:07:42 +00:00
|
|
|
|
hardening_unsupported_flags+=" stackprotector fortify"
|
2019-04-09 18:21:54 +00:00
|
|
|
|
'' + optionalString targetPlatform.isAvr ''
|
|
|
|
|
hardening_unsupported_flags+=" stackprotector pic"
|
2022-07-20 08:38:08 +00:00
|
|
|
|
'' + optionalString (targetPlatform.libc == "newlib" || targetPlatform.libc == "newlib-nano") ''
|
2018-10-15 21:11:20 +00:00
|
|
|
|
hardening_unsupported_flags+=" stackprotector fortify pie pic"
|
2019-06-07 22:40:28 +00:00
|
|
|
|
'' + optionalString (targetPlatform.libc == "musl" && targetPlatform.isx86_32) ''
|
2019-06-07 08:07:18 +00:00
|
|
|
|
hardening_unsupported_flags+=" stackprotector"
|
2019-06-07 22:40:28 +00:00
|
|
|
|
'' + optionalString targetPlatform.isNetBSD ''
|
2019-04-09 18:21:54 +00:00
|
|
|
|
hardening_unsupported_flags+=" stackprotector fortify"
|
2019-05-11 21:16:17 +00:00
|
|
|
|
'' + optionalString cc.langAda or false ''
|
2020-12-23 00:42:11 +00:00
|
|
|
|
hardening_unsupported_flags+=" format stackprotector strictoverflow"
|
2019-09-20 10:05:57 +00:00
|
|
|
|
'' + optionalString cc.langD or false ''
|
|
|
|
|
hardening_unsupported_flags+=" format"
|
2022-05-26 10:14:43 +00:00
|
|
|
|
'' + optionalString cc.langFortran or false ''
|
|
|
|
|
hardening_unsupported_flags+=" format"
|
2019-09-20 10:05:57 +00:00
|
|
|
|
'' + optionalString targetPlatform.isWasm ''
|
2019-01-30 02:01:24 +00:00
|
|
|
|
hardening_unsupported_flags+=" stackprotector fortify pie pic"
|
2022-06-20 07:57:03 +00:00
|
|
|
|
'' + optionalString targetPlatform.isMicroBlaze ''
|
|
|
|
|
hardening_unsupported_flags+=" stackprotector"
|
2019-01-30 02:01:24 +00:00
|
|
|
|
''
|
|
|
|
|
|
2018-10-15 21:11:20 +00:00
|
|
|
|
+ optionalString (libc != null && targetPlatform.isAvr) ''
|
|
|
|
|
for isa in avr5 avr3 avr4 avr6 avr25 avr31 avr35 avr51 avrxmega2 avrxmega4 avrxmega5 avrxmega6 avrxmega7 tiny-stack; do
|
2020-07-01 20:55:06 +00:00
|
|
|
|
echo "-B${getLib libc}/avr/lib/$isa" >> $out/nix-support/libc-crt1-cflags
|
2018-10-15 21:11:20 +00:00
|
|
|
|
done
|
|
|
|
|
''
|
|
|
|
|
|
2021-04-10 04:11:28 +00:00
|
|
|
|
+ optionalString stdenv.targetPlatform.isDarwin ''
|
|
|
|
|
echo "-arch ${targetPlatform.darwinArch}" >> $out/nix-support/cc-cflags
|
2021-05-06 04:15:34 +00:00
|
|
|
|
''
|
|
|
|
|
|
|
|
|
|
+ optionalString targetPlatform.isAndroid ''
|
|
|
|
|
echo "-D__ANDROID_API__=${targetPlatform.sdkVer}" >> $out/nix-support/cc-cflags
|
2021-04-10 04:11:28 +00:00
|
|
|
|
''
|
|
|
|
|
|
2020-02-27 15:39:35 +00:00
|
|
|
|
# There are a few tools (to name one libstdcxx5) which do not work
|
|
|
|
|
# well with multi line flags, so make the flags single line again
|
2017-06-20 18:04:24 +00:00
|
|
|
|
+ ''
|
2020-06-30 18:26:37 +00:00
|
|
|
|
for flags in "$out/nix-support"/*flags*; do
|
2020-04-14 00:44:43 +00:00
|
|
|
|
substituteInPlace "$flags" --replace $'\n' ' '
|
|
|
|
|
done
|
2020-02-27 15:39:35 +00:00
|
|
|
|
|
2017-06-26 04:43:06 +00:00
|
|
|
|
substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
|
|
|
|
|
substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh
|
2020-09-07 14:31:59 +00:00
|
|
|
|
substituteAll ${../wrapper-common/utils.bash} $out/nix-support/utils.bash
|
2015-07-20 11:42:30 +00:00
|
|
|
|
''
|
2018-02-01 00:00:00 +00:00
|
|
|
|
|
2022-06-13 18:24:52 +00:00
|
|
|
|
##
|
|
|
|
|
## General Clang support
|
|
|
|
|
## Needs to go after ^ because the for loop eats \n and makes this file an invalid script
|
|
|
|
|
##
|
|
|
|
|
+ optionalString isClang ''
|
|
|
|
|
export defaultTarget=${targetPlatform.config}
|
|
|
|
|
substituteAll ${./add-clang-cc-cflags-before.sh} $out/nix-support/add-local-cc-cflags-before.sh
|
|
|
|
|
''
|
|
|
|
|
|
2020-06-30 15:04:10 +00:00
|
|
|
|
##
|
|
|
|
|
## Extra custom steps
|
|
|
|
|
##
|
2022-04-30 02:54:03 +00:00
|
|
|
|
+ extraBuildCommands
|
|
|
|
|
+ lib.strings.concatStringsSep "; "
|
|
|
|
|
(lib.attrsets.mapAttrsToList
|
|
|
|
|
(name: value: "echo ${toString value} >> $out/nix-support/${name}")
|
|
|
|
|
nixSupport);
|
2014-10-10 11:49:26 +00:00
|
|
|
|
|
2017-07-01 00:27:48 +00:00
|
|
|
|
|
2018-05-07 17:15:34 +00:00
|
|
|
|
# for substitution in utils.bash
|
2017-08-23 20:39:15 +00:00
|
|
|
|
expandResponseParams = "${expand-response-params}/bin/expand-response-params";
|
2010-12-04 21:45:37 +00:00
|
|
|
|
|
2009-03-25 18:34:27 +00:00
|
|
|
|
meta =
|
2015-01-09 19:22:12 +00:00
|
|
|
|
let cc_ = if cc != null then cc else {}; in
|
|
|
|
|
(if cc_ ? meta then removeAttrs cc.meta ["priority"] else {}) //
|
2009-04-19 16:00:46 +00:00
|
|
|
|
{ description =
|
2021-01-24 03:02:59 +00:00
|
|
|
|
lib.attrByPath ["meta" "description"] "System C compiler" cc_
|
2009-04-19 16:00:46 +00:00
|
|
|
|
+ " (wrapper script)";
|
2019-02-01 01:07:55 +00:00
|
|
|
|
priority = 10;
|
2017-07-18 03:36:17 +00:00
|
|
|
|
};
|
2008-06-26 11:07:46 +00:00
|
|
|
|
}
|