Fix #254: libtool & distutils want certain compiler names.
This changes the compiler wrappers so that they are called by the same name as the wrapped compiler. Many builds make assumptions about compiler names, and we need the spack compilers to be recognizable so that build systems will get their flags right. This adds per-compiler subdirectories to lib/spack/spack/env directory that contain symlinks to cc for the C, C++, F77, and F90 compilers. The build now sets CC, CXX, F77, and F90 to point to these links instead of to the generically named cc, c++, f77, and f90 wrappers.
This commit is contained in:
parent
5f9a61616b
commit
7cc4d88726
23 changed files with 77 additions and 15 deletions
14
lib/spack/env/cc
vendored
14
lib/spack/env/cc
vendored
|
@ -86,22 +86,22 @@ done
|
|||
#
|
||||
command=$(basename "$0")
|
||||
case "$command" in
|
||||
cc|gcc|c89|c99|clang|xlc)
|
||||
cc|c89|c99|gcc|clang|icc|pgcc|xlc)
|
||||
command="$SPACK_CC"
|
||||
language="C"
|
||||
;;
|
||||
c++|CC|g++|clang++|xlC)
|
||||
c++|CC|g++|clang++|icpc|pgCC|xlc++)
|
||||
command="$SPACK_CXX"
|
||||
language="C++"
|
||||
;;
|
||||
f77|xlf)
|
||||
command="$SPACK_F77"
|
||||
language="Fortran 77"
|
||||
;;
|
||||
fc|f90|f95|xlf90)
|
||||
f90|fc|f95|gfortran|ifort|pgf90|xlf90)
|
||||
command="$SPACK_FC"
|
||||
language="Fortran 90"
|
||||
;;
|
||||
f77|gfortran|ifort|pgf77|xlf)
|
||||
command="$SPACK_F77"
|
||||
language="Fortran 77"
|
||||
;;
|
||||
cpp)
|
||||
mode=cpp
|
||||
;;
|
||||
|
|
1
lib/spack/env/clang/clang
vendored
Symbolic link
1
lib/spack/env/clang/clang
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../cc
|
1
lib/spack/env/clang/clang++
vendored
Symbolic link
1
lib/spack/env/clang/clang++
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../cc
|
1
lib/spack/env/gcc/g++
vendored
Symbolic link
1
lib/spack/env/gcc/g++
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../cc
|
1
lib/spack/env/gcc/gcc
vendored
Symbolic link
1
lib/spack/env/gcc/gcc
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../cc
|
1
lib/spack/env/gcc/gfortran
vendored
Symbolic link
1
lib/spack/env/gcc/gfortran
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../cc
|
1
lib/spack/env/intel/icc
vendored
Symbolic link
1
lib/spack/env/intel/icc
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../cc
|
1
lib/spack/env/intel/icpc
vendored
Symbolic link
1
lib/spack/env/intel/icpc
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../cc
|
1
lib/spack/env/intel/ifort
vendored
Symbolic link
1
lib/spack/env/intel/ifort
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../cc
|
1
lib/spack/env/pgi/case-insensitive/pgCC
vendored
Symbolic link
1
lib/spack/env/pgi/case-insensitive/pgCC
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../cc
|
1
lib/spack/env/pgi/pgcc
vendored
Symbolic link
1
lib/spack/env/pgi/pgcc
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../cc
|
1
lib/spack/env/pgi/pgf77
vendored
Symbolic link
1
lib/spack/env/pgi/pgf77
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../cc
|
1
lib/spack/env/pgi/pgf90
vendored
Symbolic link
1
lib/spack/env/pgi/pgf90
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../cc
|
1
lib/spack/env/xl/xlc
vendored
Symbolic link
1
lib/spack/env/xl/xlc
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../cc
|
1
lib/spack/env/xl/xlc++
vendored
Symbolic link
1
lib/spack/env/xl/xlc++
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../cc
|
1
lib/spack/env/xl/xlf
vendored
Symbolic link
1
lib/spack/env/xl/xlf
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../cc
|
1
lib/spack/env/xl/xlf90
vendored
Symbolic link
1
lib/spack/env/xl/xlf90
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../cc
|
|
@ -88,10 +88,14 @@ def set_compiler_environment_variables(pkg):
|
|||
compiler = pkg.compiler
|
||||
|
||||
# Set compiler variables used by CMake and autotools
|
||||
os.environ['CC'] = join_path(spack.build_env_path, 'cc')
|
||||
os.environ['CXX'] = join_path(spack.build_env_path, 'c++')
|
||||
os.environ['F77'] = join_path(spack.build_env_path, 'f77')
|
||||
os.environ['FC'] = join_path(spack.build_env_path, 'f90')
|
||||
assert all(key in pkg.compiler.link_paths
|
||||
for key in ('cc', 'cxx', 'f77', 'fc'))
|
||||
|
||||
link_dir = spack.build_env_path
|
||||
os.environ['CC'] = join_path(link_dir, pkg.compiler.link_paths['cc'])
|
||||
os.environ['CXX'] = join_path(link_dir, pkg.compiler.link_paths['cxx'])
|
||||
os.environ['F77'] = join_path(link_dir, pkg.compiler.link_paths['f77'])
|
||||
os.environ['FC'] = join_path(link_dir, pkg.compiler.link_paths['fc'])
|
||||
|
||||
# Set SPACK compiler variables so that our wrapper knows what to call
|
||||
if compiler.cc:
|
||||
|
@ -110,11 +114,23 @@ def set_build_environment_variables(pkg):
|
|||
"""This ensures a clean install environment when we build packages.
|
||||
"""
|
||||
# Add spack build environment path with compiler wrappers first in
|
||||
# the path. We handle case sensitivity conflicts like "CC" and
|
||||
# "cc" by putting one in the <build_env_path>/case-insensitive
|
||||
# the path. We add both spack.env_path, which includes default
|
||||
# wrappers (cc, c++, f77, f90), AND a subdirectory containing
|
||||
# compiler-specific symlinks. The latter ensures that builds that
|
||||
# are sensitive to the *name* of the compiler see the right name
|
||||
# when we're building wtih the wrappers.
|
||||
#
|
||||
# Conflicts on case-insensitive systems (like "CC" and "cc") are
|
||||
# handled by putting one in the <build_env_path>/case-insensitive
|
||||
# directory. Add that to the path too.
|
||||
env_paths = [spack.build_env_path,
|
||||
join_path(spack.build_env_path, 'case-insensitive')]
|
||||
env_paths = []
|
||||
def add_env_path(path):
|
||||
env_paths.append(path)
|
||||
ci = join_path(path, 'case-insensitive')
|
||||
if os.path.isdir(ci): env_paths.append(ci)
|
||||
add_env_path(spack.build_env_path)
|
||||
add_env_path(join_path(spack.build_env_path, pkg.compiler.name))
|
||||
|
||||
path_put_first("PATH", env_paths)
|
||||
path_set(SPACK_ENV_PATH, env_paths)
|
||||
|
||||
|
|
|
@ -37,6 +37,12 @@ class Clang(Compiler):
|
|||
# Subclasses use possible names of Fortran 90 compiler
|
||||
fc_names = []
|
||||
|
||||
# Named wrapper links within spack.build_env_path
|
||||
link_paths = { 'cc' : 'clang/clang',
|
||||
'cxx' : 'clang/clang++',
|
||||
# Use default wrappers for fortran, in case provided in compilers.yaml
|
||||
'f77' : 'f77',
|
||||
'fc' : 'f90' }
|
||||
|
||||
@classmethod
|
||||
def default_version(self, comp):
|
||||
|
|
|
@ -42,6 +42,12 @@ class Gcc(Compiler):
|
|||
# MacPorts builds gcc versions with prefixes and -mp-X.Y suffixes.
|
||||
suffixes = [r'-mp-\d\.\d']
|
||||
|
||||
# Named wrapper links within spack.build_env_path
|
||||
link_paths = {'cc' : 'gcc/gcc',
|
||||
'cxx' : 'gcc/g++',
|
||||
'f77' : 'gcc/gfortran',
|
||||
'fc' : 'gcc/gfortran' }
|
||||
|
||||
@property
|
||||
def cxx11_flag(self):
|
||||
if self.version < ver('4.3'):
|
||||
|
|
|
@ -37,6 +37,12 @@ class Intel(Compiler):
|
|||
# Subclasses use possible names of Fortran 90 compiler
|
||||
fc_names = ['ifort']
|
||||
|
||||
# Named wrapper links within spack.build_env_path
|
||||
link_paths = { 'cc' : 'intel/icc',
|
||||
'cxx' : 'intel/icpc',
|
||||
'f77' : 'intel/ifort',
|
||||
'fc' : 'intel/ifort' }
|
||||
|
||||
@property
|
||||
def cxx11_flag(self):
|
||||
if self.version < ver('11.1'):
|
||||
|
|
|
@ -37,6 +37,12 @@ class Pgi(Compiler):
|
|||
# Subclasses use possible names of Fortran 90 compiler
|
||||
fc_names = ['pgf95', 'pgf90']
|
||||
|
||||
# Named wrapper links within spack.build_env_path
|
||||
link_paths = { 'cc' : 'pgi/pgcc',
|
||||
'cxx' : 'pgi/case-insensitive/pgCC',
|
||||
'f77' : 'pgi/pgf77',
|
||||
'fc' : 'pgi/pgf90' }
|
||||
|
||||
@classmethod
|
||||
def default_version(cls, comp):
|
||||
"""The '-V' option works for all the PGI compilers.
|
||||
|
|
|
@ -38,6 +38,12 @@ class Xl(Compiler):
|
|||
# Subclasses use possible names of Fortran 90 compiler
|
||||
fc_names = ['xlf90','xlf90_r','xlf95','xlf95_r','xlf2003','xlf2003_r','xlf2008','xlf2008_r']
|
||||
|
||||
# Named wrapper links within spack.build_env_path
|
||||
link_paths = { 'cc' : 'xl/xlc',
|
||||
'cxx' : 'xl/xlc++',
|
||||
'f77' : 'xl/xlf',
|
||||
'fc' : 'xl/xlf90' }
|
||||
|
||||
@property
|
||||
def cxx11_flag(self):
|
||||
if self.version < ver('13.1'):
|
||||
|
|
Loading…
Reference in a new issue