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.
Implement rustc controlled whole-archive linking
Rustc as of version 1.61.0 has support for controlling when whole-archive linking takes place, previous to this it tried to make a good guess about what you wanted, which worked most of the time. This is now implemented. Additionally, because meson breaks some rustc assumption about library naming on windows, we have to manually pass whole-archive libraries, bypassing rustc's interface and talking directly to the linker for MSVC (and those imitating it), which we were doing incorrectly. This has been fixed. Fixes: mesonbuild#10723 Fixes: mesonbuild#11247 Co-authored-by: Nirbheek Chauhan <nirbheek@centricular.com>
- Loading branch information
Showing
11 changed files
with
78 additions
and
11 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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
project('rust static library', 'rust') | ||
project('rust static library', 'rust', 'c') | ||
|
||
l = static_library('stuff', 'stuff.rs', install : true) | ||
o = static_library('other', 'other.rs') | ||
v = static_library('value', 'value.c') | ||
l = static_library('stuff', 'stuff.rs', link_whole : [o, v], install : true) | ||
e = executable('prog', 'prog.rs', link_with : l, install : true) | ||
test('linktest', e) |
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 @@ | ||
pub fn explore( | ||
value: i32, | ||
) -> String { | ||
format!("library{}string", value) | ||
} |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
extern crate stuff; | ||
|
||
fn main() { println!("printing: {}", stuff::explore()); } | ||
fn main() { | ||
println!("printing: {}", stuff::explore()); | ||
} |
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 |
---|---|---|
@@ -1,3 +1,14 @@ | ||
#![crate_name = "stuff"] | ||
|
||
pub fn explore() -> &'static str { "librarystring" } | ||
extern crate other; | ||
|
||
extern "C" { | ||
fn c_explore_value() -> i32; | ||
} | ||
|
||
pub fn explore( | ||
) -> String { | ||
unsafe { | ||
other::explore(c_explore_value()) | ||
} | ||
} |
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 | ||
c_explore_value (void) | ||
{ | ||
return 42; | ||
} |
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,12 @@ | ||
#include <stdio.h> | ||
|
||
void hello_from_rust(void); | ||
|
||
static void hello_from_c(void) { | ||
printf("Hello from C!\n"); | ||
} | ||
|
||
void hello_from_both(void) { | ||
hello_from_c(); | ||
hello_from_rust(); | ||
} |
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 |
---|---|---|
@@ -1,8 +1,7 @@ | ||
#include <stdio.h> | ||
|
||
void f(); | ||
void hello_from_both(); | ||
|
||
int main(void) { | ||
printf("Hello from C!\n"); | ||
f(); | ||
hello_from_both(); | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#![crate_name = "stuff"] | ||
|
||
#[no_mangle] | ||
pub extern fn f() { | ||
pub extern "C" fn hello_from_rust() { | ||
println!("Hello from Rust!"); | ||
} |
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