diff options
| author | Alyssa Ross <hi@alyssa.is> | 2023-12-15 19:06:13 +0100 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2024-01-17 13:36:15 -0800 |
| commit | 1ca2c74d16c3f5987f686e358b58ce5d2253ce9b (patch) | |
| tree | 7d0c2ab046ac34f69c0c7b93eacf3099f62013d7 /test cases | |
| parent | bd3f1b2e0e70ef16dfa4f441686003212440a09b (diff) | |
| download | meson-1ca2c74d16c3f5987f686e358b58ce5d2253ce9b.tar.gz | |
rust: fix linking static executables
For the same reason as for static libraries, we have to use -l when
generating static executables.
Fixes: https://github.com/mesonbuild/meson/issues/12585
Diffstat (limited to 'test cases')
| -rw-r--r-- | test cases/rust/23 crt-static/lib.c | 6 | ||||
| -rw-r--r-- | test cases/rust/23 crt-static/main.rs | 9 | ||||
| -rw-r--r-- | test cases/rust/23 crt-static/meson.build | 9 | ||||
| -rw-r--r-- | test cases/rust/23 crt-static/test.json | 5 |
4 files changed, 29 insertions, 0 deletions
diff --git a/test cases/rust/23 crt-static/lib.c b/test cases/rust/23 crt-static/lib.c new file mode 100644 index 000000000..f18e504a3 --- /dev/null +++ b/test cases/rust/23 crt-static/lib.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void test_function(void) +{ + puts("Hello, world!"); +} diff --git a/test cases/rust/23 crt-static/main.rs b/test cases/rust/23 crt-static/main.rs new file mode 100644 index 000000000..d527ed970 --- /dev/null +++ b/test cases/rust/23 crt-static/main.rs @@ -0,0 +1,9 @@ +extern "C" { + fn test_function(); +} + +pub fn main() { + unsafe { + test_function(); + } +} diff --git a/test cases/rust/23 crt-static/meson.build b/test cases/rust/23 crt-static/meson.build new file mode 100644 index 000000000..dcdfc36e2 --- /dev/null +++ b/test cases/rust/23 crt-static/meson.build @@ -0,0 +1,9 @@ +project('rustprog', 'c') + +if not add_languages('rust', required : false) + error('MESON_SKIP_TEST crt-static doesn\'t work') +endif + +c_lib = static_library('lib', 'lib.c') + +executable('main', 'main.rs', link_with : c_lib) diff --git a/test cases/rust/23 crt-static/test.json b/test cases/rust/23 crt-static/test.json new file mode 100644 index 000000000..2d9470985 --- /dev/null +++ b/test cases/rust/23 crt-static/test.json @@ -0,0 +1,5 @@ +{ + "env": { + "RUSTC": "rustc -C target-feature=+crt-static" + } +} |
