forked from mesonbuild/meson
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rust: rlib/staticlib should not link with C libraries
- Loading branch information
Showing
8 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
int c_func(void); | ||
int c_func(void) { | ||
return 123; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
int r3(void); | ||
|
||
int main_func(void) { | ||
return r3() == 246 ? 0 : 1; | ||
} |
17 changes: 17 additions & 0 deletions
17
test cases/rust/20 transitive dependencies/diamond/meson.build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Regression test for a diamond dependency graph: | ||
# ┌►R1┐ | ||
# main-►R3─┤ ├─►C1 | ||
# └►R2┘ | ||
# Both libr1.rlib and libr2.rlib used to contain func.c.o. That was causing | ||
# libr3.rlib to have duplicated func.c.o and then libmain.so failed to link: | ||
# multiple definition of `c_func'. | ||
|
||
libc1 = static_library('c1', 'func.c') | ||
libr1 = static_library('r1', 'r1.rs', link_with: libc1) | ||
libr2 = static_library('r2', 'r2.rs', link_with: libc1) | ||
libr3 = static_library('r3', 'r3.rs', | ||
link_with: [libr1, libr2], | ||
rust_abi: 'c', | ||
) | ||
|
||
shared_library('main', 'main.c', link_whole: [libr3]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
extern "C" { | ||
fn c_func() -> i32; | ||
} | ||
|
||
pub fn r1() -> i32 { | ||
unsafe { | ||
c_func() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
extern "C" { | ||
fn c_func() -> i32; | ||
} | ||
|
||
pub fn r2() -> i32 { | ||
unsafe { | ||
c_func() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[no_mangle] | ||
pub fn r3() -> i32 { | ||
r1::r1() + r2::r2() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,5 @@ exe = executable('footest', 'foo.c', | |
link_with: foo, | ||
) | ||
test('footest', exe) | ||
|
||
subdir('diamond') |