Skip to content

Commit db8daa6

Browse files
Fix command line arguments for linker and compiler (#895)
* Fix command line arguments checking related to optimization, debugging, and lineinfo. Fix ProgramOptions.__repr__() to return a string instead of a list. * pre-commit formatting fix
1 parent 33a1110 commit db8daa6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

cuda_core/cuda/core/experimental/_linker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,15 @@ def _init_nvjitlink(self):
205205
self.formatted_options.append("-time")
206206
if self.verbose is not None:
207207
self.formatted_options.append("-verbose")
208-
if self.link_time_optimization is not None:
208+
if self.link_time_optimization is not None and self.link_time_optimization:
209209
self.formatted_options.append("-lto")
210210
if self.ptx is not None:
211211
self.formatted_options.append("-ptx")
212212
if self.optimization_level is not None:
213213
self.formatted_options.append(f"-O{self.optimization_level}")
214-
if self.debug is not None:
214+
if self.debug is not None and self.debug:
215215
self.formatted_options.append("-g")
216-
if self.lineinfo is not None:
216+
if self.lineinfo is not None and self.lineinfo:
217217
self.formatted_options.append("-lineinfo")
218218
if self.ftz is not None:
219219
self.formatted_options.append(f"-ftz={'true' if self.ftz else 'false'}")

cuda_core/cuda/core/experimental/_program.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ def __post_init__(self):
244244
self._formatted_options.append("--device-debug")
245245
if self.lineinfo is not None and self.lineinfo:
246246
self._formatted_options.append("--generate-line-info")
247-
if self.device_code_optimize is not None:
248-
self._formatted_options.append(f"--dopt={'on' if self.device_code_optimize else 'off'}")
247+
if self.device_code_optimize is not None and self.device_code_optimize:
248+
self._formatted_options.append("--dopt=on")
249249
if self.ptxas_options is not None:
250250
opt_name = "--ptxas-options"
251251
if isinstance(self.ptxas_options, str):
@@ -351,7 +351,7 @@ def _as_bytes(self):
351351

352352
def __repr__(self):
353353
# __TODO__ improve this
354-
return self._formatted_options
354+
return str(self._formatted_options)
355355

356356

357357
ProgramHandleT = Union["cuda.bindings.nvrtc.nvrtcProgram", LinkerHandleT]

0 commit comments

Comments
 (0)