Skip to content

Persistent unused attribute warnings when recompiling libcore after linker flags are changed #55

Closed
rust-lang/cargo
#8177
@cr1901

Description

@cr1901

All references to -Clink-arg are in a .cargo/config file. I can't duplicate this behavior using cargo rustc on the command-line.

I have an msp430 project I'm testing with -Zbuild-std=core. The .cargo/config file normally looks like this:

rustflags = [
    "-C", "link-arg=-Tlink.x",
    "-C", "link-arg=-nostartfiles",
    "-C", "link-arg=-mcpu=msp430",
    "-C", "link-arg=-lmul_none",
    "-C", "link-arg=-lgcc",
]

[build]
target = "msp430-none-elf"

Therefore, my command line invocation always looks like cargo build -Zbuild-std=core, relying on cargo to infer the target.

When I build a debug binary with or without -Clink-arg=-lc after a cargo clean, the build works fine. However, if I do a subsequent build where I either add -Clink-arg=-lc if it was missing, or remove -Clink-arg=-lc if it was present, I get a large number of warnings I don't understand, referring to unused attributes:

warning: unused attribute
    --> C:\Users\William\.rustup\toolchains\nightly-x86_64-pc-windows-gnu\lib\rustlib\src\rust\src\libcore\num\mod.rs:4176:13
     |
4176 |               #[allow_internal_unstable(const_fn_union)]
     |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
4872 | /     uint_impl! { usize, u16, 16, 65535, "", "", 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48",
4873 | |     "[0x34, 0x12]", "[0x12, 0x34]",
4874 | |     usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
     | |______________________________________________________________________- in this macro invocation
     |
     = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

These warnings remain, no matter whether I include -Clink-arg=-lgcc or not, on subsequent builds until I do the next cargo clean. The warnings even occur when I switch between linking to memcpy and friends using libc to linking against rlibc instead (again, until the next cargo clean). This behavior does not happen during release builds.

Beside being noise in my console, these warnings may very well be harmless. But I would expect the warnings to not persist after every other recompilation of libcore no matter what linker flags I pass to cargo. This makes me think libcore builds using -Zbuild-std=core are not duplicable w/ the same exact flags between cargo invocations, depending on what linker args cargo has seen before.

I cannot duplicate this behavior in xargo. Possibly relevant: xargo always compiles libcore etc in release mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions