Skip to content
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

many unexpected duplicates in --print native-static-libs output in some configurations #113209

Closed
cpu opened this issue Jun 30, 2023 · 6 comments · Fixed by #113626
Closed

many unexpected duplicates in --print native-static-libs output in some configurations #113209

cpu opened this issue Jun 30, 2023 · 6 comments · Fixed by #113626
Assignees
Labels
C-bug Category: This is a bug. P-medium Medium priority regression-untriaged Untriaged performance or correctness regression. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cpu
Copy link

cpu commented Jun 30, 2023

Hi there,

In rustls-ffi we use RUSTFLAGS="--print native-static-libs" cargo build to try and keep our crate's linking instructions up-to-date across supported platforms.

We've noticed that in some build configurations the output can change in surprising ways.

For instance, using rustc nightly (1.70.0) on Windows (x86_64-pc-windows-msvc) in a --debug configuration driven by cmake we see many consecutive duplicate libraries in the --print-native-static-libs output.

I understand duplicates are to be expected, and can be meaningful on some platforms, but seeing so many consecutive repeats seems unexpected and unlikely to be meaningful for the build process.

Is this perhaps a regression? Or are we making a mistake by relying on the stability of this output across versions/build configurations? This feature is documented as having a known prefix to "make it easier to fetch the output." leading to the idea that it is expected to be machine consumable.

Code

I tried this code:

RUSTFLAGS="--print native-static-libs" cargo build 

I expected to see this happen:

A list produced, with some duplicates (e.g. multiple kernel32.lib), but not many consecutive duplicates. E.g.:

advapi32.lib credui.lib kernel32.lib secur32.lib legacy_stdio_definitions.lib kernel32.lib advapi32.lib bcrypt.lib kernel32.lib ntdll.lib userenv.lib ws2_32.lib kernel32.lib ws2_32.lib kernel32.lib msvcrt.lib

Instead, this happened:

A list with many consecutive duplicates is produced:

advapi32.lib credui.lib kernel32.lib secur32.lib legacy_stdio_definitions.lib kernel32.lib advapi32.lib advapi32.lib bcrypt.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib kernel32.lib ntdll.lib ntdll.lib ntdll.lib ntdll.lib userenv.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib ws2_32.lib kernel32.lib ws2_32.lib kernel32.lib kernel32.lib msvcrt.lib

Version it worked on

rustc nightly (1.70.0) on Windows (x86_64-pc-windows-msvc) in a --release configuration.

Version with regression

rustc nightly (1.70.0) on Windows (x86_64-pc-windows-msvc) in a --debug configuration.

Extra links

Project: https://github.com/rustls/rustls-ffi
CMakeLists.txt: https://github.com/rustls/rustls-ffi/blob/2508f98ebb39be6103c78183e42ba94d70d9dd07/CMakeLists.txt
Build task: https://github.com/rustls/rustls-ffi/blob/2508f98ebb39be6103c78183e42ba94d70d9dd07/.github/workflows/test.yaml#L73-L93

@cpu cpu added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Jun 30, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 30, 2023
@ChrisDenton
Copy link
Member

Hm, I thought we usually removed consecutive duplicates but apparently only in release. A workaround would be to do so manually. For the msvc targets all duplicates can be removed so long as the order is preserved. This isn't true of many other targets though.

It would be much better to have a proper fix though.

@cpu
Copy link
Author

cpu commented Jun 30, 2023

Thanks for the quick reply :-)

Hm, I thought we usually removed consecutive duplicates but apparently only in release. A workaround would be to do so manually.

That's the approach we landed on for the short term 👍

For the msvc targets all duplicates can be removed so long as the order is preserved. This isn't true of many other targets though.

Great, thanks for clarifying.

@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jul 12, 2023
@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 12, 2023
@Urgau
Copy link
Member

Urgau commented Jul 12, 2023

@rustbot claim

@rustbot

This comment was marked as resolved.

@cpu
Copy link
Author

cpu commented Jul 16, 2023

Thanks @Urgau !

github-actions bot pushed a commit to rust-lang/miri that referenced this issue Jul 18, 2023
De-duplicate consecutive libs when printing native-static-libs

This PR adds a de-duplicate step just before printing the `native-static-libs`.

This step de-duplicates all the consecutive libs based only on the relevant comparison elements (this exclude spans, ast elements, ...).

Fixes rust-lang/rust#113209
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. P-medium Medium priority regression-untriaged Untriaged performance or correctness regression. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants