-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Compact display of static lib dependencies #43067
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Thanks for the PR @pornel! We'll check in now and again to make sure this gets reviewed soon. |
If you're going to do it in a way that can be copy pasted to the linker, then please make it adjust the syntax based on what the linker for the current target is. Trying to pass |
Which platforms actually need this message? I vaguely remember that MSVC tracks dependencies even for static libraries. Does it work with Rust too? If so, I'll just hide the whole message for MSVC. |
@pornel Rust does not currently emit the appropriate |
OK, I've added MSVC syntax. |
friendly ping @pnkfelix ! |
@pornel am I correct in inferring that this is only addressing the first of @ubsan's three points from #33173 ? The three points I will transcribe here for ease of reference:
Assuming the above inference is correct... Addressing point 2 may be more work than is warranted for this particular PR; I'd rather land a small PR that has an obvious benefit than wait a long time for the perfect one. Point 3 seems important. So that leads me to ask: Is there an easy way to change the output port so that it goes to stdout rather than stderr? On further review of the overall context here, it seems like there Anyway, I'm hesitant to just land this as is, even though it seems like an obvious improvement, given that there might be hacks in the wild that are relying on the old format... |
Yes, it's intended to address only the first point.
What can I do about this? |
@pornel wrote:
Oh sorry. I don't actually expect you to try to solve that problem (which strikes me as insolvable) that was more me thinking out loud about what to do here. I'm going to nominate this for discussion amongst the compiler team. Sorry for the hassle, and thanks for your patience @pornel! |
I would like to see @alexcrichton potentially chime in here, since it seems like he was helping coordinate efforts on #31471 and #31875 to some degree, and thus he might have a more informed opinion than I do about the right path here. |
Nominating for discussion at ... well, probably the dev-tools meeting is the most appropriate one for this. (And someone from that team should feel free to steal this bug from me.) (But I'm also tagging as T-compiler just in case that is the more appropriate team to handle this, or if you prefer, as a worst-case fallback if the dev-tools team does not get to to it before the next compiler triage meeting.) |
This was proposed in #40076 which I had concerns about leading to it being closed. |
We discussed this quite a bit in the dev tools meeting this week, but did not quite come to a conclusion. There was general agreement, that improvement here is a good thing, but also agreement that we should not break current users. We seemed to talk at cross-purposes somewhat, but here is my understanding about the constraints:
However I would be wrong if:
The alternative we discussed was:
IMO, this PR is a fine alternative to that proposal (I don't see that the alternative is more backwards compatible than the current PR), but I might be wrong. cc @michaelwoerister, @alexcrichton is my summary correct? Where do we differ in opinion? |
For back-compat the format could be hacked somewhat: library: foo -lbaz -lbar assuming current tools search for |
@nrc your summary sounds right to me, thanks for writing that up! I would just want to avoid a "halfway" situation where we change the output and then later change it again with a more "official" output. I figure that if we change it once we should just leave it for good. I'd personally have a goal here that there's some invocation you can use to have the compiler not emit anything by default, as a quiet compiler is typically synonymous with a happy compiler. |
OK, could the message be hidden when Cargo is doing the linking? i.e. show libraries when the static lib is a top-level project. Don't show libraries to link with when the static lib is built as a dependency. |
But the |
Ah, to clarify: I had in mind building static libs in If I have |
If |
⌛ Testing commit 2920658 with merge b5bc21651233404e6103ca5553fa8132e775e2ca... |
💔 Test failed - status-travis |
src/librustc_trans/back/link.rs
Outdated
against this static library. The order and any duplication \ | ||
can be significant on some platforms."); | ||
// Prefix for greppability | ||
sess.note_without_error(format!("native-static-libs: {}", &lib_args.join(" "))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing an &
before format!
.
[00:14:11] error[E0308]: mismatched types
[00:14:11] --> /checkout/src/librustc_trans/back/link.rs:702:33
[00:14:11] |
[00:14:11] 702 | sess.note_without_error(format!("native-static-libs: {}", &lib_args.join(" ")));
[00:14:11] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected &str, found struct `std::string::String`
[00:14:11] |
[00:14:11] = note: expected type `&str`
[00:14:11] found type `std::string::String`
[00:14:11] = help: try with `&format!("native-static-libs: {}", &lib_args.join(" "))`
[00:14:11] = note: this error originates in a macro outside of the current crate
[00:14:11]
[00:14:15] error: aborting due to previous error
[00:14:15]
[00:14:15] error: Could not compile `rustc_trans`.
@bors: r+ |
📌 Commit 2354089 has been approved by |
Compact display of static lib dependencies Fixes #33173 Instead of displaying one dependency per line, I've changed the format to display them all in one line. As a bonus they're in format of linker flags (`-lfoo`), so the output can be copy&pasted if one is actually going to link as suggested.
☀️ Test successful - status-appveyor, status-travis |
Should it be I guess it has been merged already. I tried today with |
BTW, I'm having doubts about this solution. I'm wondering whether printing a Perhaps this information should be written to a file in the same directory as the static library? This way users wouldn't have to parse rustc/cargo output, and the library could be used properly even by tools that didn't observe the compilation. I've started discussion topic here: https://internals.rust-lang.org/t/exposing-static-lib-dependencies/5925 |
@pornel I did have an issue on passing this flags to cargo (rust-lang/cargo#4510) |
@pornel Also, I still didn't manage to get this flag work. If I understand it correctly, the following compilation command should output bz2 right?
But there is nothing in the stdout. |
@mssun No, this doesn't just echo the flags. This specifies flags non-Rust build must use when you create a static library (i.e. it's for |
@pornel OK, I get it. Thank you so much. |
…lexcrichton Fix a typo in rustc help menu Change from native-static-deps to native-static-libs. Fix a typo introduced by this merged pull request: rust-lang#43067
Is there some way to hide these messages altogether? The note explicitly says "this list will not be printed by default", yet every time I compile it's printed ( Combine that with |
Second stage of rust-lang#43067
Remove deprecated message Follow up of rust-lang#43067
Fix failing build_ffi test under current nightly after rust-lang/rust#43067 landed.
Fixes #33173
Instead of displaying one dependency per line, I've changed the format to display them all in one line.
As a bonus they're in format of linker flags (
-lfoo
), so the output can be copy&pasted if one is actually going to link as suggested.