Skip to content

Commit 8866a19

Browse files
ngiloq6cpsauer
authored andcommitted
handle a few more flags
1 parent 9aae00f commit 8866a19

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

refresh.template.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -771,17 +771,21 @@ def _all_platform_patch(compile_args: typing.List[str]):
771771

772772
return compile_args
773773

774-
_nvcc_flags_no_arg = (
774+
_nvcc_flags_no_arg = {
775775
# long name, short name
776776
'--expt-relaxed-constexpr', '-expt-relaxed-constexpr',
777777
'--expt-extended-lambda', '-expt-extended-lambda',
778-
'--extended-lambda', '-extended-lambda',
779-
)
778+
'--extended-lambda', '-extended-lambda'}
780779
_nvcc_flags_with_arg = (
781780
# long name, short name
782781
'--relocatable-device-code', '-rdc',
783782
'--compiler-bindir', '-ccbin',
784783
'--compiler-options', '-Xcompiler')
784+
_nvcc_rewrite_flags = {
785+
# NVCC flag: equiavelent clang flag
786+
"--output-file": "-o",
787+
"--std": "-std",
788+
"--x": "-x"}
785789

786790
def _nvcc_patch(compile_args: typing.List[str]) -> typing.List[str]:
787791
"""Apply fixes to args to nvcc.
@@ -798,13 +802,17 @@ def _nvcc_patch(compile_args: typing.List[str]) -> typing.List[str]:
798802
# Make clangd's behavior closer to nvcc's.
799803
# I think this might become the default in clangd 17: https://reviews.llvm.org/D151359
800804
'-Xclang', '-fcuda-allow-variadic-functions']
801-
skip_next = True # skip the first arg which we added above
805+
skip_next = True # skip the compile_args[0] which we added above
802806
for arg in compile_args:
803807
if skip_next:
804808
skip_next = False
805809
continue
806810
if arg in _nvcc_flags_no_arg:
807811
continue
812+
rewrite_to = _nvcc_rewrite_flags.get(arg)
813+
if rewrite_to:
814+
new_compile_args.append(rewrite_to)
815+
continue
808816
skip = False
809817
for flag_with_arg in _nvcc_flags_with_arg:
810818
if arg == flag_with_arg:

0 commit comments

Comments
 (0)