toltec-dev / toolchain

Set of Docker images for cross-compiling binaries targeting the reMarkable tablet.
MIT License
34 stars 12 forks source link

How am I using the Rust image wrong? :) #2

Closed fenollp closed 3 years ago

fenollp commented 3 years ago

Hi, here's how I'm trying to use your Rust toolchain:

docker volume inspect cargo-reg >/dev/null 2>&1 || docker volume create cargo-reg
docker run --rm -t \
    -v cargo-reg:/root/.cargo/registry \
    -v "$PWD":/app:rw -w /app \
    ghcr.io/toltec-dev/rust \
    cargo build --release --bin whiteboard --target=armv7-unknown-linux-gnueabihf #--locked #--frozen #--offline

Which is not too far removed from libremarkable.rs's, however there are 2 issues:

  1. it fails, complaining about missing rustfmt even though I am not calling cargo fmt
  2. it always updates the cargo index
    Updating git repository `https://github.com/canselcik/libremarkable`
    Updating git submodule `git://github.com/ricardoquesada/libfreetype`
   Compiling marauder v0.2.0 (/app)
error: failed to run custom build command for `marauder v0.2.0 (/app)`

Caused by:
  process didn't exit successfully: `/app/target/release/build/marauder-7a842b7208b66163/build-script-build` (exit code: 1)
  --- stderr
  error: 'rustfmt' is not installed for the toolchain 'nightly-x86_64-unknown-linux-gnu'
  To install, run `rustup component add rustfmt --toolchain nightly-x86_64-unknown-linux-gnu`

What should I be doing differently? Thanks

matteodelabre commented 3 years ago

Hi @fenollp, and sorry for the delay. Is the source of your project available somewhere to test? Do you have a custom .cargo/config in your repository? There is already a config file in the Rust image at /root/.cargo/config containing the required configuration for building with the cross-compiler.

1. it fails, complaining about missing `rustfmt` even though I am not calling `cargo fmt`

Are you sure it’s not called by a dependency? Again, hard to tell without seeing your source.

2. it always updates the cargo index

Why shouldn’t it?

fenollp commented 3 years ago
  1. You're right it's probably a transitive dependency
  2. I meant that there is a network call to fetch the crate index every time I build

I have found my app can build fine with cross build --target=armv7-unknown-linux-gnueabihf so I'm no longer pursuing this route. I did add https://github.com/toltec-dev/toolchain/blob/cb0b263d908c1fc80ec8d0fc03c2b8f020d58c95/rust/config to my project's .cargo/config so many thanks for that :)

You can find my app at https://github.com/fenollp/reMarkable-tools

I'm ok with closing this if you'd like.

matteodelabre commented 3 years ago

You’re welcome. I’m glad you found a working way to build your app!