diff options
author | Adam J. Stewart <ajstewart426@gmail.com> | 2020-04-17 16:28:51 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-17 16:28:51 -0500 |
commit | 284e450c91f5fdc0a71f6c1f7c2823c84918122f (patch) | |
tree | 868961115a2ce1031098e2db7113b043a384d3c8 | |
parent | ad8977467bc3949adf3954c1f03c9de715ddf95f (diff) | |
download | spack-284e450c91f5fdc0a71f6c1f7c2823c84918122f.tar.gz spack-284e450c91f5fdc0a71f6c1f7c2823c84918122f.tar.bz2 spack-284e450c91f5fdc0a71f6c1f7c2823c84918122f.tar.xz spack-284e450c91f5fdc0a71f6c1f7c2823c84918122f.zip |
Language-specific PIC flags (#15474)
* Language-specific PIC flags
* Add tests for every compiler flag
* Fix bad rebase
* pic_flag -> cxx_pic_flag
62 files changed, 415 insertions, 160 deletions
diff --git a/lib/spack/spack/build_systems/autotools.py b/lib/spack/spack/build_systems/autotools.py index 5b4f223d41..6591b6495b 100644 --- a/lib/spack/spack/build_systems/autotools.py +++ b/lib/spack/spack/build_systems/autotools.py @@ -169,7 +169,7 @@ class AutotoolsPackage(PackageBase): line = 'wl="-Wl,"\n' if line == 'pic_flag=""\n': line = 'pic_flag="{0}"\n'\ - .format(self.compiler.pic_flag) + .format(self.compiler.cc_pic_flag) sys.stdout.write(line) @property diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py index 9fc7aa51a2..8afbe48c0c 100644 --- a/lib/spack/spack/compiler.py +++ b/lib/spack/spack/compiler.py @@ -410,6 +410,30 @@ class Compiler(object): "the C11 standard", "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 # specific compiler executables. This is used when discovering compilers. diff --git a/lib/spack/spack/compilers/arm.py b/lib/spack/spack/compilers/arm.py index ca17ff42e8..2f6e195006 100644 --- a/lib/spack/spack/compilers/arm.py +++ b/lib/spack/spack/compilers/arm.py @@ -80,7 +80,19 @@ class Arm(spack.compiler.Compiler): return "-std=c11" @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" required_libs = ['libclang', 'libflang'] diff --git a/lib/spack/spack/compilers/cce.py b/lib/spack/spack/compilers/cce.py index 23a1771e9c..7aedb55a5d 100644 --- a/lib/spack/spack/compilers/cce.py +++ b/lib/spack/spack/compilers/cce.py @@ -68,5 +68,17 @@ class Cce(Compiler): '< 8.5') @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" diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py index c8df63e533..b14eaa1278 100644 --- a/lib/spack/spack/compilers/clang.py +++ b/lib/spack/spack/compilers/clang.py @@ -174,7 +174,19 @@ class Clang(Compiler): return "-std=c11" @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" required_libs = ['libclang'] diff --git a/lib/spack/spack/compilers/fj.py b/lib/spack/spack/compilers/fj.py index 1f7d52f026..54d9308c4a 100644 --- a/lib/spack/spack/compilers/fj.py +++ b/lib/spack/spack/compilers/fj.py @@ -59,5 +59,17 @@ class Fj(spack.compiler.Compiler): return "-std=c11" @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" diff --git a/lib/spack/spack/compilers/gcc.py b/lib/spack/spack/compilers/gcc.py index da559d554c..fc9074a67a 100644 --- a/lib/spack/spack/compilers/gcc.py +++ b/lib/spack/spack/compilers/gcc.py @@ -110,7 +110,19 @@ class Gcc(Compiler): return "-std=c11" @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" required_libs = ['libgcc', 'libgfortran'] diff --git a/lib/spack/spack/compilers/intel.py b/lib/spack/spack/compilers/intel.py index bc0e44b274..c7d853e3fa 100644 --- a/lib/spack/spack/compilers/intel.py +++ b/lib/spack/spack/compilers/intel.py @@ -92,7 +92,19 @@ class Intel(Compiler): return "-std=c1x" @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" @property diff --git a/lib/spack/spack/compilers/nag.py b/lib/spack/spack/compilers/nag.py index b7ef2297b8..e5dffa4a67 100644 --- a/lib/spack/spack/compilers/nag.py +++ b/lib/spack/spack/compilers/nag.py @@ -41,7 +41,11 @@ class Nag(spack.compiler.Compiler): return "-std=c++11" @property - def pic_flag(self): + def f77_pic_flag(self): + return "-PIC" + + @property + def fc_pic_flag(self): return "-PIC" # Unlike other compilers, the NAG compiler passes options to GCC, which diff --git a/lib/spack/spack/compilers/pgi.py b/lib/spack/spack/compilers/pgi.py index 7da991754f..13d8f69ec5 100644 --- a/lib/spack/spack/compilers/pgi.py +++ b/lib/spack/spack/compilers/pgi.py @@ -46,7 +46,19 @@ class Pgi(Compiler): return "-std=c++11" @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" required_libs = ['libpgc', 'libpgf90'] diff --git a/lib/spack/spack/compilers/xl.py b/lib/spack/spack/compilers/xl.py index 36aa4dae7d..46a5002e25 100644 --- a/lib/spack/spack/compilers/xl.py +++ b/lib/spack/spack/compilers/xl.py @@ -70,7 +70,19 @@ class Xl(Compiler): '< 12.1') @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" @property diff --git a/lib/spack/spack/test/compilers.py b/lib/spack/spack/test/compilers.py index 13e3d9e695..24115ba562 100644 --- a/lib/spack/spack/test/compilers.py +++ b/lib/spack/spack/test/compilers.py @@ -17,13 +17,13 @@ import spack.compilers as compilers import spack.compilers.arm import spack.compilers.cce import spack.compilers.clang +import spack.compilers.fj import spack.compilers.gcc import spack.compilers.intel import spack.compilers.nag import spack.compilers.pgi import spack.compilers.xl import spack.compilers.xl_r -import spack.compilers.fj 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 # implementations of 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("cxx11_flag") unsupported_flag_test("cxx14_flag") unsupported_flag_test("cxx17_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. -def test_clang_flags(): - # Common - supported_flag_test("pic_flag", "-fPIC", "gcc@4.0") +def test_arm_flags(): + supported_flag_test("openmp_flag", "-fopenmp", "arm@1.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. supported_flag_test( "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") 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("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. 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") 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("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(): - supported_flag_test("openmp_flag", "-h omp", "cce@1.0") - supported_flag_test("cxx11_flag", "-h std=c++11", "cce@1.0") - supported_flag_test("pic_flag", "-h PIC", "cce@1.0") +def test_fj_flags(): + supported_flag_test("openmp_flag", "-Kopenmp", "fj@4.0.0") + supported_flag_test("cxx98_flag", "-std=c++98", "fj@4.0.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(): @@ -275,7 +331,17 @@ def test_gcc_flags(): supported_flag_test("cxx14_flag", "-std=c++14", "gcc@4.9") supported_flag_test("cxx14_flag", "", "gcc@6.0") 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(): @@ -287,43 +353,105 @@ def test_intel_flags(): 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++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(): supported_flag_test("openmp_flag", "-openmp", "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(): supported_flag_test("openmp_flag", "-mp", "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(): supported_flag_test("openmp_flag", "-qsmp=omp", "xl@1.0") unsupported_flag_test("cxx11_flag", "xl@13.0") 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(): supported_flag_test("openmp_flag", "-qsmp=omp", "xl_r@1.0") unsupported_flag_test("cxx11_flag", "xl_r@13.0") 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(): - supported_flag_test("openmp_flag", "-Kopenmp", "fj@4.0.0") - supported_flag_test("cxx98_flag", "-std=c++98", "fj@4.0.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("pic_flag", "-KPIC", "fj@4.0.0") +@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 + '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.0.0.73'), + ('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') @@ -364,21 +492,23 @@ def test_clang_version_detection(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 - '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.0.0.73'), - ('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') + # 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_arm_version_detection(version_str, expected_version): - version = spack.compilers.arm.Arm.extract_version_from_output(version_str) +def test_fj_version_detection(version_str, expected_version): + version = spack.compilers.fj.Fj.extract_version_from_output(version_str) assert version == expected_version @@ -454,37 +584,6 @@ def test_xl_version_detection(version_str, 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', [ ('gcc@4.7.2', False), ('clang@3.3', False), ('clang@8.0.0', True) ]) diff --git a/var/spack/repos/builtin/packages/adios/package.py b/var/spack/repos/builtin/packages/adios/package.py index 6994963898..c850b3058b 100644 --- a/var/spack/repos/builtin/packages/adios/package.py +++ b/var/spack/repos/builtin/packages/adios/package.py @@ -133,7 +133,7 @@ class Adios(AutotoolsPackage): extra_args = [ # 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') diff --git a/var/spack/repos/builtin/packages/boost/package.py b/var/spack/repos/builtin/packages/boost/package.py index 0f4c8394cf..cc223d2f7e 100644 --- a/var/spack/repos/builtin/packages/boost/package.py +++ b/var/spack/repos/builtin/packages/boost/package.py @@ -371,7 +371,7 @@ class Boost(Package): cxxflags.append(flag) 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 # and at least in clang 3.9 still fails to build diff --git a/var/spack/repos/builtin/packages/cantera/package.py b/var/spack/repos/builtin/packages/cantera/package.py index 4e2728fad8..4b38ccc7b3 100644 --- a/var/spack/repos/builtin/packages/cantera/package.py +++ b/var/spack/repos/builtin/packages/cantera/package.py @@ -59,7 +59,7 @@ class Cantera(SConsPackage): 'CC={0}'.format(spack_cc), 'CXX={0}'.format(spack_cxx), '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 'env_vars=all' ] diff --git a/var/spack/repos/builtin/packages/dataspaces/package.py b/var/spack/repos/builtin/packages/dataspaces/package.py index 6e2120d399..be5c5c884f 100644 --- a/var/spack/repos/builtin/packages/dataspaces/package.py +++ b/var/spack/repos/builtin/packages/dataspaces/package.py @@ -56,7 +56,7 @@ class Dataspaces(AutotoolsPackage): args = [] cookie = self.spec.variants['gni-cookie'].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'): args.append('--enable-dimes') if self.spec.satisfies('+cray-drc'): diff --git a/var/spack/repos/builtin/packages/f77-zmq/package.py b/var/spack/repos/builtin/packages/f77-zmq/package.py index bab4469442..955ed2ecd6 100644 --- a/var/spack/repos/builtin/packages/f77-zmq/package.py +++ b/var/spack/repos/builtin/packages/f77-zmq/package.py @@ -31,7 +31,7 @@ class F77Zmq(MakefilePackage): makefile = FileFilter('Makefile') makefile.filter('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('PREFIX=.*', 'PREFIX={0}'.format(self.prefix)) p = self.spec['libzmq'].prefix diff --git a/var/spack/repos/builtin/packages/fmt/package.py b/var/spack/repos/builtin/packages/fmt/package.py index be39f6cc83..e54bea78b4 100644 --- a/var/spack/repos/builtin/packages/fmt/package.py +++ b/var/spack/repos/builtin/packages/fmt/package.py @@ -61,8 +61,8 @@ class Fmt(CMakePackage): if '+pic' in spec: args.extend([ - '-DCMAKE_C_FLAGS={0}'.format(self.compiler.pic_flag), - '-DCMAKE_CXX_FLAGS={0}'.format(self.compiler.pic_flag) + '-DCMAKE_C_FLAGS={0}'.format(self.compiler.cc_pic_flag), + '-DCMAKE_CXX_FLAGS={0}'.format(self.compiler.cxx_pic_flag) ]) args.append('-DCMAKE_CXX_STANDARD={0}'.format( diff --git a/var/spack/repos/builtin/packages/gasnet/package.py b/var/spack/repos/builtin/packages/gasnet/package.py index 4a48df005e..8ead7c3796 100644 --- a/var/spack/repos/builtin/packages/gasnet/package.py +++ b/var/spack/repos/builtin/packages/gasnet/package.py @@ -60,8 +60,8 @@ class Gasnet(AutotoolsPackage): '--with-segment-mmap-max=%s ' % (self.spec.variants['segment-mmap-max'].value), # for consumers with shared libs - 'CC=%s %s' % (spack_cc, self.compiler.pic_flag), - 'CXX=%s %s' % (spack_cxx, self.compiler.pic_flag), + "CC=%s %s" % (spack_cc, self.compiler.cc_pic_flag), + "CXX=%s %s" % (spack_cxx, self.compiler.cxx_pic_flag), ] if '+aligned-segments' in self.spec: @@ -80,7 +80,7 @@ class Gasnet(AutotoolsPackage): '--disable-ibv', '--disable-seq', '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: args.extend(['--enable-ibv', diff --git a/var/spack/repos/builtin/packages/hdf/package.py b/var/spack/repos/builtin/packages/hdf/package.py index 14f04ea294..67c2744470 100644 --- a/var/spack/repos/builtin/packages/hdf/package.py +++ b/var/spack/repos/builtin/packages/hdf/package.py @@ -35,7 +35,7 @@ class Hdf(AutotoolsPackage): spec = self.spec 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-zlib={0}'.format(spec['zlib'].prefix), '--disable-netcdf', # must be disabled to build NetCDF with HDF4 diff --git a/var/spack/repos/builtin/packages/hdf5/package.py b/var/spack/repos/builtin/packages/hdf5/package.py index 9d5505b5f7..b4f427ff7b 100644 --- a/var/spack/repos/builtin/packages/hdf5/package.py +++ b/var/spack/repos/builtin/packages/hdf5/package.py @@ -259,8 +259,11 @@ class Hdf5(AutotoolsPackage): extra_args.append('--enable-static-exec') if '+pic' in self.spec: - extra_args += ['%s=%s' % (f, self.compiler.pic_flag) - for f in ['CFLAGS', 'CXXFLAGS', 'FCFLAGS']] + extra_args.extend([ + 'CFLAGS=' + self.compiler.cc_pic_flag, + 'CXXFLAGS=' + self.compiler.cxx_pic_flag, + 'FCFLAGS=' + self.compiler.fc_pic_flag, + ]) if '+mpi' in self.spec: # The HDF5 configure script warns if cxx and mpi are enabled diff --git a/var/spack/repos/builtin/packages/libceed/package.py b/var/spack/repos/builtin/packages/libceed/package.py index 3b327a5058..64d04a7b89 100644 --- a/var/spack/repos/builtin/packages/libceed/package.py +++ b/var/spack/repos/builtin/packages/libceed/package.py @@ -81,7 +81,7 @@ class Libceed(Package): if '+cuda' in spec: makeopts += ['CUDA_DIR=%s' % spec['cuda'].prefix] nvccflags = ['-ccbin %s -Xcompiler "%s" -Xcompiler %s' % - (compiler.cxx, opt, compiler.pic_flag)] + (compiler.cxx, opt, compiler.cc_pic_flag)] nvccflags = ' '.join(nvccflags) makeopts += ['NVCCFLAGS=%s' % nvccflags] else: diff --git a/var/spack/repos/builtin/packages/libiberty/package.py b/var/spack/repos/builtin/packages/libiberty/package.py index fd3c6d6ea9..2168223477 100644 --- a/var/spack/repos/builtin/packages/libiberty/package.py +++ b/var/spack/repos/builtin/packages/libiberty/package.py @@ -48,7 +48,7 @@ class Libiberty(AutotoolsPackage, GNUMirrorPackage): flags.append('-O2') if '+pic' in self.spec: - flags.append(self.compiler.pic_flag) + flags.append(self.compiler.cc_pic_flag) return (None, None, flags) diff --git a/var/spack/repos/builtin/packages/lua/package.py b/var/spack/repos/builtin/packages/lua/package.py index 910d8b252f..1c6b152aa3 100644 --- a/var/spack/repos/builtin/packages/lua/package.py +++ b/var/spack/repos/builtin/packages/lua/package.py @@ -56,7 +56,7 @@ class Lua(Package): spec['ncurses'].prefix.lib), 'MYLIBS=-lncursesw', 'CC=%s -std=gnu99 %s' % (spack_cc, - self.compiler.pic_flag), + self.compiler.cc_pic_flag), target) make('INSTALL_TOP=%s' % prefix, 'install') diff --git a/var/spack/repos/builtin/packages/mbedtls/package.py b/var/spack/repos/builtin/packages/mbedtls/package.py index 73247217e4..bbe2bd0412 100644 --- a/var/spack/repos/builtin/packages/mbedtls/package.py +++ b/var/spack/repos/builtin/packages/mbedtls/package.py @@ -40,6 +40,6 @@ class Mbedtls(CMakePackage): # Compile with PIC, if requested. 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) diff --git a/var/spack/repos/builtin/packages/metis/package.py b/var/spack/repos/builtin/packages/metis/package.py index f9371c4b2d..ad0f78566b 100644 --- a/var/spack/repos/builtin/packages/metis/package.py +++ b/var/spack/repos/builtin/packages/metis/package.py @@ -79,7 +79,7 @@ class Metis(Package): # Process library spec and options options = [] 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': options.append('OPTFLAGS=-g -O0') make(*options) @@ -107,7 +107,7 @@ class Metis(Package): install(sharefile, prefix.share) if '+shared' in spec: - shared_flags = [self.compiler.pic_flag, '-shared'] + shared_flags = [self.compiler.cc_pic_flag, '-shared'] if sys.platform == 'darwin': shared_suffix = 'dylib' shared_flags.extend(['-Wl,-all_load', 'libmetis.a']) diff --git a/var/spack/repos/builtin/packages/mfem/package.py b/var/spack/repos/builtin/packages/mfem/package.py index 08a4790f68..f754cd915e 100644 --- a/var/spack/repos/builtin/packages/mfem/package.py +++ b/var/spack/repos/builtin/packages/mfem/package.py @@ -307,7 +307,9 @@ class Mfem(Package): if '~static' in spec: options += ['STATIC=NO'] 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: options += ['MPICXX=%s' % spec['mpi'].mpicxx] diff --git a/var/spack/repos/builtin/packages/mumps/package.py b/var/spack/repos/builtin/packages/mumps/package.py index de34b6aa19..5a5110d1e1 100644 --- a/var/spack/repos/builtin/packages/mumps/package.py +++ b/var/spack/repos/builtin/packages/mumps/package.py @@ -125,7 +125,8 @@ class Mumps(Package): # when building shared libs need -fPIC, otherwise # /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 - 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 # partitionning environment with 64bit integers @@ -146,8 +147,8 @@ class Mumps(Package): ]) makefile_conf.extend([ - 'OPTL = %s -O%s' % (fpic, opt_level), - 'OPTC = %s -O%s -DINTSIZE64' % (fpic, opt_level) + 'OPTL = %s -O%s' % (cpic, opt_level), + 'OPTC = %s -O%s -DINTSIZE64' % (cpic, opt_level) ]) else: if using_xlf: @@ -157,8 +158,8 @@ class Mumps(Package): fpic, opt_level)) makefile_conf.extend([ - 'OPTL = %s -O%s' % (fpic, opt_level), - 'OPTC = %s -O%s' % (fpic, opt_level) + 'OPTL = %s -O%s' % (cpic, opt_level), + 'OPTC = %s -O%s' % (cpic, opt_level) ]) if '+mpi' in self.spec: diff --git a/var/spack/repos/builtin/packages/mxml/package.py b/var/spack/repos/builtin/packages/mxml/package.py index 1f57c2b95d..4fa90802a6 100644 --- a/var/spack/repos/builtin/packages/mxml/package.py +++ b/var/spack/repos/builtin/packages/mxml/package.py @@ -28,7 +28,7 @@ class Mxml(AutotoolsPackage): def configure_args(self): return [ # 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 '--disable-shared', ] diff --git a/var/spack/repos/builtin/packages/ncurses/package.py b/var/spack/repos/builtin/packages/ncurses/package.py index cfb122623d..55d1900c4c 100644 --- a/var/spack/repos/builtin/packages/ncurses/package.py +++ b/var/spack/repos/builtin/packages/ncurses/package.py @@ -40,8 +40,10 @@ class Ncurses(AutotoolsPackage, GNUMirrorPackage): env.unset('TERMINFO') def flag_handler(self, name, flags): - if name == 'cflags' or name == 'cxxflags': - 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 (flags, None, None) diff --git a/var/spack/repos/builtin/packages/netcdf-c/package.py b/var/spack/repos/builtin/packages/netcdf-c/package.py index ac12ab42b4..42c28e5321 100644 --- a/var/spack/repos/builtin/packages/netcdf-c/package.py +++ b/var/spack/repos/builtin/packages/netcdf-c/package.py @@ -158,7 +158,7 @@ class NetcdfC(AutotoolsPackage): if '~shared' in self.spec or '+pic' in self.spec: # We don't have shared libraries but we still want it to be # 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('cdmremote') diff --git a/var/spack/repos/builtin/packages/netcdf-cxx4/package.py b/var/spack/repos/builtin/packages/netcdf-cxx4/package.py index d11bc4ea41..3847cc48dd 100644 --- a/var/spack/repos/builtin/packages/netcdf-cxx4/package.py +++ b/var/spack/repos/builtin/packages/netcdf-cxx4/package.py @@ -44,7 +44,7 @@ class NetcdfCxx4(AutotoolsPackage): def flag_handler(self, name, flags): if name == 'cflags' and '+pic' in self.spec: - flags.append(self.compiler.pic_flag) + flags.append(self.compiler.cc_pic_flag) elif name == 'cppflags': flags.append('-I' + self.spec['netcdf-c'].prefix.include) diff --git a/var/spack/repos/builtin/packages/netcdf-fortran/package.py b/var/spack/repos/builtin/packages/netcdf-fortran/package.py index 51ff028276..1b55df1507 100644 --- a/var/spack/repos/builtin/packages/netcdf-fortran/package.py +++ b/var/spack/repos/builtin/packages/netcdf-fortran/package.py @@ -64,12 +64,16 @@ class NetcdfFortran(AutotoolsPackage): def flag_handler(self, name, flags): 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 # flags also when ~shared would make it impossible to build a # static-only version of the library with NAG. - config_flags = [self.compiler.pic_flag] - elif name == 'cppflags': + if name == 'cflags': + 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] elif name == 'ldflags': # We need to specify LDFLAGS to get correct dependency_libs diff --git a/var/spack/repos/builtin/packages/netlib-scalapack/package.py b/var/spack/repos/builtin/packages/netlib-scalapack/package.py index a135e7b2ff..75993c4701 100644 --- a/var/spack/repos/builtin/packages/netlib-scalapack/package.py +++ b/var/spack/repos/builtin/packages/netlib-scalapack/package.py @@ -78,8 +78,8 @@ class NetlibScalapack(CMakePackage): if '+pic' in spec: options.extend([ - "-DCMAKE_C_FLAGS=%s" % self.compiler.pic_flag, - "-DCMAKE_Fortran_FLAGS=%s" % self.compiler.pic_flag + "-DCMAKE_C_FLAGS=%s" % self.compiler.cc_pic_flag, + "-DCMAKE_Fortran_FLAGS=%s" % self.compiler.fc_pic_flag ]) return options diff --git a/var/spack/repos/builtin/packages/neuron/package.py b/var/spack/repos/builtin/packages/neuron/package.py index 15a0f94ea9..8f3371a159 100644 --- a/var/spack/repos/builtin/packages/neuron/package.py +++ b/var/spack/repos/builtin/packages/neuron/package.py @@ -123,7 +123,7 @@ class Neuron(Package): flags = '-O3 -qtune=qp -qarch=qp -q64 -qstrict -qnohot -g' if self.spec.satisfies('%pgi'): - flags += ' ' + self.compiler.pic_flag + flags += ' ' + self.compiler.cc_pic_flag return ['CFLAGS=%s' % flags, 'CXXFLAGS=%s' % flags] diff --git a/var/spack/repos/builtin/packages/openblas/package.py b/var/spack/repos/builtin/packages/openblas/package.py index 71d2ec4a6b..7d71702de0 100644 --- a/var/spack/repos/builtin/packages/openblas/package.py +++ b/var/spack/repos/builtin/packages/openblas/package.py @@ -231,8 +231,8 @@ class Openblas(MakefilePackage): if '~shared' in self.spec: if '+pic' in self.spec: make_defs.extend([ - 'CFLAGS={0}'.format(self.compiler.pic_flag), - 'FFLAGS={0}'.format(self.compiler.pic_flag) + 'CFLAGS={0}'.format(self.compiler.cc_pic_flag), + 'FFLAGS={0}'.format(self.compiler.f77_pic_flag) ]) make_defs += ['NO_SHARED=1'] # fix missing _dggsvd_ and _sggsvd_ diff --git a/var/spack/repos/builtin/packages/otf2/package.py b/var/spack/repos/builtin/packages/otf2/package.py index a123f0e887..a2c197e98b 100644 --- a/var/spack/repos/builtin/packages/otf2/package.py +++ b/var/spack/repos/builtin/packages/otf2/package.py @@ -31,7 +31,7 @@ class Otf2(AutotoolsPackage): 'CXX={0}'.format(spack_cxx), 'F77={0}'.format(spack_f77), 'FC={0}'.format(spack_fc), - 'CFLAGS={0}'.format(self.compiler.pic_flag), - 'CXXFLAGS={0}'.format(self.compiler.pic_flag), - 'PYTHON_FOR_GENERATOR=:' + 'CFLAGS={0}'.format(self.compiler.cc_pic_flag), + 'CXXFLAGS={0}'.format(self.compiler.cxx_pic_flag), + 'PYTHON_FOR_GENERATOR=:', ] diff --git a/var/spack/repos/builtin/packages/parallel-netcdf/package.py b/var/spack/repos/builtin/packages/parallel-netcdf/package.py index 384717d05e..dc2f1b4ac3 100644 --- a/var/spack/repos/builtin/packages/parallel-netcdf/package.py +++ b/var/spack/repos/builtin/packages/parallel-netcdf/package.py @@ -96,8 +96,12 @@ class ParallelNetcdf(AutotoolsPackage): args += self.enable_or_disable('fortran') if '+pic' in self.spec: - args.extend(['{0}FLAGS={1}'.format(lang, self.compiler.pic_flag) - for lang in ['C', 'CXX', 'F', 'FC']]) + args.extend([ + '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'): args.append('--enable-relax-coord-bound') diff --git a/var/spack/repos/builtin/packages/parmgridgen/package.py b/var/spack/repos/builtin/packages/parmgridgen/package.py index 95ab72060d..eccaec1263 100644 --- a/var/spack/repos/builtin/packages/parmgridgen/package.py +++ b/var/spack/repos/builtin/packages/parmgridgen/package.py @@ -28,8 +28,8 @@ class Parmgridgen(Package): def install(self, spec, prefix): make_opts = [ 'make=make', - 'COPTIONS={0}'.format(self.compiler.pic_flag), - 'LDOPTIONS={0}'.format(self.compiler.pic_flag), + 'COPTIONS={0}'.format(self.compiler.cc_pic_flag), + 'LDOPTIONS={0}'.format(self.compiler.cc_pic_flag), 'CC={0}'.format(self.compiler.cc), 'LD={0}'.format(self.compiler.cc), 'LIBDIR=-L../..', diff --git a/var/spack/repos/builtin/packages/parquet-cpp/package.py b/var/spack/repos/builtin/packages/parquet-cpp/package.py index 38e43f33d3..85222f83a2 100644 --- a/var/spack/repos/builtin/packages/parquet-cpp/package.py +++ b/var/spack/repos/builtin/packages/parquet-cpp/package.py @@ -36,6 +36,9 @@ class ParquetCpp(CMakePackage): def flag_handler(self, name, flags): flags = list(flags) - if '+pic' in self.spec and name in ('cflags', 'cxxflags'): - flags.append(self.compiler.pic_flag) + if '+pic' in self.spec: + if name == 'cflags': + flags.append(self.compiler.cc_pic_flag) + elif name == 'cxxflags': + flags.append(self.compiler.cxx_pic_flag) return (None, None, flags) diff --git a/var/spack/repos/builtin/packages/pdt/package.py b/var/spack/repos/builtin/packages/pdt/package.py index c2adfb831d..35164db1c5 100644 --- a/var/spack/repos/builtin/packages/pdt/package.py +++ b/var/spack/repos/builtin/packages/pdt/package.py @@ -53,7 +53,7 @@ class Pdt(AutotoolsPackage): raise InstallError('Unknown/unsupported compiler family') if '+pic' in spec: - options.append('-useropt=' + self.compiler.pic_flag) + options.append('-useropt=' + self.compiler.cxx_pic_flag) configure(*options) diff --git a/var/spack/repos/builtin/packages/perl/package.py b/var/spack/repos/builtin/packages/perl/package.py index 847bf83765..2841ab2713 100644 --- a/var/spack/repos/builtin/packages/perl/package.py +++ b/var/spack/repos/builtin/packages/perl/package.py @@ -131,7 +131,8 @@ class Perl(Package): # Perl doesn't use Autotools, it should subclass Package # https://github.com/spack/spack/pull/3081 and # https://github.com/spack/spack/pull/4416 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: config_args.append('-Duseshrplib') diff --git a/var/spack/repos/builtin/packages/py-llvmlite/package.py b/var/spack/repos/builtin/packages/py-llvmlite/package.py index c225e74354..e7e0712138 100644 --- a/var/spack/repos/builtin/packages/py-llvmlite/package.py +++ b/var/spack/repos/builtin/packages/py-llvmlite/package.py @@ -33,4 +33,5 @@ class PyLlvmlite(PythonPackage): def setup_build_environment(self, env): # 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)) diff --git a/var/spack/repos/builtin/packages/python/package.py b/var/spack/repos/builtin/packages/python/package.py index 3b675a02b6..97acde7b59 100644 --- a/var/spack/repos/builtin/packages/python/package.py +++ b/var/spack/repos/builtin/packages/python/package.py @@ -280,7 +280,7 @@ class Python(AutotoolsPackage): config_args.append('--without-ensurepip') 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 '+ssl' in spec: diff --git a/var/spack/repos/builtin/packages/r/package.py b/var/spack/repos/builtin/packages/r/package.py index 1893aca9ac..7c6807e3e7 100644 --- a/var/spack/repos/builtin/packages/r/package.py +++ b/var/spack/repos/builtin/packages/r/package.py @@ -163,7 +163,8 @@ class R(AutotoolsPackage): # Set FPICFLAGS for compilers except '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 diff --git a/var/spack/repos/builtin/packages/scorep/package.py b/var/spack/repos/builtin/packages/scorep/package.py index 96c3eae2e4..b26af4287d 100644 --- a/var/spack/repos/builtin/packages/scorep/package.py +++ b/var/spack/repos/builtin/packages/scorep/package.py @@ -106,8 +106,8 @@ class Scorep(AutotoolsPackage): config_args.append('--with-mpi=openmpi') config_args.extend([ - 'CFLAGS={0}'.format(self.compiler.pic_flag), - 'CXXFLAGS={0}'.format(self.compiler.pic_flag) + 'CFLAGS={0}'.format(self.compiler.cc_pic_flag), + 'CXXFLAGS={0}'.format(self.compiler.cxx_pic_flag) ]) if "+mpi" in spec: diff --git a/var/spack/repos/builtin/packages/scotch/package.py b/var/spack/repos/builtin/packages/scotch/package.py index 0a96559763..f2ba07a94b 100644 --- a/var/spack/repos/builtin/packages/scotch/package.py +++ b/var/spack/repos/builtin/packages/scotch/package.py @@ -117,7 +117,7 @@ class Scotch(Package): makefile_inc.extend([ 'LIB = .dylib', 'CLIBFLAGS = -dynamiclib {0}'.format( - self.compiler.pic_flag + self.compiler.cc_pic_flag ), 'RANLIB = echo', 'AR = $(CC)', @@ -126,12 +126,13 @@ class Scotch(Package): else: makefile_inc.extend([ 'LIB = .so', - 'CLIBFLAGS = -shared {0}'.format(self.compiler.pic_flag), + 'CLIBFLAGS = -shared {0}'.format( + self.compiler.cc_pic_flag), 'RANLIB = echo', 'AR = $(CC)', 'ARFLAGS = -shared $(LDFLAGS) -o' ]) - cflags.append(self.compiler.pic_flag) + cflags.append(self.compiler.cc_pic_flag) else: makefile_inc.extend([ 'LIB = .a', diff --git a/var/spack/repos/builtin/packages/shtools/package.py b/var/spack/repos/builtin/packages/shtools/package.py index 77871d7a36..dc0388939f 100644 --- a/var/spack/repos/builtin/packages/shtools/package.py +++ b/var/spack/repos/builtin/packages/shtools/package.py @@ -31,7 +31,7 @@ class Shtools(MakefilePackage): return [ "F95={0}".format(self.compiler.fc), ("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), "BLAS={0}".format(spec['blas'].libs), "FFTW={0}".format(spec['fftw'].libs), diff --git a/var/spack/repos/builtin/packages/silo/package.py b/var/spack/repos/builtin/packages/silo/package.py index 98e8b4be15..9192937393 100644 --- a/var/spack/repos/builtin/packages/silo/package.py +++ b/var/spack/repos/builtin/packages/silo/package.py @@ -45,9 +45,14 @@ class Silo(AutotoolsPackage): if spec['hdf5'].satisfies('~shared'): flags.append('-ldl') flags.append(spec['readline'].libs.search_flags) - elif name in ('cflags', 'cxxflags', 'fcflags'): - if '+pic' in spec: - flags.append(self.compiler.pic_flag) + + if '+pic' in spec: + 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) @when('%clang@9:') diff --git a/var/spack/repos/builtin/packages/simmetrix-simmodsuite/package.py b/var/spack/repos/builtin/packages/simmetrix-simmodsuite/package.py index 75ec47b39b..7d38e267d7 100644 --- a/var/spack/repos/builtin/packages/simmetrix-simmodsuite/package.py +++ b/var/spack/repos/builtin/packages/simmetrix-simmodsuite/package.py @@ -236,7 +236,7 @@ class SimmetrixSimmodsuite(Package): "CXX=%s" % spec['mpi'].mpicxx, "PARALLEL=%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' wrapperlibpath = join_path(workdir, 'lib', libname) install(wrapperlibpath, join_path(prefix.lib, self.oslib)) diff --git a/var/spack/repos/builtin/packages/snappy/package.py b/var/spack/repos/builtin/packages/snappy/package.py index 3516c53d1d..d5ade343f3 100644 --- a/var/spack/repos/builtin/packages/snappy/package.py +++ b/var/spack/repos/builtin/packages/snappy/package.py @@ -37,8 +37,11 @@ class Snappy(CMakePackage): def flag_handler(self, name, flags): flags = list(flags) - if '+pic' in self.spec and name in ('cflags', 'cxxflags'): - flags.append(self.compiler.pic_flag) + if '+pic' in self.spec: + if name == 'cflags': + flags.append(self.compiler.cc_pic_flag) + elif name == 'cxxflags': + flags.append(self.compiler.cxx_pic_flag) return (None, None, flags) @run_after('install') diff --git a/var/spack/repos/builtin/packages/sqlite/package.py b/var/spack/repos/builtin/packages/sqlite/package.py index 4e79463f36..531a9bc81d 100644 --- a/var/spack/repos/builtin/packages/sqlite/package.py +++ b/var/spack/repos/builtin/packages/sqlite/package.py @@ -122,6 +122,6 @@ class Sqlite(AutotoolsPackage): if '+functions' in self.spec: libraryname = 'libsqlitefunctions.' + dso_suffix cc = Executable(spack_cc) - cc(self.compiler.pic_flag, '-lm', '-shared', + cc(self.compiler.cc_pic_flag, '-lm', '-shared', 'extension-functions.c', '-o', libraryname) install(libraryname, self.prefix.lib) diff --git a/var/spack/repos/builtin/packages/suite-sparse/package.py b/var/spack/repos/builtin/packages/suite-sparse/package.py index 88f5aa839c..39532db801 100644 --- a/var/spack/repos/builtin/packages/suite-sparse/package.py +++ b/var/spack/repos/builtin/packages/suite-sparse/package.py @@ -63,7 +63,8 @@ class SuiteSparse(Package): # logic in it. Any kind of customization will need to go through # 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 = [ # By default, the Makefile uses the Intel compilers if @@ -78,11 +79,11 @@ class SuiteSparse(Package): 'CUDA_PATH=%s' % (spec['cuda'].prefix if '+cuda' in spec else ''), 'CFOPENMP=%s' % (self.compiler.openmp_flag 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; # FFLAGS is used in CHOLMOD, F77FLAGS is used in AMD and UMFPACK. - 'FFLAGS=%s' % pic_flag, - 'F77FLAGS=%s' % pic_flag, + 'FFLAGS=%s' % f77_pic_flag, + 'F77FLAGS=%s' % f77_pic_flag, # use Spack's metis in CHOLMOD/Partition module, # otherwise internal Metis will be compiled 'MY_METIS_LIB=%s' % spec['metis'].libs.ld_flags, diff --git a/var/spack/repos/builtin/packages/sundials/package.py b/var/spack/repos/builtin/packages/sundials/package.py index a76b36eacb..104307fa19 100644 --- a/var/spack/repos/builtin/packages/sundials/package.py +++ b/var/spack/repos/builtin/packages/sundials/package.py @@ -211,7 +211,7 @@ class Sundials(CMakePackage): def on_off(varstr): 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): f77 = Executable(self.compiler.f77) libgfortran = LibraryList(f77('--print-file-name', diff --git a/var/spack/repos/builtin/packages/superlu/package.py b/var/spack/repos/builtin/packages/superlu/package.py index 14f9483945..bc1b383729 100644 --- a/var/spack/repos/builtin/packages/superlu/package.py +++ b/var/spack/repos/builtin/packages/superlu/package.py @@ -73,10 +73,10 @@ class Superlu(Package): if '+pic' in spec: config.extend([ # Use these lines instead when pic_flag capability arrives - 'CFLAGS = -O3 {0}'.format(self.compiler.pic_flag), - 'NOOPTS = {0}'.format(self.compiler.pic_flag), - 'FFLAGS = -O2 {0}'.format(self.compiler.pic_flag), - 'LOADOPTS = {0}'.format(self.compiler.pic_flag) + 'CFLAGS = -O3 {0}'.format(self.compiler.cc_pic_flag), + 'NOOPTS = {0}'.format(self.compiler.cc_pic_flag), + 'FFLAGS = -O2 {0}'.format(self.compiler.f77_pic_flag), + 'LOADOPTS = {0}'.format(self.compiler.cc_pic_flag) ]) else: config.extend([ diff --git a/var/spack/repos/builtin/packages/thrift/package.py b/var/spack/repos/builtin/packages/thrift/package.py index 92f77e0331..7e61860243 100644 --- a/var/spack/repos/builtin/packages/thrift/package.py +++ b/var/spack/repos/builtin/packages/thrift/package.py @@ -51,8 +51,8 @@ class Thrift(Package): def setup_build_environment(self, env): if '+pic' in self.spec: - env.append_flags('CFLAGS', self.compiler.pic_flag) - env.append_flags('CXXFLAGS', self.compiler.pic_flag) + env.append_flags('CFLAGS', self.compiler.cc_pic_flag) + env.append_flags('CXXFLAGS', self.compiler.cxx_pic_flag) def install(self, spec, prefix): env['PY_PREFIX'] = prefix diff --git a/var/spack/repos/builtin/packages/unrar/package.py b/var/spack/repos/builtin/packages/unrar/package.py index 6972aef3c9..9f8700c804 100644 --- a/var/spack/repos/builtin/packages/unrar/package.py +++ b/var/spack/repos/builtin/packages/unrar/package.py @@ -26,6 +26,6 @@ class Unrar(MakefilePackage): def edit(self, spec, prefix): makefile = FileFilter("makefile") 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)) diff --git a/var/spack/repos/builtin/packages/visit/package.py b/var/spack/repos/builtin/packages/visit/package.py index 2616b689e3..1ee2994c21 100644 --- a/var/spack/repos/builtin/packages/visit/package.py +++ b/var/spack/repos/builtin/packages/visit/package.py @@ -72,8 +72,8 @@ class Visit(CMakePackage): '-DVISIT_VTK_DIR:PATH=' + spec['vtk'].prefix, '-DVISIT_ZLIB_DIR:PATH=' + spec['zlib'].prefix, '-DVISIT_USE_GLEW=OFF', - '-DCMAKE_CXX_FLAGS=' + self.compiler.pic_flag, - '-DCMAKE_C_FLAGS=' + self.compiler.pic_flag, + '-DCMAKE_CXX_FLAGS=' + self.compiler.cxx_pic_flag, + '-DCMAKE_C_FLAGS=' + self.compiler.cc_pic_flag, ] if '+python' in spec: diff --git a/var/spack/repos/builtin/packages/voropp/package.py b/var/spack/repos/builtin/packages/voropp/package.py index 201c23de24..5dc7406afc 100644 --- a/var/spack/repos/builtin/packages/voropp/package.py +++ b/var/spack/repos/builtin/packages/voropp/package.py @@ -30,7 +30,7 @@ class Voropp(MakefilePackage): # CFLAGS=-Wall -ansi -pedantic -O3 cflags = '' if '+pic' in spec: - cflags += self.compiler.pic_flag + cflags += self.compiler.cc_pic_flag filter_file(r'CFLAGS=.*', 'CFLAGS={0}'.format(cflags), 'config.mk') diff --git a/var/spack/repos/builtin/packages/zlib/package.py b/var/spack/repos/builtin/packages/zlib/package.py index 82cdf73f25..4967bc0dbb 100644 --- a/var/spack/repos/builtin/packages/zlib/package.py +++ b/var/spack/repos/builtin/packages/zlib/package.py @@ -40,7 +40,7 @@ class Zlib(Package): def setup_build_environment(self, env): 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: env.append_flags('CFLAGS', '-O2') diff --git a/var/spack/repos/builtin/packages/zoltan/package.py b/var/spack/repos/builtin/packages/zoltan/package.py index b832dbc0f8..615b65502a 100644 --- a/var/spack/repos/builtin/packages/zoltan/package.py +++ b/var/spack/repos/builtin/packages/zoltan/package.py @@ -95,7 +95,7 @@ class Zoltan(AutotoolsPackage): 'RANLIB=echo', '--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'): config_args.append('--with-libs=-lgfortran') if spec.satisfies('%intel'): diff --git a/var/spack/repos/builtin/packages/zstd/package.py b/var/spack/repos/builtin/packages/zstd/package.py index 1557cc8a07..8cc37ab3d5 100644 --- a/var/spack/repos/builtin/packages/zstd/package.py +++ b/var/spack/repos/builtin/packages/zstd/package.py @@ -27,7 +27,7 @@ class Zstd(MakefilePackage): def setup_build_environment(self, env): 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): make('PREFIX={0}'.format(prefix)) |