summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Cohn <robert.s.cohn@intel.com>2022-10-18 18:17:50 -0400
committerGitHub <noreply@github.com>2022-10-18 16:17:50 -0600
commit7bb4b58b8b06aaff7635b702093585891c966f2d (patch)
treed7e9d904bca10d8bbb20cbdbc3fc3506b26e404c
parent13356f3bfa2b5cc6d77def51416bce9413acfd02 (diff)
downloadspack-7bb4b58b8b06aaff7635b702093585891c966f2d.tar.gz
spack-7bb4b58b8b06aaff7635b702093585891c966f2d.tar.bz2
spack-7bb4b58b8b06aaff7635b702093585891c966f2d.tar.xz
spack-7bb4b58b8b06aaff7635b702093585891c966f2d.zip
intel-oneapi-compilers: do not pass -Wno-unused-command-line-argument to icc + refactor (#33389)
-rw-r--r--var/spack/repos/builtin/packages/intel-oneapi-compilers/package.py48
1 files changed, 21 insertions, 27 deletions
diff --git a/var/spack/repos/builtin/packages/intel-oneapi-compilers/package.py b/var/spack/repos/builtin/packages/intel-oneapi-compilers/package.py
index f9c832eb8d..fa6d9f7ac1 100644
--- a/var/spack/repos/builtin/packages/intel-oneapi-compilers/package.py
+++ b/var/spack/repos/builtin/packages/intel-oneapi-compilers/package.py
@@ -182,6 +182,13 @@ class IntelOneapiCompilers(IntelOneApiPackage):
# should not be patched
patchelf(file, fail_on_error=False)
+ def write_config_file(self, flags, path, compilers):
+ for compiler in compilers:
+ p = path.join(compiler + ".cfg")
+ with open(p, "w") as f:
+ f.write(" ".join(flags))
+ set_install_permissions(p)
+
@run_after("install")
def extend_config_flags(self):
# Extends compiler config files to inject additional compiler flags.
@@ -196,7 +203,12 @@ class IntelOneapiCompilers(IntelOneApiPackage):
# TODO: it is unclear whether we should really use all elements of
# _ld_library_path because it looks like the only rpath that needs to be
# injected is self.component_prefix.linux.compiler.lib.intel64_lin.
- flags_list = ["-Wl,-rpath,{}".format(d) for d in self._ld_library_path()]
+ common_flags = ["-Wl,-rpath,{}".format(d) for d in self._ld_library_path()]
+
+ # Make sure that underlying clang gets the right GCC toolchain by default
+ llvm_flags = ["--gcc-toolchain={}".format(self.compiler.prefix)]
+ classic_flags = ["-gcc-name={}".format(self.compiler.cc)]
+ classic_flags.append("-gxx-name={}".format(self.compiler.cxx))
# Older versions trigger -Wunused-command-line-argument warnings whenever
# linker flags are passed in preprocessor (-E) or compilation mode (-c).
@@ -204,33 +216,15 @@ class IntelOneapiCompilers(IntelOneApiPackage):
# do not trigger these warnings. In some build systems these warnings can
# cause feature detection to fail, so we silence them with -Wno-unused-...
if self.spec.version < Version("2022.1.0"):
- flags_list.append("-Wno-unused-command-line-argument")
-
- def write_cfg(cmp_list, flags_list):
- flags = " ".join(flags_list)
- for cmp in cmp_list:
- cfg_file = self.component_prefix.linux.bin.join(cmp + ".cfg")
- with open(cfg_file, "w") as f:
- f.write(flags)
- set_install_permissions(cfg_file)
-
- # Make sure that icc gets the right GCC C++ support
- write_cfg(
- [
- join_path("intel64", "icc"),
- ],
- flags_list + ["-gcc-name={}".format(self.compiler.cc)],
- )
- write_cfg(
- [
- join_path("intel64", "icpc"),
- ],
- flags_list + ["-gxx-name={}".format(self.compiler.cxx)],
+ llvm_flags.append("-Wno-unused-command-line-argument")
+
+ self.write_config_file(
+ common_flags + llvm_flags, self.component_prefix.linux.bin, ["icx", "icpx", "ifx"]
)
- # Make sure that underlying clang gets the right GCC toolchain by default
- write_cfg(
- ["icx", "icpx", "ifx"],
- flags_list + ["--gcc-toolchain={}".format(self.compiler.prefix)],
+ self.write_config_file(
+ common_flags + classic_flags,
+ self.component_prefix.linux.bin.intel64,
+ ["icc", "icpc", "ifort"],
)
def _ld_library_path(self):