Skip to content

Conversation

usamoi
Copy link
Contributor

@usamoi usamoi commented Jul 20, 2025

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
Collaborator

rustbot commented Jul 20, 2025

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

@rustbot rustbot 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
Collaborator

rustbot commented Jul 20, 2025

This PR modifies run-make tests.

cc @jieyouxu

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

@bjorn3
Copy link
Member

bjorn3 commented Jul 21, 2025

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.

@petrochenkov
Copy link
Contributor

r? @bjorn3

@rustbot rustbot assigned bjorn3 and unassigned petrochenkov Jul 21, 2025
@bjorn3
Copy link
Member

bjorn3 commented Jul 21, 2025

cc @Noratrieb

@rustbot rustbot removed the A-run-make Area: port run-make Makefiles to rmake.rs label Jul 22, 2025
@bjorn3
Copy link
Member

bjorn3 commented Jul 22, 2025

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

@bjorn3
Copy link
Member

bjorn3 commented Jul 22, 2025

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

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 22, 2025

📌 Commit 3083d8f has been approved by bjorn3

It is now in the queue for this repository.

@bors bors 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
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label 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
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
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
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
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
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_COLOR RUSTC_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-

@bors bors 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
Copy link
Contributor Author

usamoi commented Jul 24, 2025

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

@rustbot ready

@rustbot rustbot 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
Member

bjorn3 commented Jul 24, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 24, 2025

📌 Commit e31876c has been approved by bjorn3

It is now in the queue for this repository.

@bors bors 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
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:master Jul 24, 2025
10 checks passed
@rustbot rustbot 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant 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