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

cannot compile blink #171

Open
jdrouet opened this issue Jun 26, 2020 · 1 comment
Open

cannot compile blink #171

jdrouet opened this issue Jun 26, 2020 · 1 comment

Comments

@jdrouet
Copy link

jdrouet commented Jun 26, 2020

Hi!

I've been trying to install the avr-rust toolchain to build the blink project, and because I try to keep the things reproducible, I'm doing it in a Docker image.

FROM alpine AS cache

RUN apk add --no-cache git curl

RUN curl -o /rust-std-beta-x86_64-unknown-linux-gnu.tar.gz https://static.rust-lang.org/dist/2019-05-23/rust-std-beta-x86_64-unknown-linux-gnu.tar.gz
RUN curl -o /rustc-beta-x86_64-unknown-linux-gnu.tar.gz https://static.rust-lang.org/dist/2019-05-23/rustc-beta-x86_64-unknown-linux-gnu.tar.gz
RUN curl -o /cargo-beta-x86_64-unknown-linux-gnu.tar.gz https://static.rust-lang.org/dist/2019-05-23/cargo-beta-x86_64-unknown-linux-gnu.tar.gz

RUN git clone https://github.com/avr-rust/rust.git --recursive /avr-rust \
  && rm -rf /avr-rust/.git

FROM rust:1-slim-stretch

RUN apt-get update \
    && apt-get install -y build-essential cmake curl python \
    && rm -rf /var/lib/apt/lists/*

ENV AVR_RUST_SRC_PATH /work/avr-rust
ENV AVR_RUST_BUILD_PATH /work/avr-rust-build

COPY --from=cache /avr-rust $AVR_RUST_SRC_PATH

WORKDIR $AVR_RUST_BUILD_PATH

# Generate Makefile using settings suitable for an experimental compiler
RUN $AVR_RUST_SRC_PATH/configure \
  --enable-debug \
  --disable-docs \
  --enable-llvm-assertions \
  --enable-debug-assertions \
  --enable-optimize \
  --enable-llvm-release-debuginfo \
  --experimental-targets=AVR \
  --prefix=/opt/avr-rust

COPY --from=cache /rust-std-beta-x86_64-unknown-linux-gnu.tar.gz $AVR_RUST_BUILD_PATH/build/cache/2019-05-23/rust-std-beta-x86_64-unknown-linux-gnu.tar.gz
COPY --from=cache /rustc-beta-x86_64-unknown-linux-gnu.tar.gz $AVR_RUST_BUILD_PATH/build/cache/2019-05-23/rustc-beta-x86_64-unknown-linux-gnu.tar.gz
COPY --from=cache /cargo-beta-x86_64-unknown-linux-gnu.tar.gz $AVR_RUST_BUILD_PATH/build/cache/2019-05-23/cargo-beta-x86_64-unknown-linux-gnu.tar.gz

# Build the compiler, optionally install it to /opt/avr-rust
RUN make
RUN mkdir -p /opt/avr-rust && make install

# Register the toolchain with rustup
RUN rustup toolchain link avr-toolchain $(realpath $(find . -name 'stage2'))

# Optionally enable the avr toolchain globally
# RUN rustup default avr-toolchain

RUN cargo install xargo

RUN cp $(find /usr/local/rustup/toolchains -name cargo | grep bin | head -n 1)* /usr/local/rustup/toolchains/avr-toolchain/bin/

It's mostly copy-pasting your documentation, but when I run docker run -e RUST_TARGET_PATH=/code -e XARGO_RUST_SRC=/work/avr-rust/src -v /path/to/blink:/code -w /code avr-rust rustup run avr-toolchain xargo build --target avr-atmega328p --release I get the following error

warning: Patch `rustc-std-workspace-alloc v1.0.0 (/work/avr-rust/src/tools/rustc-std-workspace-alloc)` was not used in the crate graph.
Patch `rustc-std-workspace-core v1.0.0 (/work/avr-rust/src/tools/rustc-std-workspace-core)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
   Compiling core v0.0.0 (/work/avr-rust/src/libcore)
error: Unrecognized option: 'json'

error: could not compile `core`.

To learn more, run the command again with --verbose.
error: `"cargo" "build" "--release" "--manifest-path" "/tmp/xargo.GHevOdzy8xrC/Cargo.toml" "--target" "avr-atmega328p" "-p" "core"` failed with exit code: Some(101)
note: run with `RUST_BACKTRACE=1` for a backtrace
make: *** [Makefile:7: build] Error 1

I've tried to look around for a solution and nothing came up, except an incompatibility of some components...
Do you guys have a way to fix that?

@Rahix
Copy link

Rahix commented Jun 30, 2020

You'll need matching versions of xargo and cargo. To be specific, these versions work(ed) for me:

bash-5.0$ rustc --version
rustc 1.37.0-dev
bash-5.0$ cargo --version
cargo 1.37.0
bash-5.0$ xargo --version
xargo 0.3.17 (fd55d412234a 2019-11-08)
cargo 1.37.0

You can find more discussion around this in avr-rust/blink#15.

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