summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Prokopenko <aprokop@users.noreply.github.com>2016-11-24 15:25:22 -0500
committerTodd Gamblin <tgamblin@llnl.gov>2016-11-24 12:25:22 -0800
commit11bfccd53fe05321c2ef65b2844946fa0fa7b052 (patch)
tree00b3e464f5420de987adc3137a959f0232849547
parent261d36e8012b78f5a92a7b5f7c18ddcc34459bce (diff)
downloadspack-11bfccd53fe05321c2ef65b2844946fa0fa7b052.tar.gz
spack-11bfccd53fe05321c2ef65b2844946fa0fa7b052.tar.bz2
spack-11bfccd53fe05321c2ef65b2844946fa0fa7b052.tar.xz
spack-11bfccd53fe05321c2ef65b2844946fa0fa7b052.zip
Adding pic_flag property to compilers (#2375)
Different compilers have different flags for PIC (position-independent code). This patch provides a common ground to accessing it inside specs. See discussions in #508 and #2373. This patch does not address the issue of mixed compilers as mentioned in #508.
-rw-r--r--lib/spack/spack/compilers/clang.py4
-rw-r--r--lib/spack/spack/compilers/gcc.py4
-rw-r--r--lib/spack/spack/compilers/intel.py4
-rw-r--r--lib/spack/spack/compilers/nag.py4
-rw-r--r--lib/spack/spack/compilers/pgi.py4
-rw-r--r--lib/spack/spack/compilers/xl.py4
6 files changed, 24 insertions, 0 deletions
diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py
index da18adcecd..b2095defe5 100644
--- a/lib/spack/spack/compilers/clang.py
+++ b/lib/spack/spack/compilers/clang.py
@@ -78,6 +78,10 @@ class Clang(Compiler):
else:
return "-std=c++11"
+ @property
+ def pic_flag(self):
+ return "-fPIC"
+
@classmethod
def default_version(cls, comp):
"""The '--version' option works for clang compilers.
diff --git a/lib/spack/spack/compilers/gcc.py b/lib/spack/spack/compilers/gcc.py
index 557b1c13a9..80d24910c3 100644
--- a/lib/spack/spack/compilers/gcc.py
+++ b/lib/spack/spack/compilers/gcc.py
@@ -74,6 +74,10 @@ class Gcc(Compiler):
else:
return "-std=c++14"
+ @property
+ def pic_flag(self):
+ return "-fPIC"
+
@classmethod
def fc_version(cls, fc):
return get_compiler_version(
diff --git a/lib/spack/spack/compilers/intel.py b/lib/spack/spack/compilers/intel.py
index 14f4d2dc91..4ff7185c84 100644
--- a/lib/spack/spack/compilers/intel.py
+++ b/lib/spack/spack/compilers/intel.py
@@ -65,6 +65,10 @@ class Intel(Compiler):
else:
return "-std=c++11"
+ @property
+ def pic_flag(self):
+ return "-fPIC"
+
@classmethod
def default_version(cls, comp):
"""The '--version' option seems to be the most consistent one
diff --git a/lib/spack/spack/compilers/nag.py b/lib/spack/spack/compilers/nag.py
index 5ba235adbb..c1da95a6c3 100644
--- a/lib/spack/spack/compilers/nag.py
+++ b/lib/spack/spack/compilers/nag.py
@@ -56,6 +56,10 @@ class Nag(Compiler):
# However, it can be mixed with a compiler that does support it
return "-std=c++11"
+ @property
+ def pic_flag(self):
+ return "-PIC"
+
# Unlike other compilers, the NAG compiler passes options to GCC, which
# then passes them to the linker. Therefore, we need to doubly wrap the
# options with '-Wl,-Wl,,'
diff --git a/lib/spack/spack/compilers/pgi.py b/lib/spack/spack/compilers/pgi.py
index 37ffe44028..146c153041 100644
--- a/lib/spack/spack/compilers/pgi.py
+++ b/lib/spack/spack/compilers/pgi.py
@@ -55,6 +55,10 @@ class Pgi(Compiler):
def cxx11_flag(self):
return "-std=c++11"
+ @property
+ def pic_flag(self):
+ return "-fpic"
+
@classmethod
def default_version(cls, comp):
"""The '-V' option works for all the PGI compilers.
diff --git a/lib/spack/spack/compilers/xl.py b/lib/spack/spack/compilers/xl.py
index 5c83209781..f4b7c4237d 100644
--- a/lib/spack/spack/compilers/xl.py
+++ b/lib/spack/spack/compilers/xl.py
@@ -58,6 +58,10 @@ class Xl(Compiler):
else:
return "-qlanglvl=extended0x"
+ @property
+ def pic_flag(self):
+ return "-qpic"
+
@classmethod
def default_version(cls, comp):
"""The '-qversion' is the standard option fo XL compilers.