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

"error: unused macro definition" when trying to compile libcore for msp430 target with recent nightly. #49617

Closed
cr1901 opened this issue Apr 3, 2018 · 3 comments

Comments

@cr1901
Copy link
Contributor

cr1901 commented Apr 3, 2018

I have a Rust application written using the msp430 backend. which means using the nightly compiler. Travis CI daily cron builds have been failing with the nightly compiler since March 27, 2018 with the following error (I am currently not in a position to get a backtrace/increase verbosity, I will update when possible):

xargo build --release --target=msp430-none-elf --features use-timer
   Compiling core v0.0.0 (file:///home/travis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore)
error: unused macro definition
   --> /home/travis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/iter/range.rs:491:1
    |
491 | / macro_rules! try_from_upper_bounded {
492 | |     ($($target:ty),*) => {$(
493 | |         impl PrivateTryFromUsize for $target {
494 | |             #[inline]
...   |
503 | |     )*}
504 | | }
    | |_^
    |
note: lint level defined here
   --> /home/travis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/lib.rs:66:9
    |
66  | #![deny(warnings)]
    |         ^^^^^^^^
    = note: #[deny(unused_macros)] implied by #[deny(warnings)]
error: aborting due to previous error
error: Could not compile `core`.
To learn more, run the command again with --verbose.
error: `"cargo" "build" "--release" "--manifest-path" "/tmp/xargo.LkQsXpHQxkQq/Cargo.toml" "--target" "msp430-none-elf" "-p" "core"` failed with exit code: Some(101)
note: run with `RUST_BACKTRACE=1` for a backtrace
make: *** [timer] Error 1

My msp430 firmware uses xargo to create a libcore for msp430 every time libcore is updated, and recently a new feature has triggered a lint that causes compilation to fail due to an unused macro. Since libcore can't be compiled, the whole build fails. A stopgap solution for now is to use a nightly before March 27, 2018 which compiles libcore for msp430 successfully.

cc: @SimonSapin, based on a chat in #rust-embedded with @japaric, PR #49305 might have tickled the lint into failing compilation for the msp430 backend?

@SimonSapin
Copy link
Contributor

This macro is conditionally used in code that depends on the target’s pointer width. I suspect that this error happens on any 16-bit platform. Adding #[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))] to the macro’s definition should fix it. Would you send a PR and ping me for review?

(As an aside, we should probably have CI on rust-lang/rust that libcore at least compiles for one 16-bit platform.)

pftbest pushed a commit to pftbest/rust that referenced this issue Apr 3, 2018
kennytm added a commit to kennytm/rust that referenced this issue Apr 3, 2018
Fix build error when compiling libcore for 16bit targets

Fixes rust-lang#49617

cc @SimonSapin
@cr1901
Copy link
Contributor Author

cr1901 commented Apr 3, 2018

@SimonSapin Looking at @pftbest 's fix I guess my q is: why don't 16 bit targets (msp430/avr) need this macro at all?

@SimonSapin
Copy link
Contributor

#49415 has some background on the removal of TryFrom conversions for some combinations of integer types. Here in src/libcore/iter/range.rs we have a private trait with a generic impl based on TryFrom and some concrete impls to "restore" missing conversions. The implementation of those concrete conversion depends on the size of usize: we either check that the source value isn’t too large for the target type, or check nothing at all because the target type covers all values of the source type. When usize is 16-bits, the minimum, only the latter kind of conversion is used.

kennytm added a commit to kennytm/rust that referenced this issue Apr 4, 2018
Fix build error when compiling libcore for 16bit targets

Fixes rust-lang#49617

cc @SimonSapin
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

No branches or pull requests

2 participants