Skip to content

run-pass/lib-defaults.rs warns of redundant linker flag #54222

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

Closed
pnkfelix opened this issue Sep 14, 2018 · 5 comments · Fixed by #140681
Closed

run-pass/lib-defaults.rs warns of redundant linker flag #54222

pnkfelix opened this issue Sep 14, 2018 · 5 comments · Fixed by #140681
Labels
A-linkage Area: linking into static, shared libraries and binaries A-testsuite Area: The testsuite used to check the correctness of rustc C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@pnkfelix
Copy link
Member

This test:

// compile-flags: -lrust_test_helpers
#[link(name = "rust_test_helpers", kind = "static")]
extern "C" {
pub fn rust_dbg_extern_identity_u32(x: u32) -> u32;
}

is causing the following compile-time output to stderr (on Linux; not sure about other hosts):

warning: redundant linker flag specified for library `rust_test_helpers`

This is the command line that compiletest is constructing:

command: "/home/pnkfelix/Dev/Mozilla/issue53764/rust-53764/objdir-dbgopt/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" "/home/pnkfelix/Dev/Mozilla/issue53764/rust-53764/src/test/run-pass/lib-defaults.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/home/pnkfelix/Dev/Mozilla/issue53764/rust-53764/objdir-dbgopt/build/x86_64-unknown-linux-gnu/test/run-pass/lib-defaults/a" "-Crpath" "-Zunstable-options" "-Lnative=/home/pnkfelix/Dev/Mozilla/issue53764/rust-53764/objdir-dbgopt/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-lrust_test_helpers" "-L" "/home/pnkfelix/Dev/Mozilla/issue53764/rust-53764/objdir-dbgopt/build/x86_64-unknown-linux-gnu/test/run-pass/lib-defaults/auxiliary"

I haven't delved deeply into what our requirements are for linkage directives. I'm guessing that rustc is able to construct the desired -lrust_test_helpers from the presence of the #[link(name = "rust_test_helpers", kind = "static")], but it might be good to know if that is the case on all of our platforms?

(I.e. maybe we should strive to remove the // compile-flags: -lrust_test_helpers directive from this test, or if that fails, maybe it conditional on which platform we are testing on...)

In any case I am mainly filling this ticket so I have something to link to in the test when I explain why I'm ignoring the stderr output from the compiler in this case.

@pnkfelix
Copy link
Member Author

pnkfelix commented Sep 14, 2018

(the same output is issued for Mac OS X, which leads me to wonder if it is also issued on Windows? If that is the case, then I'd be inclined to add a .stderr file for this test rather than use // dont-check-compiler-stderr)

@pnkfelix pnkfelix changed the title src/test/run-pass/lib-defaults.rs issues a warning from (at least on Linux) src/test/run-pass/lib-defaults.rs issues a redundant linker flag warning Sep 14, 2018
@pnkfelix pnkfelix changed the title src/test/run-pass/lib-defaults.rs issues a redundant linker flag warning src/test/run-pass/lib-defaults.rs warns of redundant linker flag Sep 14, 2018
@pnkfelix pnkfelix changed the title src/test/run-pass/lib-defaults.rs warns of redundant linker flag run-pass/lib-defaults.rs warns of redundant linker flag Sep 14, 2018
@pnkfelix pnkfelix added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-testsuite Area: The testsuite used to check the correctness of rustc labels Sep 14, 2018
@pnkfelix pnkfelix changed the title run-pass/lib-defaults.rs warns of redundant linker flag src/test/run-pass/lib-defaults.rs issues a warning Sep 17, 2018
@pnkfelix
Copy link
Member Author

I've confirmed that I've seen the warning issued on both Linux and OS X.

@pnkfelix pnkfelix changed the title src/test/run-pass/lib-defaults.rs issues a warning run-pass/lib-defaults.rs warns of redundant linker flag Sep 17, 2018
pnkfelix added a commit to pnkfelix/rust that referenced this issue Sep 21, 2018
@pnkfelix pnkfelix added the A-linkage Area: linking into static, shared libraries and binaries label Sep 22, 2018
@Enselic Enselic added C-bug Category: This is a bug. C-enhancement Category: An issue proposing an enhancement or a PR with one. and removed C-bug Category: This is a bug. labels Oct 15, 2023
@jieyouxu

This comment has been minimized.

@jieyouxu jieyouxu closed this as completed May 5, 2025
@jieyouxu

This comment has been minimized.

@jieyouxu
Copy link
Member

jieyouxu commented May 6, 2025

Triage: going to try remove this ignore, and see if anyone still reports observing this locally now.

@bors bors closed this as completed in 9d05497 May 6, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 6, 2025
Rollup merge of rust-lang#140681 - jieyouxu:test_helpers, r=petrochenkov

Don't ignore compiler stderr in `lib-defaults.rs`

Closes rust-lang#54222.

- Don't ignore compiler stderr.
- Document test intent.
- Move under `tests/ui/link-native-libs/` instead.

This was previously discussed on https://web.archive.org/web/20181028094402/https://botbot.me/mozilla/rust-tools/2017-02-21/?page=1.

try-job: armhf-gnu
try-job: test-various
try-job: x86_64-msvc-1
try-job: i686-msvc-1
try-job: x86_64-mingw-1
try-job: aarch64-apple
try-job: x86_64-apple-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries A-testsuite Area: The testsuite used to check the correctness of rustc C-enhancement Category: An issue proposing an enhancement or a PR with one. 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.

3 participants