Closed
Description
When compiling the default project generated with cargo generate --git https://github.com/Rahix/avr-hal-template.git
(following this tutorial), an LLVM error arises:
❯ cargo build
Compiling compiler_builtins v0.1.87
Compiling nb v1.1.0
Compiling ufmt-write v0.1.0
Compiling bare-metal v1.0.0
Compiling void v1.0.2
Compiling vcell v0.1.3
Compiling cfg-if v1.0.0
Compiling embedded-storage v0.2.0
Compiling cfg-if v0.1.10
Compiling panic-halt v0.2.0
Compiling ufmt v0.1.2
Compiling ufmt v0.2.0
Compiling avr-device v0.5.0
Compiling nb v0.1.3
Compiling embedded-hal v0.2.7
LLVM ERROR: Expected a constant shift amount!
error: could not compile `compiler_builtins` (lib)
warning: build failed, waiting for other jobs to finish...
I have tried searching for this error online and have found zero mentions of it, even outside the context of Rust.
The -vv
argument produces the following output (trimmed to only show relevant compilations):
Running `CARGO=/nix/store/q474abvwayiafhwiz2hgrlfhvp6h57qc-cargo-1.70.0-nightly-2023-03-27-x86_64-unknown-linux-gnu/bin/cargo CARGO_CRATE_NAME=compiler_builtins CARGO_MANIFEST_DIR=/home/campbell/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.87 CARGO_PKG_AUTHORS='Jorge Aparicio <[email protected]>' CARGO_PKG_DESCRIPTION='Compiler intrinsics used by the Rust compiler. Also available for other targets
if necessary'\!'
' CARGO_PKG_HOMEPAGE='https://github.com/rust-lang/compiler-builtins' CARGO_PKG_LICENSE=MIT/Apache-2.0 CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=compiler_builtins CARGO_PKG_README=README.md CARGO_PKG_REPOSITORY='https://github.com/rust-lang/compiler-builtins' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.1.87 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=87 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/home/campbell/Projects/rust_arduino/target/debug/deps:/nix/store/ghajjbbn54cqqzimj1a8nfvxdhnvfzpd-rust-default-1.70.0-nightly-2023-03-27/lib:/nix/store/ghajjbbn54cqqzimj1a8nfvxdhnvfzpd-rust-default-1.70.0-nightly-2023-03-27/lib:/nix/store/pmk0760lk096rlf7blv5kr82mjs30j37-avr-libc-avr-2.1.0/lib' OUT_DIR=/home/campbell/Projects/rust_arduino/target/avr-atmega328p/debug/build/compiler_builtins-ad07b3c75d4d1d35/out RUSTC_BOOTSTRAP=1 rustc --crate-name compiler_builtins /home/campbell/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.87/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=277 --crate-type lib --emit=dep-info,metadata,link -C opt-level=s -C panic=abort -C linker-plugin-lto -C debuginfo=2 -C debug-assertions=on --cfg 'feature="compiler-builtins"' --cfg 'feature="core"' --cfg 'feature="default"' --cfg 'feature="rustc-dep-of-std"' -C metadata=a2638f5606e6709a -C extra-filename=-a2638f5606e6709a --out-dir /home/campbell/Projects/rust_arduino/target/avr-atmega328p/debug/deps --target /home/campbell/Projects/rust_arduino/avr-specs/avr-atmega328p.json -Z force-unstable-if-unmarked -L dependency=/home/campbell/Projects/rust_arduino/target/avr-atmega328p/debug/deps -L dependency=/home/campbell/Projects/rust_arduino/target/debug/deps --extern core=/home/campbell/Projects/rust_arduino/target/avr-atmega328p/debug/deps/librustc_std_workspace_core-ec64718225ecdf57.rmeta --cap-lints warn --cfg 'feature="unstable"'`
...
LLVM ERROR: Expected a constant shift amount!
warning: `compiler_builtins` (lib) generated 2 warnings
error: could not compile `compiler_builtins` (lib); 2 warnings emitted
Caused by:
process didn't exit successfully: `CARGO=/nix/store/q474abvwayiafhwiz2hgrlfhvp6h57qc-cargo-1.70.0-nightly-2023-03-27-x86_64-unknown-linux-gnu/bin/cargo CARGO_CRATE_NAME=compiler_builtins CARGO_MANIFEST_DIR=/home/campbell/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.87 CARGO_PKG_AUTHORS='Jorge Aparicio <[email protected]>' CARGO_PKG_DESCRIPTION='Compiler intrinsics used by the Rust compiler. Also available for other targets
if necessary'\!'
' CARGO_PKG_HOMEPAGE='https://github.com/rust-lang/compiler-builtins' CARGO_PKG_LICENSE=MIT/Apache-2.0 CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=compiler_builtins CARGO_PKG_README=README.md CARGO_PKG_REPOSITORY='https://github.com/rust-lang/compiler-builtins' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.1.87 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=87 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/home/campbell/Projects/rust_arduino/target/debug/deps:/nix/store/ghajjbbn54cqqzimj1a8nfvxdhnvfzpd-rust-default-1.70.0-nightly-2023-03-27/lib:/nix/store/ghajjbbn54cqqzimj1a8nfvxdhnvfzpd-rust-default-1.70.0-nightly-2023-03-27/lib:/nix/store/pmk0760lk096rlf7blv5kr82mjs30j37-avr-libc-avr-2.1.0/lib' OUT_DIR=/home/campbell/Projects/rust_arduino/target/avr-atmega328p/debug/build/compiler_builtins-ad07b3c75d4d1d35/out RUSTC_BOOTSTRAP=1 rustc --crate-name compiler_builtins /home/campbell/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.87/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=277 --crate-type lib --emit=dep-info,metadata,link -C opt-level=s -C panic=abort -C linker-plugin-lto -C debuginfo=2 -C debug-assertions=on --cfg 'feature="compiler-builtins"' --cfg 'feature="core"' --cfg 'feature="default"' --cfg 'feature="rustc-dep-of-std"' -C metadata=a2638f5606e6709a -C extra-filename=-a2638f5606e6709a --out-dir /home/campbell/Projects/rust_arduino/target/avr-atmega328p/debug/deps --target /home/campbell/Projects/rust_arduino/avr-specs/avr-atmega328p.json -Z force-unstable-if-unmarked -L dependency=/home/campbell/Projects/rust_arduino/target/avr-atmega328p/debug/deps -L dependency=/home/campbell/Projects/rust_arduino/target/debug/deps --extern core=/home/campbell/Projects/rust_arduino/target/avr-atmega328p/debug/deps/librustc_std_workspace_core-ec64718225ecdf57.rmeta --cap-lints warn --cfg 'feature="unstable"'` (exit status: 101)
As you may have seen from the log files, I am using NixOS and I have a suspicion this is part of the problem. I have the appropriate toolchains installed, but I don't know if I've got them all:
nativeBuildInputs = (with pkgs; [
pkg-config
clang
rust-analyzer
avrdude
(callPackage ./pkgs/ravedude { })
cargo-generate
cargo-outdated
]) ++ (with pkgs.pkgsCross.avr; [
buildPackages.gcc
]);
buildInputs = (with pkgs; [
(rust-bin.nightly.latest.default.override {
extensions = [ "rust-src" ];
})
]) ++ (with pkgs.pkgsCross.avr; [
avrlibc
]);
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
Any pointers towards the cause of this issue would be greatly appreciated. Thank you for your time 😄
Metadata
Metadata
Assignees
Labels
No labels