Skip to content

Commit

Permalink
Adding pic_flag property to compilers (spack#2375)
Browse files Browse the repository at this point in the history
Different compilers have different flags for PIC (position-independent
code). This patch provides a common ground to accessing it inside specs.

See discussions in spack#508 and spack#2373. This patch does not address the issue
of mixed compilers as mentioned in spack#508.
  • Loading branch information
aprokop authored and Elizabeth Fischer committed Dec 4, 2016
1 parent 330008b commit 4fffe5b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/spack/spack/compilers/clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def cxx11_flag(self):
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.
Expand Down
4 changes: 4 additions & 0 deletions lib/spack/spack/compilers/gcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ def cxx14_flag(self):
else:
return "-std=c++14"

@property
def pic_flag(self):
return "-fPIC"

@classmethod
def fc_version(cls, fc):
return get_compiler_version(
Expand Down
4 changes: 4 additions & 0 deletions lib/spack/spack/compilers/intel.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def cxx11_flag(self):
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
Expand Down
4 changes: 4 additions & 0 deletions lib/spack/spack/compilers/nag.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def cxx11_flag(self):
# 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,,'
Expand Down
4 changes: 4 additions & 0 deletions lib/spack/spack/compilers/pgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def openmp_flag(self):
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.
Expand Down
4 changes: 4 additions & 0 deletions lib/spack/spack/compilers/xl.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def cxx11_flag(self):
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.
Expand Down

0 comments on commit 4fffe5b

Please sign in to comment.