dtolnay / proc-macro2

Apache License 2.0
739 stars 117 forks source link

Unsure if 100% the reason: Cargo Build issue for Arduino Uno (MCU= ATmega238p) #452

Closed HaroPo closed 6 months ago

HaroPo commented 6 months ago

Hi, I just started my (Embedded) Rust programming learning journey 2~3 days ago with the popular Arduino Uno MCU hardware platform...

I finally managed to get the usual "Hello World !" equivalent code called "Blink" to compile after a lot of problems (as described there: https://github.com/Rahix/avr-hal/issues/535 ) amongst which there was this recurring one:

~/Rust/projects/rust-arduino-uno-blink$ nano  Cargo.toml  ; cargo build 
   Compiling proc-macro2 v1.0.80
error[E0658]: use of unstable library feature 'proc_macro_byte_character'
   --> /home/hp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.80/src/wrapper.rs:875:21
    |
875 |                     proc_macro::Literal::byte_character(byte)
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #115268 <https://github.com/rust-lang/rust/issues/115268> for more information
    = help: add `#![feature(proc_macro_byte_character)]` to the crate attributes to enable
    = note: this compiler was built on 2024-03-21; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature 'proc_macro_c_str_literals'
   --> /home/hp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.80/src/wrapper.rs:902:21
    |
902 |                     proc_macro::Literal::c_string(string)
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #119750 <https://github.com/rust-lang/rust/issues/119750> for more information
    = help: add `#![feature(proc_macro_c_str_literals)]` to the crate attributes to enable
    = note: this compiler was built on 2024-03-21; consider upgrading it if it is out of date

For more information about this error, try `rustc --explain E0658`.
error: could not compile `proc-macro2` (lib) due to 2 previous errors

~/Rust/projects/rust-arduino-uno-blink$ rustup toolchain list
stable-x86_64-unknown-linux-gnu (default)
nightly-2021-01-07-x86_64-unknown-linux-gnu
nightly-2024-03-22-x86_64-unknown-linux-gnu (override)
nightly-x86_64-unknown-linux-gnu

~/Rust/projects/rust-arduino-uno-blink$ 

It seems (1) that the problem got solved by adding the following 2 lines

#![feature(proc_macro_byte_character)]
#![feature(proc_macro_c_str_literals)]

right after the huge commented section at the beginning of the src/lib.rs file (2), which seems coming from a Nighty version: /home/hp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.80/src/lib.rs (I use a LinuxMint 21 machine at the moment)

Well, I hope what I have done really makes sense and that this feedback may help, else, let me know, as I am learning with (mainly) ASM, C and PHP background... :wink:

Best regards, HP_

(1) I am not 100% sure :grimacing: since I tinkered a bit for a while around the main Cargo.toml file and sometimes more things were getting compiled before a new error appeared :sweat: But, a cargo clean ; cargo embed done lately seemed to say that things are working fine by now. (I need to free some disk space to set-up a VM and re-do everything from scratch, though...)

(2) What I believe to be the root file for a "library crate", am I wrong ?

dtolnay commented 6 months ago

This is a duplicate of https://github.com/dtolnay/proc-macro2/issues/451.

HaroPo commented 6 months ago

Hi, again,

I can confirm that the 2 extra lines of code do help as the "procmacro" -related errors resurfaced after removing them and running carg clean ; cargo embed_ right after.

Before that, I also ensured that other files I was "tinkering" with were set back to their original versions too.

Following are the details of the compilation results when failing and after modifying the lib.rs file as mentioned previously:

~/Rust/projects/rust-arduino-uno-blink$  cargo clean  ;  cargo embed

     Removed 328 files, 192.7MiB total
   Compiling compiler_builtins v0.1.108
   Compiling core v0.0.0 (/home/hp/.rustup/toolchains/nightly-2024-03-22-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
   Compiling proc-macro2 v1.0.80
   Compiling unicode-ident v1.0.12
   Compiling syn v1.0.109
   Compiling rustversion v1.0.15
   Compiling embedded-hal-bus v0.1.0
   Compiling paste v1.0.14
   Compiling avr-hal-generic v0.1.0 (https://github.com/rahix/avr-hal?rev=21342dcace7184f01fdc4e9703b01197bd4b4b4f#21342dca)
error: could not compile `proc-macro2` (lib) due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
error[E0658]: use of unstable library feature 'proc_macro_byte_character'
   --> /home/hp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.80/src/wrapper.rs:871:21
    |
871 |                     proc_macro::Literal::byte_character(byte)
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #115268 <https://github.com/rust-lang/rust/issues/115268> for more information
    = help: add `#![feature(proc_macro_byte_character)]` to the crate attributes to enable
    = note: this compiler was built on 2024-03-21; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature 'proc_macro_c_str_literals'
   --> /home/hp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.80/src/wrapper.rs:898:21
    |
898 |                     proc_macro::Literal::c_string(string)
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #119750 <https://github.com/rust-lang/rust/issues/119750> for more information
    = help: add `#![feature(proc_macro_c_str_literals)]` to the crate attributes to enable
    = note: this compiler was built on 2024-03-21; consider upgrading it if it is out of date

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.
       Error Failed to run cargo build: exit code = Some(101).

~/Rust/projects/rust-arduino-uno-blink$ 

Putting back these extra 2 lines in /home/hp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.80/src/lib.rs fixed the problem:

~/Rust/projects/rust-arduino-uno-blink$  cargo clean  ;  cargo embed

     Removed 128 files, 119.3MiB total
   Compiling compiler_builtins v0.1.108
   Compiling core v0.0.0 (/home/hp/.rustup/toolchains/nightly-2024-03-22-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
   Compiling proc-macro2 v1.0.80
   Compiling unicode-ident v1.0.12
   Compiling syn v1.0.109
   Compiling rustversion v1.0.15
   Compiling paste v1.0.14
   Compiling embedded-hal-bus v0.1.0
   Compiling avr-hal-generic v0.1.0 (https://github.com/rahix/avr-hal?rev=21342dcace7184f01fdc4e9703b01197bd4b4b4f#21342dca)
   Compiling quote v1.0.36
   Compiling avr-device-macros v0.5.4
   Compiling ufmt-macros v0.3.0
   Compiling rustc-std-workspace-core v1.99.0 (/home/hp/.rustup/toolchains/nightly-2024-03-22-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling nb v1.1.0
   Compiling void v1.0.2
   Compiling critical-section v1.1.2
   Compiling bare-metal v1.0.0
   Compiling embedded-hal v1.0.0
   Compiling vcell v0.1.3
   Compiling cfg-if v1.0.0
   Compiling ufmt-write v0.1.0
   Compiling embedded-storage v0.2.0
   Compiling cfg-if v0.1.10
   Compiling unwrap-infallible v0.1.5
   Compiling panic-halt v0.2.0
   Compiling ufmt v0.2.0
   Compiling avr-device v0.5.4
   Compiling nb v0.1.3
   Compiling embedded-hal v0.2.7
   Compiling atmega-hal v0.1.0 (https://github.com/rahix/avr-hal?rev=21342dcace7184f01fdc4e9703b01197bd4b4b4f#21342dca)
   Compiling arduino-hal v0.1.0 (https://github.com/rahix/avr-hal?rev=21342dcace7184f01fdc4e9703b01197bd4b4b4f#21342dca)
   Compiling rust-arduino-uno-blink v0.1.0 (/home/hp/Rust/projects/rust-arduino-uno-blink)
WARN rustc_codegen_ssa::back::link Linker does not support -no-pie command line option. Retrying without.
    Finished `dev` profile [optimized + debuginfo] target(s) in 10.27s
      Config default
      Target /home/hp/Rust/projects/rust-arduino-uno-blink/target/avr-atmega328p/debug/rust-arduino-uno-blink.elf
       Error No supported probe was found

~/Rust/projects/rust-arduino-uno-blink$ 

Best regards, HP_

HaroPo commented 6 months ago

https://github.com/dtolnay/proc-macro2/issues/452#issuecomment-2058772776

This is a duplicate of #451.

@dtolnay Thank you for the heads up ! :+1: