Commit c1308ac5 authored by Boey Maun Suang's avatar Boey Maun Suang
Browse files

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.
parent f061f3ea
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
# 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
+4 −0
Original line number Diff line number Diff line
@@ -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
+4 −1
Original line number Diff line number Diff line
@@ -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