diff options
Diffstat (limited to 'lib/spack/env/cc')
-rwxr-xr-x | lib/spack/env/cc | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/lib/spack/env/cc b/lib/spack/env/cc index 5efe015c9e..bd479f05ec 100755 --- a/lib/spack/env/cc +++ b/lib/spack/env/cc @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other +# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) @@ -125,7 +125,7 @@ case "$command" in comp="FC" lang_flags=F ;; - f77|xlf|xlf_r|pgf77|frt|flang) + f77|xlf|xlf_r|pgf77) command="$SPACK_F77" language="Fortran 77" comp="F77" @@ -277,14 +277,22 @@ other_args=() isystem_system_includes=() isystem_includes=() -while [ -n "$1" ]; do +while [ $# -ne 0 ]; do + # an RPATH to be added after the case statement. rp="" + # Multiple consecutive spaces in the command line can + # result in blank arguments + if [ -z "$1" ]; then + shift + continue + fi + case "$1" in -isystem*) arg="${1#-isystem}" - isystem_was_used=true + isystem_was_used=true if [ -z "$arg" ]; then shift; arg="$1"; fi if system_dir "$arg"; then isystem_system_includes+=("$arg") @@ -311,6 +319,16 @@ while [ -n "$1" ]; do fi ;; -l*) + # -loopopt=0 is generated erroneously in autoconf <= 2.69, + # and passed by ifx to the linker, which confuses it with a + # library. Filter it out. + # TODO: generalize filtering of args with an env var, so that + # TODO: we do not have to special case this here. + if { [ "$mode" = "ccld" ] || [ $mode = "ld" ]; } \ + && [ "$1" != "${1#-loopopt}" ]; then + shift + continue + fi arg="${1#-l}" if [ -z "$arg" ]; then shift; arg="$1"; fi other_args+=("-l$arg") @@ -320,9 +338,13 @@ while [ -n "$1" ]; do if [ -z "$arg" ]; then shift; arg="$1"; fi if [[ "$arg" = -rpath=* ]]; then rp="${arg#-rpath=}" + elif [[ "$arg" = --rpath=* ]]; then + rp="${arg#--rpath=}" elif [[ "$arg" = -rpath,* ]]; then rp="${arg#-rpath,}" - elif [[ "$arg" = -rpath ]]; then + elif [[ "$arg" = --rpath,* ]]; then + rp="${arg#--rpath,}" + elif [[ "$arg" =~ ^-?-rpath$ ]]; then shift; arg="$1" if [[ "$arg" != -Wl,* ]]; then die "-Wl,-rpath was not followed by -Wl,*" @@ -339,7 +361,9 @@ while [ -n "$1" ]; do if [ -z "$arg" ]; then shift; arg="$1"; fi if [[ "$arg" = -rpath=* ]]; then rp="${arg#-rpath=}" - elif [[ "$arg" = -rpath ]]; then + elif [[ "$arg" = --rpath=* ]]; then + rp="${arg#--rpath=}" + elif [[ "$arg" = -rpath ]] || [[ "$arg" = --rpath ]]; then shift; arg="$1" if [[ "$arg" != -Xlinker,* ]]; then die "-Xlinker,-rpath was not followed by -Xlinker,*" @@ -434,7 +458,7 @@ then ld) flags=("${flags[@]}" -headerpad_max_install_names) ;; ccld) - flags=("${flags[@]}" -Wl,-headerpad_max_install_names) ;; + flags=("${flags[@]}" "-Wl,-headerpad_max_install_names") ;; esac fi @@ -491,19 +515,19 @@ args+=("${flags[@]}") # Insert include directories just prior to any system include directories for dir in "${includes[@]}"; do args+=("-I$dir"); done -for dir in "${isystem_includes[@]}"; do args+=("-isystem$dir"); done +for dir in "${isystem_includes[@]}"; do args+=("-isystem" "$dir"); done IFS=':' read -ra spack_include_dirs <<< "$SPACK_INCLUDE_DIRS" if [[ $mode == cpp || $mode == cc || $mode == as || $mode == ccld ]]; then if [[ "$isystem_was_used" == "true" ]] ; then - for dir in "${spack_include_dirs[@]}"; do args+=("-isystem$dir"); done + for dir in "${spack_include_dirs[@]}"; do args+=("-isystem" "$dir"); done else - for dir in "${spack_include_dirs[@]}"; do args+=("-I$dir"); done + for dir in "${spack_include_dirs[@]}"; do args+=("-I$dir"); done fi fi for dir in "${system_includes[@]}"; do args+=("-I$dir"); done -for dir in "${isystem_system_includes[@]}"; do args+=("-isystem$dir"); done +for dir in "${isystem_system_includes[@]}"; do args+=("-isystem" "$dir"); done # Library search paths for dir in "${libdirs[@]}"; do args+=("-L$dir"); done @@ -512,12 +536,12 @@ for dir in "${system_libdirs[@]}"; do args+=("-L$dir"); done # RPATHs arguments case "$mode" in ccld) - if [ ! -z "$dtags_to_add" ] ; then args+=("$linker_arg$dtags_to_add") ; fi + if [ -n "$dtags_to_add" ] ; then args+=("$linker_arg$dtags_to_add") ; fi for dir in "${rpaths[@]}"; do args+=("$rpath$dir"); done for dir in "${system_rpaths[@]}"; do args+=("$rpath$dir"); done ;; ld) - if [ ! -z "$dtags_to_add" ] ; then args+=("$dtags_to_add") ; fi + if [ -n "$dtags_to_add" ] ; then args+=("$dtags_to_add") ; fi for dir in "${rpaths[@]}"; do args+=("-rpath" "$dir"); done for dir in "${system_rpaths[@]}"; do args+=("-rpath" "$dir"); done ;; |