mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-21 22:43:01 +00:00
cc-wrapper: Fix gnatmake wrapper
Switches that gnatmake needs to pass to gcc must be given as "-cargs <gcc_switches>" after at least the files to compile (see the gnatmake docs for all the subtleties). This commit makes that happen, in a way that triggers rebuilds only for things that actually depend on GNAT, and not the other compilers contained in GCC.
This commit is contained in:
parent
f061f3ead5
commit
c1308ac58c
23
pkgs/build-support/cc-wrapper/add-gnat-extra-flags.sh
Normal file
23
pkgs/build-support/cc-wrapper/add-gnat-extra-flags.sh
Normal file
@ -0,0 +1,23 @@
|
||||
# See add-flags.sh in cc-wrapper for comments.
|
||||
var_templates_list=(
|
||||
NIX_GNATMAKE_CARGS
|
||||
)
|
||||
|
||||
accumulateRoles
|
||||
|
||||
for var in "${var_templates_list[@]}"; do
|
||||
mangleVarList "$var" ${role_suffixes[@]+"${role_suffixes[@]}"}
|
||||
done
|
||||
|
||||
# `-B@out@/bin' forces cc to use wrapped as instead of the system one.
|
||||
NIX_GNATMAKE_CARGS_@suffixSalt@="$NIX_GNATMAKE_CARGS_@suffixSalt@ -B@out@/bin/"
|
||||
|
||||
# Only add darwin min version flag if a default darwin min version is set,
|
||||
# which is a signal that we're targetting darwin.
|
||||
if [ "@darwinMinVersion@" ]; then
|
||||
mangleVarSingle @darwinMinVersionVariable@ ${role_suffixes[@]+"${role_suffixes[@]}"}
|
||||
|
||||
NIX_GNATMAKE_CARGS_@suffixSalt@="-m@darwinPlatformForCC@-version-min=${@darwinMinVersionVariable@_@suffixSalt@:-@darwinMinVersion@} $NIX_GNATMAKE_CARGS_@suffixSalt@"
|
||||
fi
|
||||
|
||||
export NIX_GNAT_WRAPPER_EXTRA_FLAGS_SET_@suffixSalt@=1
|
@ -519,6 +519,10 @@ stdenv.mkDerivation {
|
||||
substituteAll ${../wrapper-common/utils.bash} $out/nix-support/utils.bash
|
||||
''
|
||||
|
||||
+ optionalString cc.langAda or false ''
|
||||
substituteAll ${./add-gnat-extra-flags.sh} $out/nix-support/add-gnat-extra-flags.sh
|
||||
''
|
||||
|
||||
##
|
||||
## General Clang support
|
||||
## Needs to go after ^ because the for loop eats \n and makes this file an invalid script
|
||||
|
@ -29,6 +29,9 @@ if [ -z "${NIX_CC_WRAPPER_FLAGS_SET_@suffixSalt@:-}" ]; then
|
||||
source @out@/nix-support/add-flags.sh
|
||||
fi
|
||||
|
||||
if [ -z "${NIX_GNAT_WRAPPER_EXTRA_FLAGS_SET_@suffixSalt@:-}" ]; then
|
||||
source @out@/nix-support/add-gnat-extra-flags.sh
|
||||
fi
|
||||
|
||||
# Parse command line options and set several variables.
|
||||
# For instance, figure out if linker flags should be passed.
|
||||
@ -126,7 +129,7 @@ fi
|
||||
|
||||
if [ "$(basename $0)x" = "gnatmakex" ]; then
|
||||
extraBefore=("--GNATBIND=@out@/bin/gnatbind" "--GNATLINK=@out@/bin/gnatlink")
|
||||
extraAfter=($NIX_GNATFLAGS_COMPILE_@suffixSalt@)
|
||||
extraAfter=($NIX_GNATFLAGS_COMPILE_@suffixSalt@ -cargs $NIX_GNATMAKE_CARGS_@suffixSalt@)
|
||||
fi
|
||||
|
||||
if [ "$(basename $0)x" = "gnatbindx" ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user