diff options
author | Matthew Bauer <mjbauer95@gmail.com> | 2019-04-09 14:21:54 -0400 |
---|---|---|
committer | Matthew Bauer <mjbauer95@gmail.com> | 2019-04-20 20:05:51 -0400 |
commit | d180cb98503d2dc1e51d8c14b4a567e1ed3e996d (patch) | |
tree | 437b88033238e50b895fc19cbc5701527a3b5d43 /pkgs/build-support/cc-wrapper/add-flags.sh | |
parent | 799fa4d4044018f2e3a4f258942ae6d34a8d5c4d (diff) | |
download | nixpkgs-d180cb98503d2dc1e51d8c14b4a567e1ed3e996d.tar nixpkgs-d180cb98503d2dc1e51d8c14b4a567e1ed3e996d.tar.gz nixpkgs-d180cb98503d2dc1e51d8c14b4a567e1ed3e996d.tar.bz2 nixpkgs-d180cb98503d2dc1e51d8c14b4a567e1ed3e996d.tar.lz nixpkgs-d180cb98503d2dc1e51d8c14b4a567e1ed3e996d.tar.xz nixpkgs-d180cb98503d2dc1e51d8c14b4a567e1ed3e996d.tar.zst nixpkgs-d180cb98503d2dc1e51d8c14b4a567e1ed3e996d.zip |
cc-wrapper: make machine configuration configurable
It is useful to make these dynamic and not bake them into gcc. This means we don’t have to rebuild gcc to change these values. Instead, we will pass cflags to gcc based on platform values. This was already done hackily for android gcc (which is multi-target), but not for our own gccs which are single target. To accomplish this, we need to add a few things: - add ‘arch’ to cpu - add NIX_CFLAGS_COMPILE_BEFORE flag (goes before args) - set -march everywhere - set mcpu, mfpu, mmode, and mtune based on targetPlatform.gcc flags cc-wrapper: only set -march when it is in the cpu type Some architectures don’t have a good mapping of -march. For instance POWER architecture doesn’t support the -march flag at all! https://gcc.gnu.org/onlinedocs/gcc/RS_002f6000-and-PowerPC-Options.html#RS_002f6000-and-PowerPC-Options
Diffstat (limited to 'pkgs/build-support/cc-wrapper/add-flags.sh')
-rw-r--r-- | pkgs/build-support/cc-wrapper/add-flags.sh | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/pkgs/build-support/cc-wrapper/add-flags.sh b/pkgs/build-support/cc-wrapper/add-flags.sh index 9762894607a..1358b167f6e 100644 --- a/pkgs/build-support/cc-wrapper/add-flags.sh +++ b/pkgs/build-support/cc-wrapper/add-flags.sh @@ -6,6 +6,7 @@ var_templates_list=( NIX+CFLAGS_COMPILE + NIX+CFLAGS_COMPILE_BEFORE NIX+CFLAGS_LINK NIX+CXXSTDLIB_COMPILE NIX+CXXSTDLIB_LINK @@ -43,5 +44,9 @@ if [ -e @out@/nix-support/cc-ldflags ]; then NIX_@infixSalt@_LDFLAGS+=" $(< @out@/nix-support/cc-ldflags)" fi +if [ -e @out@/nix-support/cc-cflags-before ]; then + NIX_@infixSalt@_CFLAGS_COMPILE_BEFORE="$(< @out@/nix-support/cc-cflags-before) $NIX_@infixSalt@_CFLAGS_COMPILE_BEFORE" +fi + # That way forked processes will not extend these environment variables again. export NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET=1 |