Skip to content

Fix short linker error output #143482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Fix short linker error output #143482

wants to merge 3 commits into from

Conversation

ia0
Copy link
Contributor

@ia0 ia0 commented Jul 5, 2025

This PR does 2 things:

Running cargo +stage1 build on the following program:

unsafe extern "C" {
    fn foo() -> libc::c_int;
}

fn main() {
    let x = unsafe { foo() } as u32;
    // println!("{}", data_encoding::BASE64.encode(&x.to_le_bytes()));
}

Gives the following diff before and after the PR:

-/tmp/foo/target/debug/deps/{liblibc-faf416f178830595.rlib}.rlib
+/tmp/foo/target/debug/deps/liblibc-faf416f178830595.rlib

Running on the same program with the additional dependency, we get the following diff:

-/tmp/foo/target/debug/deps/{liblibc-faf416f178830595.rlib,libdata_encoding-84bb5aadfa9e8839.rlib}.rlib
+/tmp/foo/target/debug/deps/{liblibc-faf416f178830595,libdata_encoding-84bb5aadfa9e8839}.rlib

This PR does 2 things:

- It removes the braces when there's a single element. This is required since brace expansion (at
  least in bash and zsh) only triggers if there's at least 2 elements.

- It removes the extra `.rlib` suffixes of the elements. See
  rust-lang#135707 (comment) for context.

Running `cargo +stage1 build` on the following program:

```rust
unsafe extern "C" {
    fn foo() -> libc::c_int;
}

fn main() {
    let x = unsafe { foo() } as u32;
    // println!("{}", data_encoding::BASE64.encode(&x.to_le_bytes()));
}
```

Gives the following diff before and after the PR:

```diff
-/tmp/foo/target/debug/deps/{liblibc-faf416f178830595.rlib}.rlib
+/tmp/foo/target/debug/deps/liblibc-faf416f178830595.rlib
```

Running on the same program with the additional dependency, we get the following diff:

```diff
-/tmp/foo/target/debug/deps/{liblibc-faf416f178830595.rlib,libdata_encoding-84bb5aadfa9e8839.rlib}.rlib
+/tmp/foo/target/debug/deps/{liblibc-faf416f178830595,libdata_encoding-84bb5aadfa9e8839}.rlib
```

Do we want to add a UI test?
@rustbot
Copy link
Collaborator

rustbot commented Jul 5, 2025

r? @fee1-dead

rustbot has assigned @fee1-dead.
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 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 5, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 5, 2025

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

@fee1-dead
Copy link
Member

Do we want to add a UI test?

We should definitely test this, but with a run-make test, probably something like the one in #135707

@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Jul 6, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 6, 2025

This PR modifies run-make tests.

cc @jieyouxu

@ia0
Copy link
Contributor Author

ia0 commented Jul 6, 2025

We should definitely test this, but with a run-make test, probably something like the one in #135707

Thanks for the link! I don't know how I missed that. I've updated the test.

Copy link
Member

@fee1-dead fee1-dead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me after nit

@rustbot rustbot 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-review Status: Awaiting review from the assignee but also interested parties. labels Jul 7, 2025
@fee1-dead
Copy link
Member

@bors delegate+

@bors
Copy link
Collaborator

bors commented Jul 7, 2025

✌️ @ia0, you can now approve this pull request!

If @fee1-dead told you to "r=me" after making some further change, please make that change, then do @bors r=@fee1-dead

@ia0
Copy link
Contributor Author

ia0 commented Jul 7, 2025

@bors r=@fee1-dead

@bors
Copy link
Collaborator

bors commented Jul 7, 2025

📌 Commit cdbdd8a has been approved by fee1-dead

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 7, 2025
@fee1-dead
Copy link
Member

@bors rollup

jieyouxu added a commit to jieyouxu/rust that referenced this pull request Jul 7, 2025
Fix short linker error output

This PR does 2 things:

- It removes the braces when there's a single element. This is required since brace expansion (at least in bash and zsh) only triggers if there's at least 2 elements.

- It removes the extra `.rlib` suffixes of the elements. See rust-lang#135707 (comment) for context.

Running `cargo +stage1 build` on the following program:

```rust
unsafe extern "C" {
    fn foo() -> libc::c_int;
}

fn main() {
    let x = unsafe { foo() } as u32;
    // println!("{}", data_encoding::BASE64.encode(&x.to_le_bytes()));
}
```

Gives the following diff before and after the PR:

```diff
-/tmp/foo/target/debug/deps/{liblibc-faf416f178830595.rlib}.rlib
+/tmp/foo/target/debug/deps/liblibc-faf416f178830595.rlib
```

Running on the same program with the additional dependency, we get the following diff:

```diff
-/tmp/foo/target/debug/deps/{liblibc-faf416f178830595.rlib,libdata_encoding-84bb5aadfa9e8839.rlib}.rlib
+/tmp/foo/target/debug/deps/{liblibc-faf416f178830595,libdata_encoding-84bb5aadfa9e8839}.rlib
```
bors added a commit that referenced this pull request Jul 7, 2025
Rollup of 11 pull requests

Successful merges:

 - #143130 (doc(std): clarify `NonZero<T>` usage limitation in doc comment)
 - #143415 (Get rid of build-powerpc64le-toolchain.sh)
 - #143464 (Make tests/ui/abi/debug.rs cross-compile)
 - #143482 (Fix short linker error output)
 - #143524 (Move `stable_mir` back to its own crate)
 - #143528 (interpret: rename StackPopCleanup)
 - #143551 (Dont resolve instance of root in `mir_callgraph_cyclic`)
 - #143558 (mbe: Refactors and function extractions in `compile_declarative_macro`)
 - #143563 (std: fix typo in `std::path`)
 - #143564 (compiler: Deduplicate `must_emit_unwind_tables()` comments)
 - #143577 (Disable download-rustc for library profile)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs 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.

4 participants