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

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

Closed
cr1901 opened this issue Apr 27, 2020 · 5 comments · Fixed by rust-lang/cargo#8177

Comments

@cr1901
Copy link

cr1901 commented Apr 27, 2020

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.

@ehuss
Copy link
Contributor

ehuss commented Apr 27, 2020

Thanks for the report! It looks like this is a bug in rustc's incremental support. We should be turning incremental off anyways (#44), I'll take a look into that.

@ehuss
Copy link
Contributor

ehuss commented Apr 27, 2020

Oh, and the incremental thing looks like a known issue:
rust-lang/rust#65023
rust-lang/rust#58633

bors added a commit to rust-lang/cargo that referenced this issue Apr 28, 2020
build-std: Don't treat std like a "local" package.

This changes it so that build-std will not treat the std crates like a "local" package. This has the following changes:

- std does not build with incremental. This generally shouldn't be needed, and incremental has various bugs with std crates.
- Cargo's dep-info fingerprint tracking will not track the std crate sources, these are tracked via other means.
- Cargo's `.d` dep-info file does not include std crate sources.
- Lints are capped to "allow" for std crates, and warnings are not shown by default.

Closes rust-lang/wg-cargo-std-aware#44
Closes rust-lang/wg-cargo-std-aware#55
@ehuss
Copy link
Contributor

ehuss commented Apr 28, 2020

Closed by rust-lang/cargo#8177.

@ehuss ehuss closed this as completed Apr 28, 2020
@cr1901
Copy link
Author

cr1901 commented Apr 28, 2020

Excellent, ty for your work! One question:

  • Lints are capped to "allow" for std crates, and warnings are not shown by default.

Not that I have immediate use for this, but is it possible to override this setting to see std warnings if I desire?

@ehuss
Copy link
Contributor

ehuss commented Apr 28, 2020

-vv lowers the lint cap to warning for all crates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants