intel-oneapi-compilers: do not pass -Wno-unused-command-line-argument to icc + refactor (#33389)

This commit is contained in:
Robert Cohn 2022-10-18 18:17:50 -04:00 committed by GitHub
parent 13356f3bfa
commit 7bb4b58b8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -182,6 +182,13 @@ def inject_rpaths(self):
# should not be patched # should not be patched
patchelf(file, fail_on_error=False) 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") @run_after("install")
def extend_config_flags(self): def extend_config_flags(self):
# Extends compiler config files to inject additional compiler flags. # Extends compiler config files to inject additional compiler flags.
@ -196,7 +203,12 @@ def extend_config_flags(self):
# TODO: it is unclear whether we should really use all elements of # 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 # _ld_library_path because it looks like the only rpath that needs to be
# injected is self.component_prefix.linux.compiler.lib.intel64_lin. # 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 # Older versions trigger -Wunused-command-line-argument warnings whenever
# linker flags are passed in preprocessor (-E) or compilation mode (-c). # linker flags are passed in preprocessor (-E) or compilation mode (-c).
@ -204,33 +216,15 @@ def extend_config_flags(self):
# do not trigger these warnings. In some build systems these warnings can # do not trigger these warnings. In some build systems these warnings can
# cause feature detection to fail, so we silence them with -Wno-unused-... # cause feature detection to fail, so we silence them with -Wno-unused-...
if self.spec.version < Version("2022.1.0"): if self.spec.version < Version("2022.1.0"):
flags_list.append("-Wno-unused-command-line-argument") llvm_flags.append("-Wno-unused-command-line-argument")
def write_cfg(cmp_list, flags_list): self.write_config_file(
flags = " ".join(flags_list) common_flags + llvm_flags, self.component_prefix.linux.bin, ["icx", "icpx", "ifx"]
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( self.write_config_file(
[ common_flags + classic_flags,
join_path("intel64", "icpc"), self.component_prefix.linux.bin.intel64,
], ["icc", "icpc", "ifort"],
flags_list + ["-gxx-name={}".format(self.compiler.cxx)],
)
# 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)],
) )
def _ld_library_path(self): def _ld_library_path(self):