Some linker sections are missing when building project with nightly toolchain (original) (raw)

I'm using Ubuntu Linux 20.04.

I have a project which build some .c files (lttng tracepoints) in build.rs with cc::Build and link it to executable.
In stable version of Rust toolchain everything works fine.

But when compiling it with nightly Rust toolchain some tracepoint data is missing in resulting executable and tracing does not working.

Code

Here is the archive of minimal project which have a link problem on nightly:
lttng_link_test.zip

To build the code you may need to install liblttng-ust-dev package.
The Rust toolchain is specified in rust-toolchain.toml file of the project.

I tried this code:

cargo build nm target/debug/lttng_link_test | grep tracepoint_ptr

I expected to see this happen:

0000000000057118 d __tracepoint_ptr_hello_world___my_first_tracepoint 0000000000057128 V __tracepoint_ptrs_registered

Instead, this happened:

0000000000059988 b __tracepoint_ptrs_registered

The __tracepoint_ptr_hello_world___my_first_tracepoint is missing.

Version it worked on

It most recently worked on:

rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7

Version with regression

rustc 1.83.0-nightly (9b72238eb 2024-09-14)
binary: rustc
commit-hash: 9b72238eb813e9d06e9e9d270168512fbffd7ee7
commit-date: 2024-09-14
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0