Skip to content

generate elf symbol version in raw-dylib - #144221

Merged
bors merged 1 commit into
rust-lang:masterfrom
usamoi:versym
Jul 24, 2025
Merged

generate elf symbol version in raw-dylib#144221
bors merged 1 commit into
rust-lang:masterfrom
usamoi:versym

Conversation

@usamoi

@usamoiusamoi commented Jul 20, 2025

Copy link
Copy Markdown
Contributor

For link names like aaa@bbb, it generates a symbol named aaa and a version named bbb.

For link names like aaa\0bbb, aaa@@bbb or aa@bb@cc, it emits errors.

It adds a test that the executable is linked with glibc using raw-dylib.

cc #135694

@rustbot

Copy link
Copy Markdown
Collaborator

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbotrustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 20, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

This PR modifies run-make tests.

cc @jieyouxu

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

@bjorn3

bjorn3 commented Jul 21, 2025

Copy link
Copy Markdown
Member

For link names like aaa@@bbb or aa@bb@cc, it does not generate any symbols or versions.

At least aaa@@bbb seems like an easy mistake to make if you just copy from the nm -D output. @@ indicates that this is the default version of the symbol that should be linked against when no version is specified. Maybe emit an error on @@ suggesting to use @ instead?

Edit: Ah you mean entirely omitting it from the raw-dylib. That seems wrong. That may or may not cause a linker error depending on what other crates do and what the monomorphization collector does.

Comment threadtests/run-make/raw-dylib-elf-symver/t/src/main.rs Outdated
Comment threadcompiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs Outdated
Comment threadcompiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs Outdated
@petrochenkov

Copy link
Copy Markdown
Contributor

r? @bjorn3

@rustbotrustbot assigned bjorn3 and unassigned petrochenkovJul 21, 2025
@bjorn3

Copy link
Copy Markdown
Member

cc @Noratrieb

Comment threadtests/run-make/raw-dylib-elf-symver/rmake.rs Outdated
@rustbotrustbot removed the A-run-make Area: port run-make Makefiles to rmake.rs label Jul 22, 2025
Comment threadtests/ui/linkage-attr/raw-dylib/elf/malformed-link-name.rs Outdated
Comment threadtests/ui/linkage-attr/raw-dylib/elf/glibc-x86_64.rs
Comment threadcompiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs Outdated
Comment threadcompiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs
@bjorn3

Copy link
Copy Markdown
Member

https://maskray.me/blog/2020-11-26-all-about-symbol-versioning has been quite useful while reviewing this.

Comment threadcompiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs
@bjorn3

Copy link
Copy Markdown
Member

Thanks a lot for implementing this! One step closer to seamless cross-compilation.

@bors r+

@bors

bors commented Jul 22, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 3083d8f has been approved by bjorn3

It is now in the queue for this repository.

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 22, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 22, 2025
generate elf symbol version in raw-dylib
For link names like `aaa@bbb`, it generates a symbol named `aaa` and a version named `bbb`.
For link names like `aaa\0bbb`, `aaa@`@bbb`` or `aa@bb@cc`, it emits errors.
It adds a test that the executable is linked with glibc using raw-dylib.
cc rust-lang#135694
@fmeasefmease mentioned this pull request Jul 23, 2025
fmease added a commit to fmease/rust that referenced this pull request Jul 23, 2025
generate elf symbol version in raw-dylib
For link names like `aaa@bbb`, it generates a symbol named `aaa` and a version named `bbb`.
For link names like `aaa\0bbb`, `aaa@``@bbb``` or `aa@bb@cc`, it emits errors.
It adds a test that the executable is linked with glibc using raw-dylib.
cc rust-lang#135694
@fmeasefmease mentioned this pull request Jul 23, 2025
fmease added a commit to fmease/rust that referenced this pull request Jul 24, 2025
generate elf symbol version in raw-dylib
For link names like `aaa@bbb`, it generates a symbol named `aaa` and a version named `bbb`.
For link names like `aaa\0bbb`, `aaa@```@bbb```` or `aa@bb@cc`, it emits errors.
It adds a test that the executable is linked with glibc using raw-dylib.
cc rust-lang#135694
@fmeasefmease mentioned this pull request Jul 24, 2025
bors added a commit that referenced this pull request Jul 24, 2025
Rollup of 15 pull requests
Successful merges:
- #132748 (get rid of some false negatives in rustdoc::broken_intra_doc_links)
- #143374 (Unquerify extern_mod_stmt_cnum.)
- #143838 (std: net: uefi: Add support to query connection data)
- #144014 (don't link to the nightly version of the Edition Guide in stable lints)
- #144094 (Ensure we codegen the main fn)
- #144218 (Use serde for target spec json deserialize)
- #144221 (generate elf symbol version in raw-dylib)
- #144240 (Add more test case to check if the false note related to sealed trait suppressed)
- #144247 (coretests/num: use ldexp instead of hard-coding a power of 2)
- #144276 (Use less HIR in check_private_in_public.)
- #144317 (pass build.npm from bootstrap to tidy and use it for npm install)
- #144320 (rustdoc: avoid allocating a temp String for aliases in search index)
- #144334 (rustc_resolve: get rid of unused rustdoc::span_of_fragments_with_expansion)
- #144335 (Don't suggest assoc ty bound on non-angle-bracketed problematic assoc ty binding)
- #144358 (Stop using the old `validate_attr` logic for stability attributes)
r? `@ghost`
`@rustbot` modify labels: rollup
fmease added a commit to fmease/rust that referenced this pull request Jul 24, 2025
generate elf symbol version in raw-dylib
For link names like `aaa@bbb`, it generates a symbol named `aaa` and a version named `bbb`.
For link names like `aaa\0bbb`, `aaa@````@bbb````` or `aa@bb@cc`, it emits errors.
It adds a test that the executable is linked with glibc using raw-dylib.
cc rust-lang#135694
@fmeasefmease mentioned this pull request Jul 24, 2025
bors added a commit that referenced this pull request Jul 24, 2025
Rollup of 16 pull requests
Successful merges:
- #143374 (Unquerify extern_mod_stmt_cnum.)
- #143838 (std: net: uefi: Add support to query connection data)
- #144014 (don't link to the nightly version of the Edition Guide in stable lints)
- #144094 (Ensure we codegen the main fn)
- #144218 (Use serde for target spec json deserialize)
- #144221 (generate elf symbol version in raw-dylib)
- #144232 (Implement support for `become` and explicit tail call codegen for the LLVM backend)
- #144240 (Add more test case to check if the false note related to sealed trait suppressed)
- #144247 (coretests/num: use ldexp instead of hard-coding a power of 2)
- #144276 (Use less HIR in check_private_in_public.)
- #144278 (add Rev::into_inner)
- #144317 (pass build.npm from bootstrap to tidy and use it for npm install)
- #144320 (rustdoc: avoid allocating a temp String for aliases in search index)
- #144334 (rustc_resolve: get rid of unused rustdoc::span_of_fragments_with_expansion)
- #144335 (Don't suggest assoc ty bound on non-angle-bracketed problematic assoc ty binding)
- #144358 (Stop using the old `validate_attr` logic for stability attributes)
r? `@ghost`
`@rustbot` modify labels: rollup
@jieyouxu

Copy link
Copy Markdown
Member

Failed in rollup: #144387 (comment)

---- [ui] tests/ui/linkage-attr/raw-dylib/elf/glibc-x86_64.rs stdout ----
error: test compilation failed although it shouldn't!
status: exit status:1
command: env -u RUSTC_LOG_COLORRUSTC_ICE="0"RUST_BACKTRACE="short""/checkout/obj/build/unpacked-dist/rustc-nightly-x86_64-unknown-linux-gnu/rustc/bin/rustc""/checkout/tests/ui/linkage-attr/raw-dylib/elf/glibc-x86_64.rs""-Zthreads=1""-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX""-Ztranslate-remapped-path-to-local-path=no""-Z""ignore-directory-in-diagnostics-source-blocks=/cargo""-Z""ignore-directory-in-diagnostics-source-blocks=/checkout/vendor""--sysroot""/checkout/obj/build/unpacked-dist/rustc-nightly-x86_64-unknown-linux-gnu/rustc""--target=x86_64-unknown-linux-gnu""--check-cfg""cfg(test,FALSE)""-O""--error-format""json""--json""future-incompat""-Ccodegen-units=1""-Zui-testing""-Zdeduplicate-diagnostics=no""-Zwrite-long-types-to-disk=no""-Cstrip=debuginfo""-C""prefer-dynamic""-o""/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/linkage-attr/raw-dylib/elf/glibc-x86_64/a""-A""internal_features""-A""unused_parens""-A""unused_braces""-Crpath""-Cdebuginfo=0""-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers""--edition=2024""-Cpanic=abort"
stdout: none
--- stderr -------------------------------
error: linking with `cc` failed: exit status:1
|
= note:"cc""-m64""/tmp/rustchrNwsb/symbols.o""<1 object files omitted>""-Wl,--as-needed""-Wl,-Bstatic""<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libcore-*,libcompiler_builtins-*}.rlib""-L""/tmp/rustchrNwsb/raw-dylibs""-Wl,-Bdynamic""-Wl,--no-as-needed""-l:lib105m6f543m4qw1t7khnttg751.so""-Wl,--as-needed""-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld""-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld""-fuse-ld=lld""-Wl,--eh-frame-hdr""-Wl,-z,noexecstack""-L""/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers""-L""<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib""-o""/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/linkage-attr/raw-dylib/elf/glibc-x86_64/a""-Wl,--gc-sections""-pie""-Wl,-z,relro,-z,now""-Wl,-O1""-Wl,--strip-debug""-nodefaultlibs""-Wl,--enable-new-dtags,-z,origin"
= note: some arguments are omitted.use `--verbose` to show all linker arguments
= note: rust-lld: error: undefined symbol: __libc_csu_fini
>>> referenced by /lib/../lib64/Scrt1.o:(.text+0x12)
rust-lld: error: undefined symbol: __libc_csu_init
>>> referenced by /lib/../lib64/Scrt1.o:(.text+0x19)
collect2: error: ld returned 1 exit status

@bors r-

@borsbors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 24, 2025
@usamoi

usamoi commented Jul 24, 2025

Copy link
Copy Markdown
ContributorAuthor

This error only occurs in earlier versions of glibc, so unfortunately, it wasn't discovered in advance.

@rustbot ready

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 24, 2025
@bjorn3

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Jul 24, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit e31876c has been approved by bjorn3

It is now in the queue for this repository.

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 24, 2025
@fmeasefmease mentioned this pull request Jul 24, 2025
bors added a commit that referenced this pull request Jul 24, 2025
Rollup of 15 pull requests
Successful merges:
- #143374 (Unquerify extern_mod_stmt_cnum.)
- #143838 (std: net: uefi: Add support to query connection data)
- #144014 (don't link to the nightly version of the Edition Guide in stable lints)
- #144094 (Ensure we codegen the main fn)
- #144218 (Use serde for target spec json deserialize)
- #144221 (generate elf symbol version in raw-dylib)
- #144240 (Add more test case to check if the false note related to sealed trait suppressed)
- #144247 (coretests/num: use ldexp instead of hard-coding a power of 2)
- #144276 (Use less HIR in check_private_in_public.)
- #144278 (add Rev::into_inner)
- #144317 (pass build.npm from bootstrap to tidy and use it for npm install)
- #144320 (rustdoc: avoid allocating a temp String for aliases in search index)
- #144334 (rustc_resolve: get rid of unused rustdoc::span_of_fragments_with_expansion)
- #144335 (Don't suggest assoc ty bound on non-angle-bracketed problematic assoc ty binding)
- #144358 (Stop using the old `validate_attr` logic for stability attributes)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit cdca384 into rust-lang:masterJul 24, 2025
10 checks passed
@rustbotrustbot added this to the 1.90.0 milestone Jul 24, 2025
rust-timer added a commit that referenced this pull request Jul 24, 2025
Rollup merge of #144221 - usamoi:versym, r=bjorn3
generate elf symbol version in raw-dylib
For link names like `aaa@bbb`, it generates a symbol named `aaa` and a version named `bbb`.
For link names like `aaa\0bbb`, `aaa@`@bbb`` or `aa@bb@cc`, it emits errors.
It adds a test that the executable is linked with glibc using raw-dylib.
cc #135694
@bjorn3bjorn3 mentioned this pull request Jan 18, 2025
5 tasks
Kobzol pushed a commit to Kobzol/rustc_codegen_gcc that referenced this pull request Dec 21, 2025
Rollup of 15 pull requests
Successful merges:
- rust-lang/rust#143374 (Unquerify extern_mod_stmt_cnum.)
- rust-lang/rust#143838 (std: net: uefi: Add support to query connection data)
- rust-lang/rust#144014 (don't link to the nightly version of the Edition Guide in stable lints)
- rust-lang/rust#144094 (Ensure we codegen the main fn)
- rust-lang/rust#144218 (Use serde for target spec json deserialize)
- rust-lang/rust#144221 (generate elf symbol version in raw-dylib)
- rust-lang/rust#144240 (Add more test case to check if the false note related to sealed trait suppressed)
- rust-lang/rust#144247 (coretests/num: use ldexp instead of hard-coding a power of 2)
- rust-lang/rust#144276 (Use less HIR in check_private_in_public.)
- rust-lang/rust#144278 (add Rev::into_inner)
- rust-lang/rust#144317 (pass build.npm from bootstrap to tidy and use it for npm install)
- rust-lang/rust#144320 (rustdoc: avoid allocating a temp String for aliases in search index)
- rust-lang/rust#144334 (rustc_resolve: get rid of unused rustdoc::span_of_fragments_with_expansion)
- rust-lang/rust#144335 (Don't suggest assoc ty bound on non-angle-bracketed problematic assoc ty binding)
- rust-lang/rust#144358 (Stop using the old `validate_attr` logic for stability attributes)
r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@usamoi@rustbot@bjorn3@petrochenkov@bors@jieyouxu