diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-07-21 12:15:46 +0200 |
|---|---|---|
| committer | Jussi Pakkanen <jussi.pakkanen@mailbox.org> | 2025-07-29 21:58:47 +0300 |
| commit | 9b40c5fe4a9899daa214c736726ca4739138e24a (patch) | |
| tree | e306b9f34dd8aea29f9e320f0cde3e9a49105c78 | |
| parent | 0237e2f3f954ec718638077bc4c356532739d93f (diff) | |
| download | meson-9b40c5fe4a9899daa214c736726ca4739138e24a.tar.gz | |
ninjabackend: handle specially TUs where compilation and linking happens together
Rust sources are not compiled separately: generation of the .a or .so
or binary happens at the same time as compilation. There is no separate
compilation phase where the .o file is created.
In preparation for moving generate_rust_target where generate_link is now,
make the compilation phase of generate_target skip them.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
| -rw-r--r-- | mesonbuild/backend/ninjabackend.py | 4 | ||||
| -rw-r--r-- | mesonbuild/compilers/__init__.py | 2 | ||||
| -rw-r--r-- | mesonbuild/compilers/compilers.py | 3 | ||||
| -rw-r--r-- | mesonbuild/environment.py | 4 |
4 files changed, 13 insertions, 0 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 2b4bfd92b..a9f0bbb6a 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -993,6 +993,8 @@ class NinjaBackend(backends.Backend): # this target. We create the Ninja build file elements for this here # because we need `header_deps` to be fully generated in the above loop. for src in generated_source_files: + if not self.environment.is_separate_compile(src): + continue if self.environment.is_llvm_ir(src): o, s = self.generate_llvm_ir_compile(target, src) else: @@ -1051,6 +1053,8 @@ class NinjaBackend(backends.Backend): # Generate compile targets for all the preexisting sources for this target for src in target_sources.values(): + if not self.environment.is_separate_compile(src): + continue if self.environment.is_header(src) and not is_compile_target: continue if self.environment.is_llvm_ir(src): diff --git a/mesonbuild/compilers/__init__.py b/mesonbuild/compilers/__init__.py index aab761af4..f645090e1 100644 --- a/mesonbuild/compilers/__init__.py +++ b/mesonbuild/compilers/__init__.py @@ -18,6 +18,7 @@ __all__ = [ 'is_library', 'is_llvm_ir', 'is_object', + 'is_separate_compile', 'is_source', 'is_java', 'is_known_suffix', @@ -62,6 +63,7 @@ from .compilers import ( is_object, is_library, is_known_suffix, + is_separate_compile, lang_suffixes, LANGUAGES_USING_LDFLAGS, sort_clink, diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 76d8d72e7..5915790d0 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -154,6 +154,9 @@ def is_java(fname: mesonlib.FileOrString) -> bool: suffix = fname.split('.')[-1] return suffix in lang_suffixes['java'] +def is_separate_compile(fname: mesonlib.FileOrString) -> bool: + return not fname.endswith('.rs') + def is_llvm_ir(fname: 'mesonlib.FileOrString') -> bool: if isinstance(fname, mesonlib.File): fname = fname.fname diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 19e8b4e2e..489ef5077 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -35,6 +35,7 @@ from .compilers import ( is_library, is_llvm_ir, is_object, + is_separate_compile, is_source, ) @@ -937,6 +938,9 @@ class Environment: def is_assembly(self, fname: 'mesonlib.FileOrString') -> bool: return is_assembly(fname) + def is_separate_compile(self, fname: 'mesonlib.FileOrString') -> bool: + return is_separate_compile(fname) + def is_llvm_ir(self, fname: 'mesonlib.FileOrString') -> bool: return is_llvm_ir(fname) |
