aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Seifert <soap@gentoo.org>2024-05-29 22:19:02 +0200
committerEli Schwartz <eschwartz93@gmail.com>2024-05-29 19:13:14 -0400
commit7f2c6f644b83f27d1f46aacf8ac59722498529ff (patch)
tree477eff8ef5a03ee6051a14233d8d47d3901ea9d4
parent8d9248716cdc6cfc3ddcda7b825b2e470fdc767f (diff)
downloadmeson-7f2c6f644b83f27d1f46aacf8ac59722498529ff.zip
meson-7f2c6f644b83f27d1f46aacf8ac59722498529ff.tar.gz
meson-7f2c6f644b83f27d1f46aacf8ac59722498529ff.tar.bz2
cuda: disable thin archives when cuda is added through `add_languages('cuda')` later
-rw-r--r--mesonbuild/backend/ninjabackend.py15
-rw-r--r--mesonbuild/interpreter/interpreter.py4
2 files changed, 11 insertions, 8 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 28f5d53..4d56f7d 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -502,13 +502,12 @@ class NinjaBackend(backends.Backend):
# 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')
+ self.allow_thin_archives = PerMachine[bool](True, True)
+ if self.environment:
+ for for_machine in MachineChoice:
+ if 'cuda' in self.environment.coredata.compilers[for_machine]:
+ mlog.debug('cuda enabled globally, disabling thin archives for {}, since nvcc/nvlink cannot handle thin archives natively'.format(for_machine))
+ self.allow_thin_archives[for_machine] = False
def create_phony_target(self, dummy_outfile: str, rulename: str, phony_infilename: str) -> NinjaBuildElement:
'''
@@ -3268,7 +3267,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
if target.import_filename:
commands += linker.gen_import_library_args(self.get_import_filename(target))
elif isinstance(target, build.StaticLibrary):
- produce_thin_archive = self._allow_thin_archives[target.for_machine] and 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.')
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index 67c000c..6474e60 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -1531,6 +1531,10 @@ class Interpreter(InterpreterBase, HoldableObject):
continue
else:
raise
+ if lang == 'cuda' and hasattr(self.backend, 'allow_thin_archives'):
+ # see NinjaBackend.__init__() why we need to disable thin archives for cuda
+ mlog.debug('added cuda as language, disabling thin archives for {}, since nvcc/nvlink cannot handle thin archives natively'.format(for_machine))
+ self.backend.allow_thin_archives[for_machine] = False
else:
# update new values from commandline, if it applies
self.coredata.process_compiler_options(lang, comp, self.environment, self.subproject)