|
|
@ -290,8 +290,7 @@ class CudaCompiler(Compiler): |
|
|
|
raise ValueError("-Xcompiler flag merging failed, unknown argument form!") |
|
|
|
raise ValueError("-Xcompiler flag merging failed, unknown argument form!") |
|
|
|
return xflags |
|
|
|
return xflags |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
def _to_host_flags(self, flags: T.List[str], phase: _Phase = _Phase.COMPILER) -> T.List[str]: |
|
|
|
def _to_host_flags(cls, flags: T.List[str], phase: _Phase = _Phase.COMPILER) -> T.List[str]: |
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
Translate generic "GCC-speak" plus particular "NVCC-speak" flags to NVCC flags. |
|
|
|
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 |
|
|
|
# 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). |
|
|
|
# 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) |
|
|
|
xflags.append(flag) |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
@ -384,19 +383,23 @@ class CudaCompiler(Compiler): |
|
|
|
else: # -Isomething |
|
|
|
else: # -Isomething |
|
|
|
val = flag[2:] |
|
|
|
val = flag[2:] |
|
|
|
flag = flag[:2] # -I |
|
|
|
flag = flag[:2] # -I |
|
|
|
elif flag in cls._FLAG_LONG2SHORT_WITHARGS or \ |
|
|
|
elif flag in self._FLAG_LONG2SHORT_WITHARGS or \ |
|
|
|
flag in cls._FLAG_SHORT2LONG_WITHARGS: |
|
|
|
flag in self._FLAG_SHORT2LONG_WITHARGS: |
|
|
|
# This is either -o or a multi-letter flag, and it is receiving its |
|
|
|
# This is either -o or a multi-letter flag, and it is receiving its |
|
|
|
# value isolated. |
|
|
|
# value isolated. |
|
|
|
try: |
|
|
|
try: |
|
|
|
val = next(flagit) # -o something |
|
|
|
val = next(flagit) # -o something |
|
|
|
except StopIteration: |
|
|
|
except StopIteration: |
|
|
|
pass |
|
|
|
pass |
|
|
|
elif flag.split('=',1)[0] in cls._FLAG_LONG2SHORT_WITHARGS or \ |
|
|
|
elif flag.split('=',1)[0] in self._FLAG_LONG2SHORT_WITHARGS or \ |
|
|
|
flag.split('=',1)[0] in cls._FLAG_SHORT2LONG_WITHARGS: |
|
|
|
flag.split('=',1)[0] in self._FLAG_SHORT2LONG_WITHARGS: |
|
|
|
# This is either -o or a multi-letter flag, and it is receiving its |
|
|
|
# This is either -o or a multi-letter flag, and it is receiving its |
|
|
|
# value after an = sign. |
|
|
|
# value after an = sign. |
|
|
|
flag, val = flag.split('=',1) # -o=something |
|
|
|
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: |
|
|
|
else: |
|
|
|
# This is a flag, and it's foreign to NVCC. |
|
|
|
# This is a flag, and it's foreign to NVCC. |
|
|
|
# |
|
|
|
# |
|
|
@ -418,7 +421,7 @@ class CudaCompiler(Compiler): |
|
|
|
xflags.append('-prec-div=true') |
|
|
|
xflags.append('-prec-div=true') |
|
|
|
xflags.append('-Xcompiler='+flag) |
|
|
|
xflags.append('-Xcompiler='+flag) |
|
|
|
else: |
|
|
|
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. |
|
|
|
# The above should securely handle GCC's -Wl, -Wa, -Wp, arguments. |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
@ -427,7 +430,7 @@ class CudaCompiler(Compiler): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Take care of the various NVCC-supported flags that need special handling. |
|
|
|
# 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'}: |
|
|
|
if flag in {'-include','-isystem','-I','-L','-l'}: |
|
|
|
# These flags are known to GCC, but list-valued in NVCC. They potentially |
|
|
|
# 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 |
|
|
|
# -U with comma arguments is impossible in GCC-speak (and thus unambiguous |
|
|
|
#in NVCC-speak, albeit unportable). |
|
|
|
#in NVCC-speak, albeit unportable). |
|
|
|
if len(flag) == 2: |
|
|
|
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: |
|
|
|
else: |
|
|
|
xflags.append(flag) |
|
|
|
xflags.append(flag) |
|
|
|
xflags.append(cls._shield_nvcc_list_arg(val)) |
|
|
|
xflags.append(self._shield_nvcc_list_arg(val)) |
|
|
|
elif flag == '-O': |
|
|
|
elif flag == '-O': |
|
|
|
# Handle optimization levels GCC knows about that NVCC does not. |
|
|
|
# Handle optimization levels GCC knows about that NVCC does not. |
|
|
|
if val == 'fast': |
|
|
|
if val == 'fast': |
|
|
@ -463,7 +470,7 @@ class CudaCompiler(Compiler): |
|
|
|
xflags.append(flag) |
|
|
|
xflags.append(flag) |
|
|
|
xflags.append(val) |
|
|
|
xflags.append(val) |
|
|
|
|
|
|
|
|
|
|
|
return cls._merge_flags(xflags) |
|
|
|
return self._merge_flags(xflags) |
|
|
|
|
|
|
|
|
|
|
|
def needs_static_linker(self) -> bool: |
|
|
|
def needs_static_linker(self) -> bool: |
|
|
|
return False |
|
|
|
return False |
|
|
@ -759,3 +766,12 @@ class CudaCompiler(Compiler): |
|
|
|
return [self._shield_nvcc_list_arg('-ccbin='+ccbindir, False)] |
|
|
|
return [self._shield_nvcc_list_arg('-ccbin='+ccbindir, False)] |
|
|
|
else: |
|
|
|
else: |
|
|
|
return [] |
|
|
|
return [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_profile_generate_args(self) -> T.List[str]: |
|
|
|
|
|
|
|
return ['-Xcompiler=' + x for x in self.host_compiler.get_profile_generate_args()] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_profile_use_args(self) -> T.List[str]: |
|
|
|
|
|
|
|
return ['-Xcompiler=' + x for x in self.host_compiler.get_profile_use_args()] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_disable_assert_args(self) -> T.List[str]: |
|
|
|
|
|
|
|
return self.host_compiler.get_disable_assert_args() |
|
|
|