rust-esp-nix icon indicating copy to clipboard operation
rust-esp-nix copied to clipboard

Not working anymore, easy fix

Open mauriciojost opened this issue 4 years ago • 0 comments

Hi @sdobz

First of all thanks for such contribution. You're solving in a beautiful manner the build of all this mess. Thanks!

The build finished correctly, and I managed to enter the nix environment without any issue (after a couple of hours).

However when building the project (sdobz/esp32-hello) there is a failure:

[nix-shell:~/persospace/rust-esp-nix/esp32-hello]$ ./all.sh /dev/ttyUSB0
Toolchain path: /nix/store/fsw629zbkgzxbyv54gfml8fxwjqs8xmw-esp32-toolchain/tools/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Toolchain version: esp32-2019r1
Compiler version: 8.2.0
Python requirements from /home/mjost/persospace/rust-esp-nix/esp32-hello/esp-idf/requirements.txt are satisfied.
App "hello-world" version: 643b3b1-dirty
App built. Default flash app command is:
python /home/mjost/persospace/rust-esp-nix/esp32-hello/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 115200 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x10000 /home/mjost/persospace/rust-esp-nix/esp32-hello/build/hello-world.bin
    Updating crates.io index
   Compiling compiler_builtins v0.1.43
   Compiling core v0.0.0 (/nix/store/5qr9mk1pf2rcpdr5y4r715s30di12rib-source/src/libcore)
   Compiling rustc-std-workspace-core v1.99.0 (/nix/store/5qr9mk1pf2rcpdr5y4r715s30di12rib-source/src/tools/rustc-std-workspace-core)
error[E0658]: `loop` is not allowed in a `const`
   --> /home/mjost/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.43/src/int/mod.rs:107:13
    |
107 | /             loop {
108 | |                 if l >= ((bits / 2) as u8) {
109 | |                     break;
110 | |                 }
...   |
116 | |                 l *= 2;
117 | |             }
    | |_____________^
...
251 |   int_impl!(isize, usize);
    |   ------------------------ in this macro invocation
    |
    = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
    = help: add `#![feature(const_loop)]` to the crate attributes to enable
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0658]: `if` is not allowed in a `const`
   --> /home/mjost/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.43/src/int/mod.rs:108:17
    |
108 | /                 if l >= ((bits / 2) as u8) {
109 | |                     break;
110 | |                 }
    | |_________________^
...
251 |   int_impl!(isize, usize);
    |   ------------------------ in this macro invocation
    |
    = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
    = help: add `#![feature(const_if_match)]` to the crate attributes to enable
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0658]: `if` is not allowed in a `const`
   --> /home/mjost/.cargo/registry/src/github.com-1ecc6
...

@mebubo figured out why. As per what I understand the version used of compiler_builtins is not the same as the one you used when you wrote this project. The version resolved is now different. This has to do with the fact that the project xbuild generates a Cargo.toml which depends on the version 0.1.0 of compiler_builtins, which means any patch 0.1.x (to avoid this it should use =0.1.0 instead of 0.1.0). While performing the (x)build cargo takes the latest patch available for such dependency, going to 0.1.43 (!!!), which breaks the compilation as shown above . As per semver, until you have a major=1 it seems to be legal to make breaking changes without bumps in major (https://semver.org/#spec-item-4), so I think xbuild project should for now pin a fixed version, even at patch number.

This build worked: https://github.com/mauriciojost/rust-esp-nix/tree/mjost (is a fork of your project with the above suggested changes).

How do you think this could be solved?

mauriciojost avatar May 29 '21 16:05 mauriciojost