Language-specific PIC flags (#15474)

* Language-specific PIC flags

* Add tests for every compiler flag

* Fix bad rebase

* pic_flag -> cxx_pic_flag
This commit is contained in:
Adam J. Stewart
2020-04-17 16:28:51 -05:00
committed by GitHub
parent ad8977467b
commit 284e450c91
62 changed files with 415 additions and 160 deletions

View File

@@ -169,7 +169,7 @@ def _do_patch_libtool(self):
line = 'wl="-Wl,"\n' line = 'wl="-Wl,"\n'
if line == 'pic_flag=""\n': if line == 'pic_flag=""\n':
line = 'pic_flag="{0}"\n'\ line = 'pic_flag="{0}"\n'\
.format(self.compiler.pic_flag) .format(self.compiler.cc_pic_flag)
sys.stdout.write(line) sys.stdout.write(line)
@property @property

View File

@@ -410,6 +410,30 @@ def c11_flag(self):
"the C11 standard", "the C11 standard",
"c11_flag") "c11_flag")
@property
def cc_pic_flag(self):
"""Returns the flag used by the C compiler to produce
Position Independent Code (PIC)."""
return '-fPIC'
@property
def cxx_pic_flag(self):
"""Returns the flag used by the C++ compiler to produce
Position Independent Code (PIC)."""
return '-fPIC'
@property
def f77_pic_flag(self):
"""Returns the flag used by the F77 compiler to produce
Position Independent Code (PIC)."""
return '-fPIC'
@property
def fc_pic_flag(self):
"""Returns the flag used by the FC compiler to produce
Position Independent Code (PIC)."""
return '-fPIC'
# #
# Compiler classes have methods for querying the version of # Compiler classes have methods for querying the version of
# specific compiler executables. This is used when discovering compilers. # specific compiler executables. This is used when discovering compilers.

View File

@@ -80,7 +80,19 @@ def c11_flag(self):
return "-std=c11" return "-std=c11"
@property @property
def pic_flag(self): def cc_pic_flag(self):
return "-fPIC"
@property
def cxx_pic_flag(self):
return "-fPIC"
@property
def f77_pic_flag(self):
return "-fPIC"
@property
def fc_pic_flag(self):
return "-fPIC" return "-fPIC"
required_libs = ['libclang', 'libflang'] required_libs = ['libclang', 'libflang']

View File

@@ -68,5 +68,17 @@ def c11_flag(self):
'< 8.5') '< 8.5')
@property @property
def pic_flag(self): def cc_pic_flag(self):
return "-h PIC"
@property
def cxx_pic_flag(self):
return "-h PIC"
@property
def f77_pic_flag(self):
return "-h PIC"
@property
def fc_pic_flag(self):
return "-h PIC" return "-h PIC"

View File

@@ -174,7 +174,19 @@ def c11_flag(self):
return "-std=c11" return "-std=c11"
@property @property
def pic_flag(self): def cc_pic_flag(self):
return "-fPIC"
@property
def cxx_pic_flag(self):
return "-fPIC"
@property
def f77_pic_flag(self):
return "-fPIC"
@property
def fc_pic_flag(self):
return "-fPIC" return "-fPIC"
required_libs = ['libclang'] required_libs = ['libclang']

View File

@@ -59,5 +59,17 @@ def c11_flag(self):
return "-std=c11" return "-std=c11"
@property @property
def pic_flag(self): def cc_pic_flag(self):
return "-KPIC"
@property
def cxx_pic_flag(self):
return "-KPIC"
@property
def f77_pic_flag(self):
return "-KPIC"
@property
def fc_pic_flag(self):
return "-KPIC" return "-KPIC"

View File

@@ -110,7 +110,19 @@ def c11_flag(self):
return "-std=c11" return "-std=c11"
@property @property
def pic_flag(self): def cc_pic_flag(self):
return "-fPIC"
@property
def cxx_pic_flag(self):
return "-fPIC"
@property
def f77_pic_flag(self):
return "-fPIC"
@property
def fc_pic_flag(self):
return "-fPIC" return "-fPIC"
required_libs = ['libgcc', 'libgfortran'] required_libs = ['libgcc', 'libgfortran']

View File

@@ -92,7 +92,19 @@ def c11_flag(self):
return "-std=c1x" return "-std=c1x"
@property @property
def pic_flag(self): def cc_pic_flag(self):
return "-fPIC"
@property
def cxx_pic_flag(self):
return "-fPIC"
@property
def f77_pic_flag(self):
return "-fPIC"
@property
def fc_pic_flag(self):
return "-fPIC" return "-fPIC"
@property @property

View File

@@ -41,7 +41,11 @@ def cxx11_flag(self):
return "-std=c++11" return "-std=c++11"
@property @property
def pic_flag(self): def f77_pic_flag(self):
return "-PIC"
@property
def fc_pic_flag(self):
return "-PIC" return "-PIC"
# Unlike other compilers, the NAG compiler passes options to GCC, which # Unlike other compilers, the NAG compiler passes options to GCC, which

View File

@@ -46,7 +46,19 @@ def cxx11_flag(self):
return "-std=c++11" return "-std=c++11"
@property @property
def pic_flag(self): def cc_pic_flag(self):
return "-fpic"
@property
def cxx_pic_flag(self):
return "-fpic"
@property
def f77_pic_flag(self):
return "-fpic"
@property
def fc_pic_flag(self):
return "-fpic" return "-fpic"
required_libs = ['libpgc', 'libpgf90'] required_libs = ['libpgc', 'libpgf90']

View File

@@ -70,7 +70,19 @@ def c11_flag(self):
'< 12.1') '< 12.1')
@property @property
def pic_flag(self): def cc_pic_flag(self):
return "-qpic"
@property
def cxx_pic_flag(self):
return "-qpic"
@property
def f77_pic_flag(self):
return "-qpic"
@property
def fc_pic_flag(self):
return "-qpic" return "-qpic"
@property @property

View File

@@ -17,13 +17,13 @@
import spack.compilers.arm import spack.compilers.arm
import spack.compilers.cce import spack.compilers.cce
import spack.compilers.clang import spack.compilers.clang
import spack.compilers.fj
import spack.compilers.gcc import spack.compilers.gcc
import spack.compilers.intel import spack.compilers.intel
import spack.compilers.nag import spack.compilers.nag
import spack.compilers.pgi import spack.compilers.pgi
import spack.compilers.xl import spack.compilers.xl
import spack.compilers.xl_r import spack.compilers.xl_r
import spack.compilers.fj
from spack.compiler import Compiler from spack.compiler import Compiler
@@ -222,18 +222,53 @@ def supported_flag_test(flag, flag_value_ref, spec=None):
# Tests for UnsupportedCompilerFlag exceptions from default # Tests for UnsupportedCompilerFlag exceptions from default
# implementations of flags. # implementations of flags.
def test_default_flags(): def test_default_flags():
supported_flag_test("cc_rpath_arg", "-Wl,-rpath,")
supported_flag_test("cxx_rpath_arg", "-Wl,-rpath,")
supported_flag_test("f77_rpath_arg", "-Wl,-rpath,")
supported_flag_test("fc_rpath_arg", "-Wl,-rpath,")
supported_flag_test("linker_arg", "-Wl,")
unsupported_flag_test("openmp_flag") unsupported_flag_test("openmp_flag")
unsupported_flag_test("cxx11_flag") unsupported_flag_test("cxx11_flag")
unsupported_flag_test("cxx14_flag") unsupported_flag_test("cxx14_flag")
unsupported_flag_test("cxx17_flag") unsupported_flag_test("cxx17_flag")
supported_flag_test("cxx98_flag", "") supported_flag_test("cxx98_flag", "")
unsupported_flag_test("c99_flag")
unsupported_flag_test("c11_flag")
supported_flag_test("cc_pic_flag", "-fPIC")
supported_flag_test("cxx_pic_flag", "-fPIC")
supported_flag_test("f77_pic_flag", "-fPIC")
supported_flag_test("fc_pic_flag", "-fPIC")
# Verify behavior of particular compiler definitions. # Verify behavior of particular compiler definitions.
def test_clang_flags(): def test_arm_flags():
# Common supported_flag_test("openmp_flag", "-fopenmp", "arm@1.0")
supported_flag_test("pic_flag", "-fPIC", "gcc@4.0") supported_flag_test("cxx11_flag", "-std=c++11", "arm@1.0")
supported_flag_test("cxx14_flag", "-std=c++14", "arm@1.0")
supported_flag_test("cxx17_flag", "-std=c++1z", "arm@1.0")
supported_flag_test("c99_flag", "-std=c99", "arm@1.0")
supported_flag_test("c11_flag", "-std=c11", "arm@1.0")
supported_flag_test("cc_pic_flag", "-fPIC", "arm@1.0")
supported_flag_test("cxx_pic_flag", "-fPIC", "arm@1.0")
supported_flag_test("f77_pic_flag", "-fPIC", "arm@1.0")
supported_flag_test("fc_pic_flag", "-fPIC", "arm@1.0")
def test_cce_flags():
supported_flag_test("openmp_flag", "-h omp", "cce@1.0")
supported_flag_test("cxx11_flag", "-h std=c++11", "cce@1.0")
unsupported_flag_test("c99_flag", "cce@8.0")
supported_flag_test("c99_flag", "-h c99,noconform,gnu", "cce@8.1")
supported_flag_test("c99_flag", "-h stc=c99,noconform,gnu", "cce@8.4")
unsupported_flag_test("c11_flag", "cce@8.4")
supported_flag_test("c11_flag", "-h std=c11,noconform,gnu", "cce@8.5")
supported_flag_test("cc_pic_flag", "-h PIC", "cce@1.0")
supported_flag_test("cxx_pic_flag", "-h PIC", "cce@1.0")
supported_flag_test("f77_pic_flag", "-h PIC", "cce@1.0")
supported_flag_test("fc_pic_flag", "-h PIC", "cce@1.0")
def test_clang_flags():
# Apple Clang. # Apple Clang.
supported_flag_test( supported_flag_test(
"openmp_flag", "-Xpreprocessor -fopenmp", "clang@2.0.0-apple") "openmp_flag", "-Xpreprocessor -fopenmp", "clang@2.0.0-apple")
@@ -244,6 +279,13 @@ def test_clang_flags():
supported_flag_test("cxx14_flag", "-std=c++14", "clang@6.1.0-apple") supported_flag_test("cxx14_flag", "-std=c++14", "clang@6.1.0-apple")
unsupported_flag_test("cxx17_flag", "clang@6.0.0-apple") unsupported_flag_test("cxx17_flag", "clang@6.0.0-apple")
supported_flag_test("cxx17_flag", "-std=c++1z", "clang@6.1.0-apple") supported_flag_test("cxx17_flag", "-std=c++1z", "clang@6.1.0-apple")
supported_flag_test("c99_flag", "-std=c99", "clang@6.1.0-apple")
unsupported_flag_test("c11_flag", "clang@6.0.0-apple")
supported_flag_test("c11_flag", "-std=c11", "clang@6.1.0-apple")
supported_flag_test("cc_pic_flag", "-fPIC", "clang@2.0.0-apple")
supported_flag_test("cxx_pic_flag", "-fPIC", "clang@2.0.0-apple")
supported_flag_test("f77_pic_flag", "-fPIC", "clang@2.0.0-apple")
supported_flag_test("fc_pic_flag", "-fPIC", "clang@2.0.0-apple")
# non-Apple Clang. # non-Apple Clang.
supported_flag_test("openmp_flag", "-fopenmp", "clang@3.3") supported_flag_test("openmp_flag", "-fopenmp", "clang@3.3")
@@ -255,12 +297,26 @@ def test_clang_flags():
unsupported_flag_test("cxx17_flag", "clang@3.4") unsupported_flag_test("cxx17_flag", "clang@3.4")
supported_flag_test("cxx17_flag", "-std=c++1z", "clang@3.5") supported_flag_test("cxx17_flag", "-std=c++1z", "clang@3.5")
supported_flag_test("cxx17_flag", "-std=c++17", "clang@5.0") supported_flag_test("cxx17_flag", "-std=c++17", "clang@5.0")
supported_flag_test("c99_flag", "-std=c99", "clang@3.3")
unsupported_flag_test("c11_flag", "clang@6.0.0")
supported_flag_test("c11_flag", "-std=c11", "clang@6.1.0")
supported_flag_test("cc_pic_flag", "-fPIC", "clang@3.3")
supported_flag_test("cxx_pic_flag", "-fPIC", "clang@3.3")
supported_flag_test("f77_pic_flag", "-fPIC", "clang@3.3")
supported_flag_test("fc_pic_flag", "-fPIC", "clang@3.3")
def test_cce_flags(): def test_fj_flags():
supported_flag_test("openmp_flag", "-h omp", "cce@1.0") supported_flag_test("openmp_flag", "-Kopenmp", "fj@4.0.0")
supported_flag_test("cxx11_flag", "-h std=c++11", "cce@1.0") supported_flag_test("cxx98_flag", "-std=c++98", "fj@4.0.0")
supported_flag_test("pic_flag", "-h PIC", "cce@1.0") supported_flag_test("cxx11_flag", "-std=c++11", "fj@4.0.0")
supported_flag_test("cxx14_flag", "-std=c++14", "fj@4.0.0")
supported_flag_test("c99_flag", "-std=c99", "fj@4.0.0")
supported_flag_test("c11_flag", "-std=c11", "fj@4.0.0")
supported_flag_test("cc_pic_flag", "-KPIC", "fj@4.0.0")
supported_flag_test("cxx_pic_flag", "-KPIC", "fj@4.0.0")
supported_flag_test("f77_pic_flag", "-KPIC", "fj@4.0.0")
supported_flag_test("fc_pic_flag", "-KPIC", "fj@4.0.0")
def test_gcc_flags(): def test_gcc_flags():
@@ -275,7 +331,17 @@ def test_gcc_flags():
supported_flag_test("cxx14_flag", "-std=c++14", "gcc@4.9") supported_flag_test("cxx14_flag", "-std=c++14", "gcc@4.9")
supported_flag_test("cxx14_flag", "", "gcc@6.0") supported_flag_test("cxx14_flag", "", "gcc@6.0")
unsupported_flag_test("cxx17_flag", "gcc@4.9") unsupported_flag_test("cxx17_flag", "gcc@4.9")
supported_flag_test("pic_flag", "-fPIC", "gcc@4.0") supported_flag_test("cxx17_flag", "-std=c++1z", "gcc@5.0")
supported_flag_test("cxx17_flag", "-std=c++17", "gcc@6.0")
unsupported_flag_test("c99_flag", "gcc@4.4")
supported_flag_test("c99_flag", "-std=c99", "gcc@4.5")
unsupported_flag_test("c11_flag", "gcc@4.6")
supported_flag_test("c11_flag", "-std=c11", "gcc@4.7")
supported_flag_test("cc_pic_flag", "-fPIC", "gcc@4.0")
supported_flag_test("cxx_pic_flag", "-fPIC", "gcc@4.0")
supported_flag_test("f77_pic_flag", "-fPIC", "gcc@4.0")
supported_flag_test("fc_pic_flag", "-fPIC", "gcc@4.0")
supported_flag_test("stdcxx_libs", ("-lstdc++",), "gcc@4.1")
def test_intel_flags(): def test_intel_flags():
@@ -287,43 +353,105 @@ def test_intel_flags():
unsupported_flag_test("cxx14_flag", "intel@14.0") unsupported_flag_test("cxx14_flag", "intel@14.0")
supported_flag_test("cxx14_flag", "-std=c++1y", "intel@15.0") supported_flag_test("cxx14_flag", "-std=c++1y", "intel@15.0")
supported_flag_test("cxx14_flag", "-std=c++14", "intel@15.0.2") supported_flag_test("cxx14_flag", "-std=c++14", "intel@15.0.2")
supported_flag_test("pic_flag", "-fPIC", "intel@1.0") unsupported_flag_test("c99_flag", "intel@11.0")
supported_flag_test("c99_flag", "-std=c99", "intel@12.0")
unsupported_flag_test("c11_flag", "intel@15.0")
supported_flag_test("c11_flag", "-std=c1x", "intel@16.0")
supported_flag_test("cc_pic_flag", "-fPIC", "intel@1.0")
supported_flag_test("cxx_pic_flag", "-fPIC", "intel@1.0")
supported_flag_test("f77_pic_flag", "-fPIC", "intel@1.0")
supported_flag_test("fc_pic_flag", "-fPIC", "intel@1.0")
supported_flag_test("stdcxx_libs", ("-cxxlib",), "intel@1.0")
def test_nag_flags(): def test_nag_flags():
supported_flag_test("openmp_flag", "-openmp", "nag@1.0") supported_flag_test("openmp_flag", "-openmp", "nag@1.0")
supported_flag_test("cxx11_flag", "-std=c++11", "nag@1.0") supported_flag_test("cxx11_flag", "-std=c++11", "nag@1.0")
supported_flag_test("pic_flag", "-PIC", "nag@1.0") supported_flag_test("cc_pic_flag", "-fPIC", "nag@1.0")
supported_flag_test("cxx_pic_flag", "-fPIC", "nag@1.0")
supported_flag_test("f77_pic_flag", "-PIC", "nag@1.0")
supported_flag_test("fc_pic_flag", "-PIC", "nag@1.0")
supported_flag_test("cc_rpath_arg", "-Wl,-rpath,", "nag@1.0")
supported_flag_test("cxx_rpath_arg", "-Wl,-rpath,", "nag@1.0")
supported_flag_test("f77_rpath_arg", "-Wl,-Wl,,-rpath,,", "nag@1.0")
supported_flag_test("fc_rpath_arg", "-Wl,-Wl,,-rpath,,", "nag@1.0")
supported_flag_test("linker_arg", "-Wl,-Wl,,", "nag@1.0")
def test_pgi_flags(): def test_pgi_flags():
supported_flag_test("openmp_flag", "-mp", "pgi@1.0") supported_flag_test("openmp_flag", "-mp", "pgi@1.0")
supported_flag_test("cxx11_flag", "-std=c++11", "pgi@1.0") supported_flag_test("cxx11_flag", "-std=c++11", "pgi@1.0")
supported_flag_test("pic_flag", "-fpic", "pgi@1.0") unsupported_flag_test("c99_flag", "pgi@12.9")
supported_flag_test("c99_flag", "-c99", "pgi@12.10")
unsupported_flag_test("c11_flag", "pgi@15.2")
supported_flag_test("c11_flag", "-c11", "pgi@15.3")
supported_flag_test("cc_pic_flag", "-fpic", "pgi@1.0")
supported_flag_test("cxx_pic_flag", "-fpic", "pgi@1.0")
supported_flag_test("f77_pic_flag", "-fpic", "pgi@1.0")
supported_flag_test("fc_pic_flag", "-fpic", "pgi@1.0")
def test_xl_flags(): def test_xl_flags():
supported_flag_test("openmp_flag", "-qsmp=omp", "xl@1.0") supported_flag_test("openmp_flag", "-qsmp=omp", "xl@1.0")
unsupported_flag_test("cxx11_flag", "xl@13.0") unsupported_flag_test("cxx11_flag", "xl@13.0")
supported_flag_test("cxx11_flag", "-qlanglvl=extended0x", "xl@13.1") supported_flag_test("cxx11_flag", "-qlanglvl=extended0x", "xl@13.1")
supported_flag_test("pic_flag", "-qpic", "xl@1.0") unsupported_flag_test("c99_flag", "xl@10.0")
supported_flag_test("c99_flag", "-qlanglvl=extc99", "xl@10.1")
supported_flag_test("c99_flag", "-std=gnu99", "xl@13.1.1")
unsupported_flag_test("c11_flag", "xl@12.0")
supported_flag_test("c11_flag", "-qlanglvl=extc1x", "xl@12.1")
supported_flag_test("c11_flag", "-std=gnu11", "xl@13.1.2")
supported_flag_test("cc_pic_flag", "-qpic", "xl@1.0")
supported_flag_test("cxx_pic_flag", "-qpic", "xl@1.0")
supported_flag_test("f77_pic_flag", "-qpic", "xl@1.0")
supported_flag_test("fc_pic_flag", "-qpic", "xl@1.0")
supported_flag_test("fflags", "-qzerosize", "xl@1.0")
def test_xl_r_flags(): def test_xl_r_flags():
supported_flag_test("openmp_flag", "-qsmp=omp", "xl_r@1.0") supported_flag_test("openmp_flag", "-qsmp=omp", "xl_r@1.0")
unsupported_flag_test("cxx11_flag", "xl_r@13.0") unsupported_flag_test("cxx11_flag", "xl_r@13.0")
supported_flag_test("cxx11_flag", "-qlanglvl=extended0x", "xl_r@13.1") supported_flag_test("cxx11_flag", "-qlanglvl=extended0x", "xl_r@13.1")
supported_flag_test("pic_flag", "-qpic", "xl_r@1.0") unsupported_flag_test("c99_flag", "xl_r@10.0")
supported_flag_test("c99_flag", "-qlanglvl=extc99", "xl_r@10.1")
supported_flag_test("c99_flag", "-std=gnu99", "xl_r@13.1.1")
unsupported_flag_test("c11_flag", "xl_r@12.0")
supported_flag_test("c11_flag", "-qlanglvl=extc1x", "xl_r@12.1")
supported_flag_test("c11_flag", "-std=gnu11", "xl_r@13.1.2")
supported_flag_test("cc_pic_flag", "-qpic", "xl_r@1.0")
supported_flag_test("cxx_pic_flag", "-qpic", "xl_r@1.0")
supported_flag_test("f77_pic_flag", "-qpic", "xl_r@1.0")
supported_flag_test("fc_pic_flag", "-qpic", "xl_r@1.0")
supported_flag_test("fflags", "-qzerosize", "xl_r@1.0")
def test_fj_flags(): @pytest.mark.parametrize('version_str,expected_version', [
supported_flag_test("openmp_flag", "-Kopenmp", "fj@4.0.0") ('Arm C/C++/Fortran Compiler version 19.0 (build number 73) (based on LLVM 7.0.2)\n' # NOQA
supported_flag_test("cxx98_flag", "-std=c++98", "fj@4.0.0") 'Target: aarch64--linux-gnu\n'
supported_flag_test("cxx11_flag", "-std=c++11", "fj@4.0.0") 'Thread model: posix\n'
supported_flag_test("cxx14_flag", "-std=c++14", "fj@4.0.0") 'InstalledDir:\n'
supported_flag_test("c99_flag", "-std=c99", "fj@4.0.0") '/opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin\n', # NOQA
supported_flag_test("c11_flag", "-std=c11", "fj@4.0.0") '19.0.0.73'),
supported_flag_test("pic_flag", "-KPIC", "fj@4.0.0") ('Arm C/C++/Fortran Compiler version 19.3.1 (build number 75) (based on LLVM 7.0.2)\n' # NOQA
'Target: aarch64--linux-gnu\n'
'Thread model: posix\n'
'InstalledDir:\n'
'/opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin\n', # NOQA
'19.3.1.75')
])
def test_arm_version_detection(version_str, expected_version):
version = spack.compilers.arm.Arm.extract_version_from_output(version_str)
assert version == expected_version
@pytest.mark.parametrize('version_str,expected_version', [
('Cray C : Version 8.4.6 Mon Apr 15, 2019 12:13:39\n', '8.4.6'),
('Cray C++ : Version 8.4.6 Mon Apr 15, 2019 12:13:45\n', '8.4.6'),
('Cray Fortran : Version 8.4.6 Mon Apr 15, 2019 12:13:55\n', '8.4.6')
])
def test_cce_version_detection(version_str, expected_version):
version = spack.compilers.cce.Cce.extract_version_from_output(version_str)
assert version == expected_version
@pytest.mark.regression('10191') @pytest.mark.regression('10191')
@@ -364,21 +492,23 @@ def test_clang_version_detection(version_str, expected_version):
@pytest.mark.parametrize('version_str,expected_version', [ @pytest.mark.parametrize('version_str,expected_version', [
('Arm C/C++/Fortran Compiler version 19.0 (build number 73) (based on LLVM 7.0.2)\n' # NOQA # C compiler
'Target: aarch64--linux-gnu\n' ('fcc (FCC) 4.0.0 20190314\n'
'Thread model: posix\n' 'simulating gcc version 6.1\n'
'InstalledDir:\n' 'Copyright FUJITSU LIMITED 2019',
'/opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin\n', # NOQA '4.0.0'),
'19.0.0.73'), # C++ compiler
('Arm C/C++/Fortran Compiler version 19.3.1 (build number 75) (based on LLVM 7.0.2)\n' # NOQA ('FCC (FCC) 4.0.0 20190314\n'
'Target: aarch64--linux-gnu\n' 'simulating gcc version 6.1\n'
'Thread model: posix\n' 'Copyright FUJITSU LIMITED 2019',
'InstalledDir:\n' '4.0.0'),
'/opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin\n', # NOQA # Fortran compiler
'19.3.1.75') ('frt (FRT) 4.0.0 20190314\n'
'Copyright FUJITSU LIMITED 2019',
'4.0.0')
]) ])
def test_arm_version_detection(version_str, expected_version): def test_fj_version_detection(version_str, expected_version):
version = spack.compilers.arm.Arm.extract_version_from_output(version_str) version = spack.compilers.fj.Fj.extract_version_from_output(version_str)
assert version == expected_version assert version == expected_version
@@ -454,37 +584,6 @@ def test_xl_version_detection(version_str, expected_version):
assert version == expected_version assert version == expected_version
@pytest.mark.parametrize('version_str,expected_version', [
('Cray C : Version 8.4.6 Mon Apr 15, 2019 12:13:39\n', '8.4.6'),
('Cray C++ : Version 8.4.6 Mon Apr 15, 2019 12:13:45\n', '8.4.6'),
('Cray Fortran : Version 8.4.6 Mon Apr 15, 2019 12:13:55\n', '8.4.6')
])
def test_cce_version_detection(version_str, expected_version):
version = spack.compilers.cce.Cce.extract_version_from_output(version_str)
assert version == expected_version
@pytest.mark.parametrize('version_str,expected_version', [
# C compiler
('fcc (FCC) 4.0.0 20190314\n'
'simulating gcc version 6.1\n'
'Copyright FUJITSU LIMITED 2019',
'4.0.0'),
# C++ compiler
('FCC (FCC) 4.0.0 20190314\n'
'simulating gcc version 6.1\n'
'Copyright FUJITSU LIMITED 2019',
'4.0.0'),
# Fortran compiler
('frt (FRT) 4.0.0 20190314\n'
'Copyright FUJITSU LIMITED 2019',
'4.0.0')
])
def test_fj_version_detection(version_str, expected_version):
version = spack.compilers.fj.Fj.extract_version_from_output(version_str)
assert version == expected_version
@pytest.mark.parametrize('compiler_spec,expected_result', [ @pytest.mark.parametrize('compiler_spec,expected_result', [
('gcc@4.7.2', False), ('clang@3.3', False), ('clang@8.0.0', True) ('gcc@4.7.2', False), ('clang@3.3', False), ('clang@8.0.0', True)
]) ])

View File

@@ -133,7 +133,7 @@ def configure_args(self):
extra_args = [ extra_args = [
# required, otherwise building its python bindings will fail # required, otherwise building its python bindings will fail
'CFLAGS={0}'.format(self.compiler.pic_flag) 'CFLAGS={0}'.format(self.compiler.cc_pic_flag)
] ]
extra_args += self.enable_or_disable('shared') extra_args += self.enable_or_disable('shared')

View File

@@ -371,7 +371,7 @@ def determine_b2_options(self, spec, options):
cxxflags.append(flag) cxxflags.append(flag)
if '+pic' in self.spec: if '+pic' in self.spec:
cxxflags.append(self.compiler.pic_flag) cxxflags.append(self.compiler.cxx_pic_flag)
# clang is not officially supported for pre-compiled headers # clang is not officially supported for pre-compiled headers
# and at least in clang 3.9 still fails to build # and at least in clang 3.9 still fails to build

View File

@@ -59,7 +59,7 @@ def build_args(self, spec, prefix):
'CC={0}'.format(spack_cc), 'CC={0}'.format(spack_cc),
'CXX={0}'.format(spack_cxx), 'CXX={0}'.format(spack_cxx),
'FORTRAN={0}'.format(spack_fc), 'FORTRAN={0}'.format(spack_fc),
'cc_flags={0}'.format(self.compiler.pic_flag), 'cc_flags={0}'.format(self.compiler.cc_pic_flag),
# Allow Spack environment variables to propagate through to SCons # Allow Spack environment variables to propagate through to SCons
'env_vars=all' 'env_vars=all'
] ]

View File

@@ -56,7 +56,7 @@ def configure_args(self):
args = [] args = []
cookie = self.spec.variants['gni-cookie'].value cookie = self.spec.variants['gni-cookie'].value
ptag = self.spec.variants['ptag'].value ptag = self.spec.variants['ptag'].value
args.append('CFLAGS={0}'.format(self.compiler.pic_flag)) args.append('CFLAGS={0}'.format(self.compiler.cc_pic_flag))
if self.spec.satisfies('+dimes'): if self.spec.satisfies('+dimes'):
args.append('--enable-dimes') args.append('--enable-dimes')
if self.spec.satisfies('+cray-drc'): if self.spec.satisfies('+cray-drc'):

View File

@@ -31,7 +31,7 @@ def edit(self, spec, prefix):
makefile = FileFilter('Makefile') makefile = FileFilter('Makefile')
makefile.filter('CC=.*', makefile.filter('CC=.*',
'CC={0} {1}'.format(spack_cc, 'CC={0} {1}'.format(spack_cc,
self.compiler.pic_flag)) self.compiler.cc_pic_flag))
makefile.filter('CFLAGS=.*', 'CFLAGS={0}'.format(cflags)) makefile.filter('CFLAGS=.*', 'CFLAGS={0}'.format(cflags))
makefile.filter('PREFIX=.*', 'PREFIX={0}'.format(self.prefix)) makefile.filter('PREFIX=.*', 'PREFIX={0}'.format(self.prefix))
p = self.spec['libzmq'].prefix p = self.spec['libzmq'].prefix

View File

@@ -61,8 +61,8 @@ def cmake_args(self):
if '+pic' in spec: if '+pic' in spec:
args.extend([ args.extend([
'-DCMAKE_C_FLAGS={0}'.format(self.compiler.pic_flag), '-DCMAKE_C_FLAGS={0}'.format(self.compiler.cc_pic_flag),
'-DCMAKE_CXX_FLAGS={0}'.format(self.compiler.pic_flag) '-DCMAKE_CXX_FLAGS={0}'.format(self.compiler.cxx_pic_flag)
]) ])
args.append('-DCMAKE_CXX_STANDARD={0}'.format( args.append('-DCMAKE_CXX_STANDARD={0}'.format(

View File

@@ -60,8 +60,8 @@ def configure_args(self):
'--with-segment-mmap-max=%s ' '--with-segment-mmap-max=%s '
% (self.spec.variants['segment-mmap-max'].value), % (self.spec.variants['segment-mmap-max'].value),
# for consumers with shared libs # for consumers with shared libs
'CC=%s %s' % (spack_cc, self.compiler.pic_flag), "CC=%s %s" % (spack_cc, self.compiler.cc_pic_flag),
'CXX=%s %s' % (spack_cxx, self.compiler.pic_flag), "CXX=%s %s" % (spack_cxx, self.compiler.cxx_pic_flag),
] ]
if '+aligned-segments' in self.spec: if '+aligned-segments' in self.spec:
@@ -80,7 +80,7 @@ def configure_args(self):
'--disable-ibv', '--disable-ibv',
'--disable-seq', '--disable-seq',
'MPI_CC=%s %s' 'MPI_CC=%s %s'
% (self.spec['mpi'].mpicc, self.compiler.pic_flag)]) % (self.spec['mpi'].mpicc, self.compiler.cc_pic_flag)])
if '+ibv' in self.spec: if '+ibv' in self.spec:
args.extend(['--enable-ibv', args.extend(['--enable-ibv',

View File

@@ -35,7 +35,7 @@ def configure_args(self):
spec = self.spec spec = self.spec
config_args = [ config_args = [
'CFLAGS={0}'.format(self.compiler.pic_flag), 'CFLAGS={0}'.format(self.compiler.cc_pic_flag),
'--with-jpeg={0}'.format(spec['jpeg'].prefix), '--with-jpeg={0}'.format(spec['jpeg'].prefix),
'--with-zlib={0}'.format(spec['zlib'].prefix), '--with-zlib={0}'.format(spec['zlib'].prefix),
'--disable-netcdf', # must be disabled to build NetCDF with HDF4 '--disable-netcdf', # must be disabled to build NetCDF with HDF4

View File

@@ -259,8 +259,11 @@ def configure_args(self):
extra_args.append('--enable-static-exec') extra_args.append('--enable-static-exec')
if '+pic' in self.spec: if '+pic' in self.spec:
extra_args += ['%s=%s' % (f, self.compiler.pic_flag) extra_args.extend([
for f in ['CFLAGS', 'CXXFLAGS', 'FCFLAGS']] 'CFLAGS=' + self.compiler.cc_pic_flag,
'CXXFLAGS=' + self.compiler.cxx_pic_flag,
'FCFLAGS=' + self.compiler.fc_pic_flag,
])
if '+mpi' in self.spec: if '+mpi' in self.spec:
# The HDF5 configure script warns if cxx and mpi are enabled # The HDF5 configure script warns if cxx and mpi are enabled

View File

@@ -81,7 +81,7 @@ def common_make_opts(self):
if '+cuda' in spec: if '+cuda' in spec:
makeopts += ['CUDA_DIR=%s' % spec['cuda'].prefix] makeopts += ['CUDA_DIR=%s' % spec['cuda'].prefix]
nvccflags = ['-ccbin %s -Xcompiler "%s" -Xcompiler %s' % nvccflags = ['-ccbin %s -Xcompiler "%s" -Xcompiler %s' %
(compiler.cxx, opt, compiler.pic_flag)] (compiler.cxx, opt, compiler.cc_pic_flag)]
nvccflags = ' '.join(nvccflags) nvccflags = ' '.join(nvccflags)
makeopts += ['NVCCFLAGS=%s' % nvccflags] makeopts += ['NVCCFLAGS=%s' % nvccflags]
else: else:

View File

@@ -48,7 +48,7 @@ def flag_handler(self, name, flags):
flags.append('-O2') flags.append('-O2')
if '+pic' in self.spec: if '+pic' in self.spec:
flags.append(self.compiler.pic_flag) flags.append(self.compiler.cc_pic_flag)
return (None, None, flags) return (None, None, flags)

View File

@@ -56,7 +56,7 @@ def install(self, spec, prefix):
spec['ncurses'].prefix.lib), spec['ncurses'].prefix.lib),
'MYLIBS=-lncursesw', 'MYLIBS=-lncursesw',
'CC=%s -std=gnu99 %s' % (spack_cc, 'CC=%s -std=gnu99 %s' % (spack_cc,
self.compiler.pic_flag), self.compiler.cc_pic_flag),
target) target)
make('INSTALL_TOP=%s' % prefix, make('INSTALL_TOP=%s' % prefix,
'install') 'install')

View File

@@ -40,6 +40,6 @@ def flag_handler(self, name, flags):
# Compile with PIC, if requested. # Compile with PIC, if requested.
if name == 'cflags' and '+pic' in self.spec: if name == 'cflags' and '+pic' in self.spec:
flags.append(self.compiler.pic_flag) flags.append(self.compiler.cc_pic_flag)
return (flags, None, None) return (flags, None, None)

View File

@@ -79,7 +79,7 @@ def install(self, spec, prefix):
# Process library spec and options # Process library spec and options
options = [] options = []
if '+shared' in spec: if '+shared' in spec:
options.append('COPTIONS={0}'.format(self.compiler.pic_flag)) options.append('COPTIONS={0}'.format(self.compiler.cc_pic_flag))
if spec.variants['build_type'].value == 'Debug': if spec.variants['build_type'].value == 'Debug':
options.append('OPTFLAGS=-g -O0') options.append('OPTFLAGS=-g -O0')
make(*options) make(*options)
@@ -107,7 +107,7 @@ def install(self, spec, prefix):
install(sharefile, prefix.share) install(sharefile, prefix.share)
if '+shared' in spec: if '+shared' in spec:
shared_flags = [self.compiler.pic_flag, '-shared'] shared_flags = [self.compiler.cc_pic_flag, '-shared']
if sys.platform == 'darwin': if sys.platform == 'darwin':
shared_suffix = 'dylib' shared_suffix = 'dylib'
shared_flags.extend(['-Wl,-all_load', 'libmetis.a']) shared_flags.extend(['-Wl,-all_load', 'libmetis.a'])

View File

@@ -307,7 +307,9 @@ def find_optional_library(name, prefix):
if '~static' in spec: if '~static' in spec:
options += ['STATIC=NO'] options += ['STATIC=NO']
if '+shared' in spec: if '+shared' in spec:
options += ['SHARED=YES', 'PICFLAG=%s' % self.compiler.pic_flag] options += [
'SHARED=YES', 'PICFLAG=%s' % self.compiler.cxx_pic_flag
]
if '+mpi' in spec: if '+mpi' in spec:
options += ['MPICXX=%s' % spec['mpi'].mpicxx] options += ['MPICXX=%s' % spec['mpi'].mpicxx]

View File

@@ -125,7 +125,8 @@ def write_makefile_inc(self):
# when building shared libs need -fPIC, otherwise # when building shared libs need -fPIC, otherwise
# /usr/bin/ld: graph.o: relocation R_X86_64_32 against `.rodata.str1.1' # /usr/bin/ld: graph.o: relocation R_X86_64_32 against `.rodata.str1.1'
# can not be used when making a shared object; recompile with -fPIC # can not be used when making a shared object; recompile with -fPIC
fpic = self.compiler.pic_flag if '+shared' in self.spec else '' cpic = self.compiler.cc_pic_flag if '+shared' in self.spec else ''
fpic = self.compiler.fc_pic_flag if '+shared' in self.spec else ''
# TODO: test this part, it needs a full blas, scalapack and # TODO: test this part, it needs a full blas, scalapack and
# partitionning environment with 64bit integers # partitionning environment with 64bit integers
@@ -146,8 +147,8 @@ def write_makefile_inc(self):
]) ])
makefile_conf.extend([ makefile_conf.extend([
'OPTL = %s -O%s' % (fpic, opt_level), 'OPTL = %s -O%s' % (cpic, opt_level),
'OPTC = %s -O%s -DINTSIZE64' % (fpic, opt_level) 'OPTC = %s -O%s -DINTSIZE64' % (cpic, opt_level)
]) ])
else: else:
if using_xlf: if using_xlf:
@@ -157,8 +158,8 @@ def write_makefile_inc(self):
fpic, opt_level)) fpic, opt_level))
makefile_conf.extend([ makefile_conf.extend([
'OPTL = %s -O%s' % (fpic, opt_level), 'OPTL = %s -O%s' % (cpic, opt_level),
'OPTC = %s -O%s' % (fpic, opt_level) 'OPTC = %s -O%s' % (cpic, opt_level)
]) ])
if '+mpi' in self.spec: if '+mpi' in self.spec:

View File

@@ -28,7 +28,7 @@ def url_for_version(self, version):
def configure_args(self): def configure_args(self):
return [ return [
# ADIOS build with -fPIC, so we need it too (avoid linkage issue) # ADIOS build with -fPIC, so we need it too (avoid linkage issue)
'CFLAGS={0}'.format(self.compiler.pic_flag), 'CFLAGS={0}'.format(self.compiler.cc_pic_flag),
# Default is non-shared, but avoid any future surprises # Default is non-shared, but avoid any future surprises
'--disable-shared', '--disable-shared',
] ]

View File

@@ -40,8 +40,10 @@ def setup_build_environment(self, env):
env.unset('TERMINFO') env.unset('TERMINFO')
def flag_handler(self, name, flags): def flag_handler(self, name, flags):
if name == 'cflags' or name == 'cxxflags': if name == 'cflags':
flags.append(self.compiler.pic_flag) flags.append(self.compiler.cc_pic_flag)
elif name == 'cxxflags':
flags.append(self.compiler.cxx_pic_flag)
return (flags, None, None) return (flags, None, None)

View File

@@ -158,7 +158,7 @@ def configure_args(self):
if '~shared' in self.spec or '+pic' in self.spec: if '~shared' in self.spec or '+pic' in self.spec:
# We don't have shared libraries but we still want it to be # We don't have shared libraries but we still want it to be
# possible to use this library in shared builds # possible to use this library in shared builds
cflags.append(self.compiler.pic_flag) cflags.append(self.compiler.cc_pic_flag)
config_args += self.enable_or_disable('dap') config_args += self.enable_or_disable('dap')
# config_args += self.enable_or_disable('cdmremote') # config_args += self.enable_or_disable('cdmremote')

View File

@@ -44,7 +44,7 @@ class NetcdfCxx4(AutotoolsPackage):
def flag_handler(self, name, flags): def flag_handler(self, name, flags):
if name == 'cflags' and '+pic' in self.spec: if name == 'cflags' and '+pic' in self.spec:
flags.append(self.compiler.pic_flag) flags.append(self.compiler.cc_pic_flag)
elif name == 'cppflags': elif name == 'cppflags':
flags.append('-I' + self.spec['netcdf-c'].prefix.include) flags.append('-I' + self.spec['netcdf-c'].prefix.include)

View File

@@ -64,12 +64,16 @@ class NetcdfFortran(AutotoolsPackage):
def flag_handler(self, name, flags): def flag_handler(self, name, flags):
config_flags = None config_flags = None
if name in ['cflags', 'fflags'] and '+pic' in self.spec: if '+pic' in self.spec:
# Unlike NetCDF-C, we add PIC flag only when +pic. Adding the # Unlike NetCDF-C, we add PIC flag only when +pic. Adding the
# flags also when ~shared would make it impossible to build a # flags also when ~shared would make it impossible to build a
# static-only version of the library with NAG. # static-only version of the library with NAG.
config_flags = [self.compiler.pic_flag] if name == 'cflags':
elif name == 'cppflags': config_flags = [self.compiler.cc_pic_flag]
elif name == 'fflags':
config_flags = [self.compiler.f77_pic_flag]
if name == 'cppflags':
config_flags = [self.spec['netcdf-c'].headers.cpp_flags] config_flags = [self.spec['netcdf-c'].headers.cpp_flags]
elif name == 'ldflags': elif name == 'ldflags':
# We need to specify LDFLAGS to get correct dependency_libs # We need to specify LDFLAGS to get correct dependency_libs

View File

@@ -78,8 +78,8 @@ def cmake_args(self):
if '+pic' in spec: if '+pic' in spec:
options.extend([ options.extend([
"-DCMAKE_C_FLAGS=%s" % self.compiler.pic_flag, "-DCMAKE_C_FLAGS=%s" % self.compiler.cc_pic_flag,
"-DCMAKE_Fortran_FLAGS=%s" % self.compiler.pic_flag "-DCMAKE_Fortran_FLAGS=%s" % self.compiler.fc_pic_flag
]) ])
return options return options

View File

@@ -123,7 +123,7 @@ def get_compiler_options(self, spec):
flags = '-O3 -qtune=qp -qarch=qp -q64 -qstrict -qnohot -g' flags = '-O3 -qtune=qp -qarch=qp -q64 -qstrict -qnohot -g'
if self.spec.satisfies('%pgi'): if self.spec.satisfies('%pgi'):
flags += ' ' + self.compiler.pic_flag flags += ' ' + self.compiler.cc_pic_flag
return ['CFLAGS=%s' % flags, return ['CFLAGS=%s' % flags,
'CXXFLAGS=%s' % flags] 'CXXFLAGS=%s' % flags]

View File

@@ -231,8 +231,8 @@ def make_defs(self):
if '~shared' in self.spec: if '~shared' in self.spec:
if '+pic' in self.spec: if '+pic' in self.spec:
make_defs.extend([ make_defs.extend([
'CFLAGS={0}'.format(self.compiler.pic_flag), 'CFLAGS={0}'.format(self.compiler.cc_pic_flag),
'FFLAGS={0}'.format(self.compiler.pic_flag) 'FFLAGS={0}'.format(self.compiler.f77_pic_flag)
]) ])
make_defs += ['NO_SHARED=1'] make_defs += ['NO_SHARED=1']
# fix missing _dggsvd_ and _sggsvd_ # fix missing _dggsvd_ and _sggsvd_

View File

@@ -31,7 +31,7 @@ def configure_args(self):
'CXX={0}'.format(spack_cxx), 'CXX={0}'.format(spack_cxx),
'F77={0}'.format(spack_f77), 'F77={0}'.format(spack_f77),
'FC={0}'.format(spack_fc), 'FC={0}'.format(spack_fc),
'CFLAGS={0}'.format(self.compiler.pic_flag), 'CFLAGS={0}'.format(self.compiler.cc_pic_flag),
'CXXFLAGS={0}'.format(self.compiler.pic_flag), 'CXXFLAGS={0}'.format(self.compiler.cxx_pic_flag),
'PYTHON_FOR_GENERATOR=:' 'PYTHON_FOR_GENERATOR=:',
] ]

View File

@@ -96,8 +96,12 @@ def configure_args(self):
args += self.enable_or_disable('fortran') args += self.enable_or_disable('fortran')
if '+pic' in self.spec: if '+pic' in self.spec:
args.extend(['{0}FLAGS={1}'.format(lang, self.compiler.pic_flag) args.extend([
for lang in ['C', 'CXX', 'F', 'FC']]) 'CFLAGS=' + self.compiler.cc_pic_flag,
'CXXFLAGS=' + self.compiler.cxx_pic_flag,
'FFLAGS=' + self.compiler.f77_pic_flag,
'FCFLAGS=' + self.compiler.fc_pic_flag,
])
if self.version >= Version('1.8'): if self.version >= Version('1.8'):
args.append('--enable-relax-coord-bound') args.append('--enable-relax-coord-bound')

View File

@@ -28,8 +28,8 @@ class Parmgridgen(Package):
def install(self, spec, prefix): def install(self, spec, prefix):
make_opts = [ make_opts = [
'make=make', 'make=make',
'COPTIONS={0}'.format(self.compiler.pic_flag), 'COPTIONS={0}'.format(self.compiler.cc_pic_flag),
'LDOPTIONS={0}'.format(self.compiler.pic_flag), 'LDOPTIONS={0}'.format(self.compiler.cc_pic_flag),
'CC={0}'.format(self.compiler.cc), 'CC={0}'.format(self.compiler.cc),
'LD={0}'.format(self.compiler.cc), 'LD={0}'.format(self.compiler.cc),
'LIBDIR=-L../..', 'LIBDIR=-L../..',

View File

@@ -36,6 +36,9 @@ def cmake_args(self):
def flag_handler(self, name, flags): def flag_handler(self, name, flags):
flags = list(flags) flags = list(flags)
if '+pic' in self.spec and name in ('cflags', 'cxxflags'): if '+pic' in self.spec:
flags.append(self.compiler.pic_flag) if name == 'cflags':
flags.append(self.compiler.cc_pic_flag)
elif name == 'cxxflags':
flags.append(self.compiler.cxx_pic_flag)
return (None, None, flags) return (None, None, flags)

View File

@@ -53,7 +53,7 @@ def configure(self, spec, prefix):
raise InstallError('Unknown/unsupported compiler family') raise InstallError('Unknown/unsupported compiler family')
if '+pic' in spec: if '+pic' in spec:
options.append('-useropt=' + self.compiler.pic_flag) options.append('-useropt=' + self.compiler.cxx_pic_flag)
configure(*options) configure(*options)

View File

@@ -131,7 +131,8 @@ def configure_args(self):
# https://github.com/spack/spack/pull/3081 and # https://github.com/spack/spack/pull/3081 and
# https://github.com/spack/spack/pull/4416 # https://github.com/spack/spack/pull/4416
if spec.satisfies('%intel'): if spec.satisfies('%intel'):
config_args.append('-Accflags={0}'.format(self.compiler.pic_flag)) config_args.append('-Accflags={0}'.format(
self.compiler.cc_pic_flag))
if '+shared' in spec: if '+shared' in spec:
config_args.append('-Duseshrplib') config_args.append('-Duseshrplib')

View File

@@ -33,4 +33,5 @@ class PyLlvmlite(PythonPackage):
def setup_build_environment(self, env): def setup_build_environment(self, env):
# Need to set PIC flag since this is linking statically with LLVM # Need to set PIC flag since this is linking statically with LLVM
env.set('CXX_FLTO_FLAGS', '-flto {0}'.format(self.compiler.pic_flag)) env.set('CXX_FLTO_FLAGS', '-flto {0}'.format(
self.compiler.cxx_pic_flag))

View File

@@ -280,7 +280,7 @@ def configure_args(self):
config_args.append('--without-ensurepip') config_args.append('--without-ensurepip')
if '+pic' in spec: if '+pic' in spec:
config_args.append('CFLAGS={0}'.format(self.compiler.pic_flag)) config_args.append('CFLAGS={0}'.format(self.compiler.cc_pic_flag))
if spec.satisfies('@3.7:'): if spec.satisfies('@3.7:'):
if '+ssl' in spec: if '+ssl' in spec:

View File

@@ -163,7 +163,8 @@ def configure_args(self):
# Set FPICFLAGS for compilers except 'gcc'. # Set FPICFLAGS for compilers except 'gcc'.
if self.compiler.name != 'gcc': if self.compiler.name != 'gcc':
config_args.append('FPICFLAGS={0}'.format(self.compiler.pic_flag)) config_args.append('FPICFLAGS={0}'.format(
self.compiler.cc_pic_flag))
return config_args return config_args

View File

@@ -106,8 +106,8 @@ def configure_args(self):
config_args.append('--with-mpi=openmpi') config_args.append('--with-mpi=openmpi')
config_args.extend([ config_args.extend([
'CFLAGS={0}'.format(self.compiler.pic_flag), 'CFLAGS={0}'.format(self.compiler.cc_pic_flag),
'CXXFLAGS={0}'.format(self.compiler.pic_flag) 'CXXFLAGS={0}'.format(self.compiler.cxx_pic_flag)
]) ])
if "+mpi" in spec: if "+mpi" in spec:

View File

@@ -117,7 +117,7 @@ def configure(self):
makefile_inc.extend([ makefile_inc.extend([
'LIB = .dylib', 'LIB = .dylib',
'CLIBFLAGS = -dynamiclib {0}'.format( 'CLIBFLAGS = -dynamiclib {0}'.format(
self.compiler.pic_flag self.compiler.cc_pic_flag
), ),
'RANLIB = echo', 'RANLIB = echo',
'AR = $(CC)', 'AR = $(CC)',
@@ -126,12 +126,13 @@ def configure(self):
else: else:
makefile_inc.extend([ makefile_inc.extend([
'LIB = .so', 'LIB = .so',
'CLIBFLAGS = -shared {0}'.format(self.compiler.pic_flag), 'CLIBFLAGS = -shared {0}'.format(
self.compiler.cc_pic_flag),
'RANLIB = echo', 'RANLIB = echo',
'AR = $(CC)', 'AR = $(CC)',
'ARFLAGS = -shared $(LDFLAGS) -o' 'ARFLAGS = -shared $(LDFLAGS) -o'
]) ])
cflags.append(self.compiler.pic_flag) cflags.append(self.compiler.cc_pic_flag)
else: else:
makefile_inc.extend([ makefile_inc.extend([
'LIB = .a', 'LIB = .a',

View File

@@ -31,7 +31,7 @@ def makeopts(self, spec, prefix):
return [ return [
"F95={0}".format(self.compiler.fc), "F95={0}".format(self.compiler.fc),
("F95FLAGS={0} -O3 -std=f2003 -ffast-math". ("F95FLAGS={0} -O3 -std=f2003 -ffast-math".
format(self.compiler.pic_flag)), format(self.compiler.fc_pic_flag)),
"OPENMPFLAGS={0}".format(self.compiler.openmp_flag), "OPENMPFLAGS={0}".format(self.compiler.openmp_flag),
"BLAS={0}".format(spec['blas'].libs), "BLAS={0}".format(spec['blas'].libs),
"FFTW={0}".format(spec['fftw'].libs), "FFTW={0}".format(spec['fftw'].libs),

View File

@@ -45,9 +45,14 @@ def flag_handler(self, name, flags):
if spec['hdf5'].satisfies('~shared'): if spec['hdf5'].satisfies('~shared'):
flags.append('-ldl') flags.append('-ldl')
flags.append(spec['readline'].libs.search_flags) flags.append(spec['readline'].libs.search_flags)
elif name in ('cflags', 'cxxflags', 'fcflags'):
if '+pic' in spec: if '+pic' in spec:
flags.append(self.compiler.pic_flag) if name == 'cflags':
flags.append(self.compiler.cc_pic_flag)
elif name == 'cxxflags':
flags.append(self.compiler.cxx_pic_flag)
elif name == 'fcflags':
flags.append(self.compiler.fc_pic_flag)
return (flags, None, None) return (flags, None, None)
@when('%clang@9:') @when('%clang@9:')

View File

@@ -236,7 +236,7 @@ def install(self, spec, prefix):
"CXX=%s" % spec['mpi'].mpicxx, "CXX=%s" % spec['mpi'].mpicxx,
"PARALLEL=%s" % mpi_id, "PARALLEL=%s" % mpi_id,
"PQUAL=-%s" % mpi_id, "PQUAL=-%s" % mpi_id,
"OPTFLAGS=-O2 -DNDEBUG " + self.compiler.pic_flag) "OPTFLAGS=-O2 -DNDEBUG " + self.compiler.cc_pic_flag)
libname = 'libSimPartitionWrapper-' + mpi_id + '.a' libname = 'libSimPartitionWrapper-' + mpi_id + '.a'
wrapperlibpath = join_path(workdir, 'lib', libname) wrapperlibpath = join_path(workdir, 'lib', libname)
install(wrapperlibpath, join_path(prefix.lib, self.oslib)) install(wrapperlibpath, join_path(prefix.lib, self.oslib))

View File

@@ -37,8 +37,11 @@ def cmake_args(self):
def flag_handler(self, name, flags): def flag_handler(self, name, flags):
flags = list(flags) flags = list(flags)
if '+pic' in self.spec and name in ('cflags', 'cxxflags'): if '+pic' in self.spec:
flags.append(self.compiler.pic_flag) if name == 'cflags':
flags.append(self.compiler.cc_pic_flag)
elif name == 'cxxflags':
flags.append(self.compiler.cxx_pic_flag)
return (None, None, flags) return (None, None, flags)
@run_after('install') @run_after('install')

View File

@@ -122,6 +122,6 @@ def build_libsqlitefunctions(self):
if '+functions' in self.spec: if '+functions' in self.spec:
libraryname = 'libsqlitefunctions.' + dso_suffix libraryname = 'libsqlitefunctions.' + dso_suffix
cc = Executable(spack_cc) cc = Executable(spack_cc)
cc(self.compiler.pic_flag, '-lm', '-shared', cc(self.compiler.cc_pic_flag, '-lm', '-shared',
'extension-functions.c', '-o', libraryname) 'extension-functions.c', '-o', libraryname)
install(libraryname, self.prefix.lib) install(libraryname, self.prefix.lib)

View File

@@ -63,7 +63,8 @@ def install(self, spec, prefix):
# logic in it. Any kind of customization will need to go through # logic in it. Any kind of customization will need to go through
# filtering of that file # filtering of that file
pic_flag = self.compiler.pic_flag if '+pic' in spec else '' cc_pic_flag = self.compiler.cc_pic_flag if '+pic' in spec else ''
f77_pic_flag = self.compiler.f77_pic_flag if '+pic' in spec else ''
make_args = [ make_args = [
# By default, the Makefile uses the Intel compilers if # By default, the Makefile uses the Intel compilers if
@@ -78,11 +79,11 @@ def install(self, spec, prefix):
'CUDA_PATH=%s' % (spec['cuda'].prefix if '+cuda' in spec else ''), 'CUDA_PATH=%s' % (spec['cuda'].prefix if '+cuda' in spec else ''),
'CFOPENMP=%s' % (self.compiler.openmp_flag 'CFOPENMP=%s' % (self.compiler.openmp_flag
if '+openmp' in spec else ''), if '+openmp' in spec else ''),
'CFLAGS=-O3 %s' % pic_flag, 'CFLAGS=-O3 %s' % cc_pic_flag,
# Both FFLAGS and F77FLAGS are used in SuiteSparse makefiles; # Both FFLAGS and F77FLAGS are used in SuiteSparse makefiles;
# FFLAGS is used in CHOLMOD, F77FLAGS is used in AMD and UMFPACK. # FFLAGS is used in CHOLMOD, F77FLAGS is used in AMD and UMFPACK.
'FFLAGS=%s' % pic_flag, 'FFLAGS=%s' % f77_pic_flag,
'F77FLAGS=%s' % pic_flag, 'F77FLAGS=%s' % f77_pic_flag,
# use Spack's metis in CHOLMOD/Partition module, # use Spack's metis in CHOLMOD/Partition module,
# otherwise internal Metis will be compiled # otherwise internal Metis will be compiled
'MY_METIS_LIB=%s' % spec['metis'].libs.ld_flags, 'MY_METIS_LIB=%s' % spec['metis'].libs.ld_flags,

View File

@@ -211,7 +211,7 @@ def cmake_args(self):
def on_off(varstr): def on_off(varstr):
return 'ON' if varstr in self.spec else 'OFF' return 'ON' if varstr in self.spec else 'OFF'
fortran_flag = self.compiler.pic_flag fortran_flag = self.compiler.f77_pic_flag
if (spec.satisfies('%clang platform=darwin')) and ('+fcmix' in spec): if (spec.satisfies('%clang platform=darwin')) and ('+fcmix' in spec):
f77 = Executable(self.compiler.f77) f77 = Executable(self.compiler.f77)
libgfortran = LibraryList(f77('--print-file-name', libgfortran = LibraryList(f77('--print-file-name',

View File

@@ -73,10 +73,10 @@ def install(self, spec, prefix):
if '+pic' in spec: if '+pic' in spec:
config.extend([ config.extend([
# Use these lines instead when pic_flag capability arrives # Use these lines instead when pic_flag capability arrives
'CFLAGS = -O3 {0}'.format(self.compiler.pic_flag), 'CFLAGS = -O3 {0}'.format(self.compiler.cc_pic_flag),
'NOOPTS = {0}'.format(self.compiler.pic_flag), 'NOOPTS = {0}'.format(self.compiler.cc_pic_flag),
'FFLAGS = -O2 {0}'.format(self.compiler.pic_flag), 'FFLAGS = -O2 {0}'.format(self.compiler.f77_pic_flag),
'LOADOPTS = {0}'.format(self.compiler.pic_flag) 'LOADOPTS = {0}'.format(self.compiler.cc_pic_flag)
]) ])
else: else:
config.extend([ config.extend([

View File

@@ -51,8 +51,8 @@ class Thrift(Package):
def setup_build_environment(self, env): def setup_build_environment(self, env):
if '+pic' in self.spec: if '+pic' in self.spec:
env.append_flags('CFLAGS', self.compiler.pic_flag) env.append_flags('CFLAGS', self.compiler.cc_pic_flag)
env.append_flags('CXXFLAGS', self.compiler.pic_flag) env.append_flags('CXXFLAGS', self.compiler.cxx_pic_flag)
def install(self, spec, prefix): def install(self, spec, prefix):
env['PY_PREFIX'] = prefix env['PY_PREFIX'] = prefix

View File

@@ -26,6 +26,6 @@ class Unrar(MakefilePackage):
def edit(self, spec, prefix): def edit(self, spec, prefix):
makefile = FileFilter("makefile") makefile = FileFilter("makefile")
makefile.filter( makefile.filter(
"LIBFLAGS=-fPIC", "LIBFLAGS={0}".format(self.compiler.pic_flag) "LIBFLAGS=-fPIC", "LIBFLAGS={0}".format(self.compiler.cc_pic_flag)
) )
makefile.filter("DESTDIR=/usr", "DESTDIR={0}".format(self.prefix)) makefile.filter("DESTDIR=/usr", "DESTDIR={0}".format(self.prefix))

View File

@@ -72,8 +72,8 @@ def cmake_args(self):
'-DVISIT_VTK_DIR:PATH=' + spec['vtk'].prefix, '-DVISIT_VTK_DIR:PATH=' + spec['vtk'].prefix,
'-DVISIT_ZLIB_DIR:PATH=' + spec['zlib'].prefix, '-DVISIT_ZLIB_DIR:PATH=' + spec['zlib'].prefix,
'-DVISIT_USE_GLEW=OFF', '-DVISIT_USE_GLEW=OFF',
'-DCMAKE_CXX_FLAGS=' + self.compiler.pic_flag, '-DCMAKE_CXX_FLAGS=' + self.compiler.cxx_pic_flag,
'-DCMAKE_C_FLAGS=' + self.compiler.pic_flag, '-DCMAKE_C_FLAGS=' + self.compiler.cc_pic_flag,
] ]
if '+python' in spec: if '+python' in spec:

View File

@@ -30,7 +30,7 @@ def edit(self, spec, prefix):
# CFLAGS=-Wall -ansi -pedantic -O3 # CFLAGS=-Wall -ansi -pedantic -O3
cflags = '' cflags = ''
if '+pic' in spec: if '+pic' in spec:
cflags += self.compiler.pic_flag cflags += self.compiler.cc_pic_flag
filter_file(r'CFLAGS=.*', filter_file(r'CFLAGS=.*',
'CFLAGS={0}'.format(cflags), 'CFLAGS={0}'.format(cflags),
'config.mk') 'config.mk')

View File

@@ -40,7 +40,7 @@ def libs(self):
def setup_build_environment(self, env): def setup_build_environment(self, env):
if '+pic' in self.spec: if '+pic' in self.spec:
env.append_flags('CFLAGS', self.compiler.pic_flag) env.append_flags('CFLAGS', self.compiler.cc_pic_flag)
if '+optimize' in self.spec: if '+optimize' in self.spec:
env.append_flags('CFLAGS', '-O2') env.append_flags('CFLAGS', '-O2')

View File

@@ -95,7 +95,7 @@ def configure_args(self):
'RANLIB=echo', 'RANLIB=echo',
'--with-ar=$(CXX) -shared $(LDFLAGS) -o' '--with-ar=$(CXX) -shared $(LDFLAGS) -o'
]) ])
config_cflags.append(self.compiler.pic_flag) config_cflags.append(self.compiler.cc_pic_flag)
if spec.satisfies('%gcc'): if spec.satisfies('%gcc'):
config_args.append('--with-libs=-lgfortran') config_args.append('--with-libs=-lgfortran')
if spec.satisfies('%intel'): if spec.satisfies('%intel'):

View File

@@ -27,7 +27,7 @@ class Zstd(MakefilePackage):
def setup_build_environment(self, env): def setup_build_environment(self, env):
if '+pic' in self.spec: if '+pic' in self.spec:
env.append_flags('CFLAGS', self.compiler.pic_flag) env.append_flags('CFLAGS', self.compiler.cc_pic_flag)
def build(self, spec, prefix): def build(self, spec, prefix):
make('PREFIX={0}'.format(prefix)) make('PREFIX={0}'.format(prefix))