Skip to content

Commit

Permalink
cuda: disable thin archives when 'cuda' is enabled globally
Browse files Browse the repository at this point in the history
Bug: mesonbuild/pull/9453
Bug: mesonbuild/issues/9479#issuecomment-953485040
  • Loading branch information
SoapGentoo committed May 7, 2024
1 parent ba39f71 commit 9947d0f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,19 @@ def __init__(self, build: T.Optional[build.Build], interpreter: T.Optional[Inter
self.rust_crates: T.Dict[str, RustCrate] = {}
self.implicit_meson_outs = []
self._uses_dyndeps = False
# nvcc chokes on thin archives:
# nvlink fatal : Could not open input file 'libfoo.a.p'
# nvlink fatal : elfLink internal error
# hence we disable them if 'cuda' is enabled globally. See also
# - https://github.com/mesonbuild/meson/pull/9453
# - https://github.com/mesonbuild/meson/issues/9479#issuecomment-953485040
self._allow_thin_archives = PerMachine[bool](
'cuda' not in self.environment.coredata.compilers.build,
'cuda' not in self.environment.coredata.compilers.host) if self.environment else PerMachine[bool](True, True)
if not self._allow_thin_archives.build:
mlog.debug('cuda enabled globally, disabling thin archives for build machine, since nvcc/nvlink cannot handle thin archives natively')
if not self._allow_thin_archives.host:
mlog.debug('cuda enabled globally, disabling thin archives for host machine, since nvcc/nvlink cannot handle thin archives natively')

def create_phony_target(self, dummy_outfile: str, rulename: str, phony_infilename: str) -> NinjaBuildElement:
'''
Expand Down Expand Up @@ -3255,7 +3268,8 @@ def get_target_type_link_args(self, target, linker):
if target.import_filename:
commands += linker.gen_import_library_args(self.get_import_filename(target))
elif isinstance(target, build.StaticLibrary):
commands += linker.get_std_link_args(self.environment, not target.should_install())
produce_thin_archive = self._allow_thin_archives[target.for_machine] and not target.should_install()
commands += linker.get_std_link_args(self.environment, produce_thin_archive)
else:
raise RuntimeError('Unknown build target type.')
return commands
Expand Down

0 comments on commit 9947d0f

Please sign in to comment.