Cuda: Filter -isystem with system paths

pull/8994/head
David Seifert 3 years ago
parent 3b47d161e7
commit d648f3497e
No known key found for this signature in database
GPG Key ID: CE36E117202E3842
  1. 31
      mesonbuild/compilers/cuda.py

@ -290,8 +290,7 @@ class CudaCompiler(Compiler):
raise ValueError("-Xcompiler flag merging failed, unknown argument form!")
return xflags
@classmethod
def _to_host_flags(cls, flags: T.List[str], phase: _Phase = _Phase.COMPILER) -> T.List[str]:
def _to_host_flags(self, flags: T.List[str], phase: _Phase = _Phase.COMPILER) -> T.List[str]:
"""
Translate generic "GCC-speak" plus particular "NVCC-speak" flags to NVCC flags.
@ -353,7 +352,7 @@ class CudaCompiler(Compiler):
# an exception for -D (where this would be value-changing) and -U (because
# it isn't possible to define a macro with a comma in the name).
if flag in cls._FLAG_PASSTHRU_NOARGS:
if flag in self._FLAG_PASSTHRU_NOARGS:
xflags.append(flag)
continue
@ -384,19 +383,23 @@ class CudaCompiler(Compiler):
else: # -Isomething
val = flag[2:]
flag = flag[:2] # -I
elif flag in cls._FLAG_LONG2SHORT_WITHARGS or \
flag in cls._FLAG_SHORT2LONG_WITHARGS:
elif flag in self._FLAG_LONG2SHORT_WITHARGS or \
flag in self._FLAG_SHORT2LONG_WITHARGS:
# This is either -o or a multi-letter flag, and it is receiving its
# value isolated.
try:
val = next(flagit) # -o something
except StopIteration:
pass
elif flag.split('=',1)[0] in cls._FLAG_LONG2SHORT_WITHARGS or \
flag.split('=',1)[0] in cls._FLAG_SHORT2LONG_WITHARGS:
elif flag.split('=',1)[0] in self._FLAG_LONG2SHORT_WITHARGS or \
flag.split('=',1)[0] in self._FLAG_SHORT2LONG_WITHARGS:
# This is either -o or a multi-letter flag, and it is receiving its
# value after an = sign.
flag, val = flag.split('=',1) # -o=something
# Some dependencies (e.g., BoostDependency) add unspaced "-isystem/usr/include" arguments
elif flag.startswith('-isystem'):
val = flag[8:].strip()
flag = flag[:8]
else:
# This is a flag, and it's foreign to NVCC.
#
@ -418,7 +421,7 @@ class CudaCompiler(Compiler):
xflags.append('-prec-div=true')
xflags.append('-Xcompiler='+flag)
else:
xflags.append('-Xcompiler='+cls._shield_nvcc_list_arg(flag))
xflags.append('-Xcompiler='+self._shield_nvcc_list_arg(flag))
# The above should securely handle GCC's -Wl, -Wa, -Wp, arguments.
continue
@ -427,7 +430,7 @@ class CudaCompiler(Compiler):
# Take care of the various NVCC-supported flags that need special handling.
flag = cls._FLAG_LONG2SHORT_WITHARGS.get(flag,flag)
flag = self._FLAG_LONG2SHORT_WITHARGS.get(flag,flag)
if flag in {'-include','-isystem','-I','-L','-l'}:
# These flags are known to GCC, but list-valued in NVCC. They potentially
@ -439,10 +442,14 @@ class CudaCompiler(Compiler):
# -U with comma arguments is impossible in GCC-speak (and thus unambiguous
#in NVCC-speak, albeit unportable).
if len(flag) == 2:
xflags.append(flag+cls._shield_nvcc_list_arg(val))
xflags.append(flag+self._shield_nvcc_list_arg(val))
elif flag == '-isystem' and val in self.host_compiler.get_default_include_dirs():
# like GnuLikeCompiler, we have to filter out include directories specified
# with -isystem that overlap with the host compiler's search path
pass
else:
xflags.append(flag)
xflags.append(cls._shield_nvcc_list_arg(val))
xflags.append(self._shield_nvcc_list_arg(val))
elif flag == '-O':
# Handle optimization levels GCC knows about that NVCC does not.
if val == 'fast':
@ -463,7 +470,7 @@ class CudaCompiler(Compiler):
xflags.append(flag)
xflags.append(val)
return cls._merge_flags(xflags)
return self._merge_flags(xflags)
def needs_static_linker(self) -> bool:
return False

Loading…
Cancel
Save