Skip to content

Commit

Permalink
Found cause - rust-lang/rust#47384?
Browse files Browse the repository at this point in the history
  • Loading branch information
Raekye committed Oct 4, 2023
1 parent 84d2f56 commit 3a92401
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 9 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Functions from the library crate marked `#[no_mangle]` seem to be removed from executables if no references are made to the library,
even when a linker arg like `-rdynamic` is used.
This behaviour seems to be described in this bug report: https://github.com/rust-lang/rust/issues/47384.
However, that bug report is supposedly fixed by https://github.com/rust-lang/rust/pull/95604.

```
# cat src/bin/without_extern_crate.rs
fn main() {
println!("Hello, world!");
}
```

```
# RUSTFLAGS='-C link-arg=-rdynamic' cargo build && nm -g target/debug/without_extern_crate.rs | grep foo
# nothing
```

```
# cat src/bin/with_extern_crate.rs
extern crate export_symbols;
fn main() {
println!("Hello, world!");
}
```

```
# RUSTFLAGS='-C link-arg=-rdynamic' cargo build && nm -g target/debug/with_extern_crate.rs | grep foo
000000000006dfa0 T foo1
000000000006dfb0 T foo2
```
3 changes: 0 additions & 3 deletions build.rs

This file was deleted.

6 changes: 0 additions & 6 deletions src/bin/main.rs

This file was deleted.

5 changes: 5 additions & 0 deletions src/bin/with_extern_crate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extern crate export_symbols;

fn main() {
println!("Hello, world!");
}
3 changes: 3 additions & 0 deletions src/bin/without_extern_crate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

0 comments on commit 3a92401

Please sign in to comment.