Skip to content

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

Description

@pnkfelix

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesA-testsuiteArea: The testsuite used to check the correctness of rustcC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions