diff options
| author | Alyssa Ross <hi@alyssa.is> | 2024-07-16 10:21:43 +0200 |
|---|---|---|
| committer | Xavier Claessens <xclaesse@gmail.com> | 2024-07-17 13:20:16 -0400 |
| commit | a05f6a260ef4882f82da38ff1818ca8391b15bd8 (patch) | |
| tree | aefc5f59db94399067814f6d28e84aee50c04e6e /test cases | |
| parent | 6e200222957063819a00e3bf767ce28b7489c31f (diff) | |
| download | meson-a05f6a260ef4882f82da38ff1818ca8391b15bd8.tar.gz | |
rust: recursively pull proc-macro deps for rust targets
aee941559 ("rust: recursively pull proc-macro dependencies as well")
had to be reverted (in a66cb97e8) because it broke Mesa cross
compilation. This happened because a C shared library was linked with
a Rust C-ABI static library, which caused it to inherit the proc macro
dependency the Rust static library was linked with.
The right way to handle this is for only Rust targets to inherit proc
macro dependencies from static libraries they link with. A Rust
executable, library, or whatever will need the proc macros its Rust
dependencies use, as illustrated in the test case that I've
reintroduced here.
I've verified that Mesa still cross compiles correctly with this
change. The same failure was also identified by the "rust/21
transitive dependencies" test case, but only when cross compiling, so
it wasn't caught by CI.
Co-authored-by: Xavier Claessens <xavier.claessens@collabora.com>
Diffstat (limited to 'test cases')
| -rw-r--r-- | test cases/rust/18 proc-macro/lib.rs | 8 | ||||
| -rw-r--r-- | test cases/rust/18 proc-macro/meson.build | 11 | ||||
| -rw-r--r-- | test cases/rust/18 proc-macro/subdir/meson.build | 1 | ||||
| -rw-r--r-- | test cases/rust/18 proc-macro/transitive-proc-macro.rs | 7 | ||||
| -rw-r--r-- | test cases/rust/21 transitive dependencies/meson.build | 1 |
5 files changed, 28 insertions, 0 deletions
diff --git a/test cases/rust/18 proc-macro/lib.rs b/test cases/rust/18 proc-macro/lib.rs new file mode 100644 index 000000000..5242886cc --- /dev/null +++ b/test cases/rust/18 proc-macro/lib.rs @@ -0,0 +1,8 @@ +extern crate proc_macro_examples; +use proc_macro_examples::make_answer; + +make_answer!(); + +pub fn func() -> u32 { + answer() +} diff --git a/test cases/rust/18 proc-macro/meson.build b/test cases/rust/18 proc-macro/meson.build index c5f0dfc82..e8b28eda1 100644 --- a/test cases/rust/18 proc-macro/meson.build +++ b/test cases/rust/18 proc-macro/meson.build @@ -31,3 +31,14 @@ main = executable( ) test('main_test2', main) + +subdir('subdir') + +staticlib = static_library('staticlib', 'lib.rs', + link_with: pm_in_subdir, + rust_dependency_map : {'proc_macro_examples3' : 'proc_macro_examples'} +) + +executable('transitive-proc-macro', 'transitive-proc-macro.rs', + link_with: staticlib, +) diff --git a/test cases/rust/18 proc-macro/subdir/meson.build b/test cases/rust/18 proc-macro/subdir/meson.build new file mode 100644 index 000000000..04842c431 --- /dev/null +++ b/test cases/rust/18 proc-macro/subdir/meson.build @@ -0,0 +1 @@ +pm_in_subdir = rust.proc_macro('proc_macro_examples3', '../proc.rs') diff --git a/test cases/rust/18 proc-macro/transitive-proc-macro.rs b/test cases/rust/18 proc-macro/transitive-proc-macro.rs new file mode 100644 index 000000000..4c804b3b6 --- /dev/null +++ b/test cases/rust/18 proc-macro/transitive-proc-macro.rs @@ -0,0 +1,7 @@ +extern crate staticlib; +use staticlib::func; + + +fn main() { + assert_eq!(42, func()); +} diff --git a/test cases/rust/21 transitive dependencies/meson.build b/test cases/rust/21 transitive dependencies/meson.build index 37687fd4d..3b1f3d63c 100644 --- a/test cases/rust/21 transitive dependencies/meson.build +++ b/test cases/rust/21 transitive dependencies/meson.build @@ -21,6 +21,7 @@ foo = static_library('foo-rs', 'foo.rs', rust_abi: 'c', link_with: pm, ) +shared_library('shared', 'foo.c', link_with : foo) exe = executable('footest', 'foo.c', link_with: foo, ) |
