diff options
| -rw-r--r-- | mesonbuild/build.py | 5 | ||||
| -rw-r--r-- | test cases/rust/28 self-contained/lib.rs | 4 | ||||
| -rw-r--r-- | test cases/rust/28 self-contained/main.c | 6 | ||||
| -rw-r--r-- | test cases/rust/28 self-contained/meson.build | 17 | ||||
| -rw-r--r-- | test cases/rust/28 self-contained/test.json | 6 |
5 files changed, 36 insertions, 2 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index a43709342..0ad679450 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -2327,8 +2327,9 @@ class StaticLibrary(BuildTarget): # and thus, machine_info kernel should be set to 'none'. # In that case, native_static_libs list is empty. rustc = self.compilers['rust'] - d = dependencies.InternalDependency('undefined', [], [], - rustc.native_static_libs, + link_args = ['-L' + rustc.get_target_libdir() + '/self-contained'] + link_args += rustc.native_static_libs + d = dependencies.InternalDependency('undefined', [], [], link_args, [], [], [], [], [], {}, [], [], [], '_rust_native_static_libs') self.external_deps.append(d) diff --git a/test cases/rust/28 self-contained/lib.rs b/test cases/rust/28 self-contained/lib.rs new file mode 100644 index 000000000..f8a8bf201 --- /dev/null +++ b/test cases/rust/28 self-contained/lib.rs @@ -0,0 +1,4 @@ +#[unsafe(export_name = "hello")] +pub extern "C" fn hello() { + println!("Hello, world!"); +} diff --git a/test cases/rust/28 self-contained/main.c b/test cases/rust/28 self-contained/main.c new file mode 100644 index 000000000..11bedf5ae --- /dev/null +++ b/test cases/rust/28 self-contained/main.c @@ -0,0 +1,6 @@ +extern void hello(void); + +int main(void) +{ + hello(); +} diff --git a/test cases/rust/28 self-contained/meson.build b/test cases/rust/28 self-contained/meson.build new file mode 100644 index 000000000..25de68f25 --- /dev/null +++ b/test cases/rust/28 self-contained/meson.build @@ -0,0 +1,17 @@ +project('self-contained', meson_version : '>= 1.3.0') + +if not add_languages('c', native : false, required : false) + error('MESON_SKIP_TEST clang not installed') +endif + +if not add_languages('rust', native : false, required : false) + error('MESON_SKIP_TEST Rust x86_64-unknown-linux-musl target not installed') +endif + +if meson.get_compiler('c').find_library('libunwind', required : false).found() + error('MESON_SKIP_TEST libunwind is installed globally') +endif + +lib = static_library('rust', 'lib.rs', rust_abi : 'c') + +executable('exe', 'main.c', link_with : lib) diff --git a/test cases/rust/28 self-contained/test.json b/test cases/rust/28 self-contained/test.json new file mode 100644 index 000000000..fccefd6f1 --- /dev/null +++ b/test cases/rust/28 self-contained/test.json @@ -0,0 +1,6 @@ +{ + "env": { + "CC": "clang -target x86_64-unknown-linux-musl", + "RUSTC": "rustc --target x86_64-unknown-linux-musl" + } +} |
