|
|
@ -258,6 +258,52 @@ class CudaCompiler(Compiler): |
|
|
|
l = [cls._shield_nvcc_list_arg(s, listmode=False) for s in l] |
|
|
|
l = [cls._shield_nvcc_list_arg(s, listmode=False) for s in l] |
|
|
|
return '\,'.join(l) |
|
|
|
return '\,'.join(l) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
|
|
def _merge_flags(cls, flags: T.List[str]) -> T.List[str]: |
|
|
|
|
|
|
|
r""" |
|
|
|
|
|
|
|
The flags to NVCC gets exceedingly verbose and unreadable when too many of them |
|
|
|
|
|
|
|
are shielded with -Xcompiler. Merge consecutive -Xcompiler-wrapped arguments |
|
|
|
|
|
|
|
into one. |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
if len(flags) <= 1: |
|
|
|
|
|
|
|
return flags |
|
|
|
|
|
|
|
flagit = iter(flags) |
|
|
|
|
|
|
|
xflags = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_xcompiler_flag_isolated(flag: str) -> bool: |
|
|
|
|
|
|
|
return flag == '-Xcompiler' |
|
|
|
|
|
|
|
def is_xcompiler_flag_glued(flag: str) -> bool: |
|
|
|
|
|
|
|
return flag.startswith('-Xcompiler=') |
|
|
|
|
|
|
|
def is_xcompiler_flag(flag: str) -> bool: |
|
|
|
|
|
|
|
return is_xcompiler_flag_isolated(flag) or is_xcompiler_flag_glued(flag) |
|
|
|
|
|
|
|
def get_xcompiler_val(flag: str, flagit: T.Iterator[str]) -> str: |
|
|
|
|
|
|
|
if is_xcompiler_flag_glued(flag): |
|
|
|
|
|
|
|
return flag[len('-Xcompiler='):] |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
return next(flagit) |
|
|
|
|
|
|
|
except StopIteration: |
|
|
|
|
|
|
|
return "" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ingroup = False |
|
|
|
|
|
|
|
for flag in flagit: |
|
|
|
|
|
|
|
if not is_xcompiler_flag(flag): |
|
|
|
|
|
|
|
ingroup = False |
|
|
|
|
|
|
|
xflags.append(flag) |
|
|
|
|
|
|
|
elif ingroup: |
|
|
|
|
|
|
|
xflags[-1] += ',' |
|
|
|
|
|
|
|
xflags[-1] += get_xcompiler_val(flag, flagit) |
|
|
|
|
|
|
|
elif is_xcompiler_flag_isolated(flag): |
|
|
|
|
|
|
|
ingroup = True |
|
|
|
|
|
|
|
xflags.append(flag) |
|
|
|
|
|
|
|
xflags.append(get_xcompiler_val(flag, flagit)) |
|
|
|
|
|
|
|
elif is_xcompiler_flag_glued(flag): |
|
|
|
|
|
|
|
ingroup = True |
|
|
|
|
|
|
|
xflags.append(flag) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
raise ValueError("-Xcompiler flag merging failed, unknown argument form!") |
|
|
|
|
|
|
|
return xflags |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
@classmethod |
|
|
|
def _to_host_flags(cls, 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]: |
|
|
|
""" |
|
|
|
""" |
|
|
@ -431,7 +477,7 @@ class CudaCompiler(Compiler): |
|
|
|
xflags.append(flag) |
|
|
|
xflags.append(flag) |
|
|
|
xflags.append(val) |
|
|
|
xflags.append(val) |
|
|
|
|
|
|
|
|
|
|
|
return xflags |
|
|
|
return cls._merge_flags(xflags) |
|
|
|
|
|
|
|
|
|
|
|
def needs_static_linker(self) -> bool: |
|
|
|
def needs_static_linker(self) -> bool: |
|
|
|
return False |
|
|
|
return False |
|
|
|