diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2023-07-05 01:10:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-05 01:10:58 +0300 |
commit | d391e5281c982899e17c7a5ceeca30262f1640ea (patch) | |
tree | 17d134e2b037d66f4e75468e552587b7d9b0b95d /test cases | |
parent | 7fe6e18a02129d788cd29e6861b331341265f4c7 (diff) | |
parent | ff86e799a4d1119f51d7e7715944a2c87eaef509 (diff) | |
download | meson-d391e5281c982899e17c7a5ceeca30262f1640ea.zip meson-d391e5281c982899e17c7a5ceeca30262f1640ea.tar.gz meson-d391e5281c982899e17c7a5ceeca30262f1640ea.tar.bz2 |
Merge pull request #11742 from xclaesse/link-whole-cases
Fix niche cases when linking static libs
Diffstat (limited to 'test cases')
-rw-r--r-- | test cases/rust/5 polyglot static/meson.build | 13 | ||||
-rw-r--r-- | test cases/rust/5 polyglot static/test.json | 3 | ||||
-rw-r--r-- | test cases/unit/113 complex link cases/main.c | 6 | ||||
-rw-r--r-- | test cases/unit/113 complex link cases/meson.build | 40 | ||||
-rw-r--r-- | test cases/unit/113 complex link cases/s1.c | 3 | ||||
-rw-r--r-- | test cases/unit/113 complex link cases/s2.c | 5 | ||||
-rw-r--r-- | test cases/unit/113 complex link cases/s3.c | 5 |
7 files changed, 72 insertions, 3 deletions
diff --git a/test cases/rust/5 polyglot static/meson.build b/test cases/rust/5 polyglot static/meson.build index 9fbba68..22c0cd0 100644 --- a/test cases/rust/5 polyglot static/meson.build +++ b/test cases/rust/5 polyglot static/meson.build @@ -1,7 +1,18 @@ project('static rust and c polyglot executable', 'c', 'rust') r = static_library('stuff', 'stuff.rs', rust_crate_type : 'staticlib') -l = static_library('clib', 'clib.c', link_with : r, install : true) + +# clib is installed static library and stuff is not installed. That means that +# to be usable clib must link_whole stuff. Meson automatically promote to link_whole, +# as it would do with C libraries, but then cannot extract objects from stuff and +# thus should error out. +# FIXME: We should support this use-case in the future. +testcase expect_error('Cannot link_whole a custom or Rust target into a static library') + l = static_library('clib', 'clib.c', link_with : r, install : true) +endtestcase + +l = static_library('clib', 'clib.c', link_with : r) + e = executable('prog', 'prog.c', link_with : l, install : true) diff --git a/test cases/rust/5 polyglot static/test.json b/test cases/rust/5 polyglot static/test.json index cc0d2da..135300d 100644 --- a/test cases/rust/5 polyglot static/test.json +++ b/test cases/rust/5 polyglot static/test.json @@ -1,7 +1,6 @@ { "installed": [ {"type": "exe", "file": "usr/bin/prog"}, - {"type": "pdb", "file": "usr/bin/prog"}, - {"type": "file", "file": "usr/lib/libclib.a"} + {"type": "pdb", "file": "usr/bin/prog"} ] } diff --git a/test cases/unit/113 complex link cases/main.c b/test cases/unit/113 complex link cases/main.c new file mode 100644 index 0000000..739b413 --- /dev/null +++ b/test cases/unit/113 complex link cases/main.c @@ -0,0 +1,6 @@ +int s3(void); + +int main(int argc, char *argv[]) +{ + return s3(); +} diff --git a/test cases/unit/113 complex link cases/meson.build b/test cases/unit/113 complex link cases/meson.build new file mode 100644 index 0000000..d3387c2 --- /dev/null +++ b/test cases/unit/113 complex link cases/meson.build @@ -0,0 +1,40 @@ +project('complex link cases', 'c') + +# In all tests, e1 uses s3 which uses s2 which uses s1. + +# Executable links with s3 and s1 but not s2 because it is included in s3. +s1 = static_library('t1-s1', 's1.c') +s2 = static_library('t1-s2', 's2.c', link_with: s1) +s3 = static_library('t1-s3', 's3.c', link_whole: s2) +e = executable('t1-e1', 'main.c', link_with: s3) + +# s3 is installed but not s1 so it has to include s1 too. +# Executable links only s3 because it contains s1 and s2. +s1 = static_library('t2-s1', 's1.c') +s2 = static_library('t2-s2', 's2.c', link_with: s1) +s3 = static_library('t2-s3', 's3.c', link_whole: s2, install: true) +e = executable('t2-e1', 'main.c', link_with: s3) + +# Executable needs to link with s3 only +s1 = static_library('t3-s1', 's1.c') +s2 = static_library('t3-s2', 's2.c', link_with: s1) +s3 = shared_library('t3-s3', 's3.c', link_with: s2) +e = executable('t3-e1', 'main.c', link_with: s3) + +# Executable needs to link with s3 and s2 +s1 = static_library('t4-s1', 's1.c') +s2 = shared_library('t4-s2', 's2.c', link_with: s1) +s3 = static_library('t4-s3', 's3.c', link_with: s2) +e = executable('t4-e1', 'main.c', link_with: s3) + +# Executable needs to link with s3 and s1 +s1 = shared_library('t5-s1', 's1.c') +s2 = static_library('t5-s2', 's2.c', link_with: s1) +s3 = static_library('t5-s3', 's3.c', link_with: s2, install: true) +e = executable('t5-e1', 'main.c', link_with: s3) + +# Executable needs to link with s3 and s2 +s1 = static_library('t6-s1', 's1.c') +s2 = static_library('t6-s2', 's2.c', link_with: s1, install: true) +s3 = static_library('t6-s3', 's3.c', link_with: s2, install: true) +e = executable('t6-e1', 'main.c', link_with: s3) diff --git a/test cases/unit/113 complex link cases/s1.c b/test cases/unit/113 complex link cases/s1.c new file mode 100644 index 0000000..68bba49 --- /dev/null +++ b/test cases/unit/113 complex link cases/s1.c @@ -0,0 +1,3 @@ +int s1(void) { + return 1; +} diff --git a/test cases/unit/113 complex link cases/s2.c b/test cases/unit/113 complex link cases/s2.c new file mode 100644 index 0000000..835870c --- /dev/null +++ b/test cases/unit/113 complex link cases/s2.c @@ -0,0 +1,5 @@ +int s1(void); + +int s2(void) { + return s1() + 1; +} diff --git a/test cases/unit/113 complex link cases/s3.c b/test cases/unit/113 complex link cases/s3.c new file mode 100644 index 0000000..08e0620 --- /dev/null +++ b/test cases/unit/113 complex link cases/s3.c @@ -0,0 +1,5 @@ +int s2(void); + +int s3(void) { + return s2() + 1; +} |