rust: Don't pass dependency compile arguments to the compiler

Rust doesn't have a concept of dependency compile arguments, i.e.
something like headers. Dependencies are linked in and all required
metadata is provided by the linker flags.
pull/11683/head
Sebastian Dröge 2 years ago committed by Xavier Claessens
parent 93cafe7b14
commit 49e62877d1
  1. 7
      mesonbuild/compilers/rust.py
  2. 8
      test cases/rust/16 internal c dependencies/meson.build

@ -28,6 +28,7 @@ if T.TYPE_CHECKING:
from ..linkers import DynamicLinker
from ..mesonlib import MachineChoice
from ..programs import ExternalProgram
from ..dependencies import Dependency
rust_optimization_args = {
@ -153,6 +154,12 @@ class RustCompiler(Compiler):
),
}
def get_dependency_compile_args(self, dep: 'Dependency') -> T.List[str]:
# Rust doesn't have dependency compile arguments so simply return
# nothing here. Dependencies are linked and all required metadata is
# provided by the linker flags.
return []
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
args = []
key = OptionKey('std', machine=self.for_machine, lang=self.language)

@ -3,12 +3,16 @@ project('internal dependencies', 'c', 'rust')
test_prog = find_program('test.py')
static = static_library('static', 'lib.c', c_args : '-DMODE="static"')
exe = executable('static', 'main.rs', link_with : static)
# Add some -I compiler arguments to make sure they're not passed to the Rust
# compiler when handling the dependency.
static_dep = declare_dependency(link_with : static, compile_args : ['-Idoesnotexist'])
exe = executable('static', 'main.rs', dependencies : static_dep)
test('static linkage', test_prog, args : [exe, 'This is a static C library'])
# Shared linkage with rust doesn't work on macOS with meson, yet
if host_machine.system() != 'darwin'
shared = shared_library('shared', 'lib.c', c_args : '-DMODE="shared"')
exe = executable('shared', 'main.rs', link_with : shared)
shared_dep = declare_dependency(link_with : shared, compile_args : ['-Idoesnotexist'])
exe = executable('shared', 'main.rs', dependencies : shared_dep)
test('shared linkage', test_prog, args : [exe, 'This is a shared C library'])
endif

Loading…
Cancel
Save