From 576e09d471dfc82cd0aa8428a32b160fb30e87a6 Mon Sep 17 00:00:00 2001 From: Mr-Leshiy Date: Tue, 24 Oct 2023 12:44:59 +0300 Subject: [PATCH 1/2] fix aarch64-unknown-linux-gnu rustflags, updated rust Earthly targets --- earthly/rust/Earthfile | 68 ++++++++++++++++++++++++++++++++-------- earthly/rust/config.toml | 4 +-- 2 files changed, 57 insertions(+), 15 deletions(-) diff --git a/earthly/rust/Earthfile b/earthly/rust/Earthfile index ed1f0af7f..a53a3ec47 100644 --- a/earthly/rust/Earthfile +++ b/earthly/rust/Earthfile @@ -52,10 +52,21 @@ rustup: # Common Rust setup # Parameters: # * toolchain : The `rust-toolchain` toml file. +# * with_cargo_nextest: Flag to install cargo-nextest tool +# * with_cargo_chef: Flag to install cargo-chef tool +# * with_kani: Flag to install kani-verifier and kani tools +# * with_refinery: Flag to install refinery tool +# * with_cargo_machete: Flag to install cargo-machete tool RUST_SETUP: COMMAND ARG toolchain=./rust-toolchain.toml + ARG with_cargo_nextest=false + ARG with_cargo_chef=false + ARG with_kani=false + ARG with_refinery=false + ARG with_cargo_machete=false + # Poetry Installation directory. # Gives poetry and our poetry project a reliable location. WORKDIR /build @@ -73,18 +84,40 @@ RUST_SETUP: cargo +nightly --version # Install tools we use commonly with `cargo`. - RUN cargo install cargo-nextest --locked && \ - cargo install cargo-chef --locked && \ - cargo install kani-verifier --locked && \ - cargo kani setup && \ - cargo install refinery_cli --locked && \ - cargo install cargo-machete --locked + IF [ "$with_cargo_nextest" = "true" ] + RUN cargo install cargo-nextest --locked + END + IF [ "$with_cargo_chef" = "true" ] + RUN cargo install cargo-chef --locked + END + IF [ "$with_kani" = "true" ] + RUN cargo install kani-verifier --locked && \ + cargo kani setup + END + IF [ "$with_refinery" = "true" ] + RUN cargo install refinery_cli --locked + END + IF [ "$with_cargo_machete" = "true" ] + RUN cargo install cargo-machete --locked + END # Test rust build container check: FROM +rustup - DO +RUST_SETUP --toolchain=example/rust-toolchain.toml + ARG with_cargo_nextest=true + ARG with_cargo_chef=true + ARG with_kani=true + ARG with_refinery=true + ARG with_cargo_machete=true + + DO +RUST_SETUP \ + --toolchain=example/rust-toolchain.toml \ + --with_cargo_nextest="$with_cargo_nextest" \ + --with_cargo_chef="$with_cargo_chef" \ + --with_kani="$with_kani" \ + --with_refinery="$with_refinery" \ + --with_cargo_machete="$with_cargo_machete" # Check all the expected tooling is installed and works for both the stable and nightly versions. RUN rustc --version && \ @@ -93,11 +126,20 @@ check: cargo +nightly --version && \ cargo clippy --version && \ cargo +nightly clippy --version && \ - cargo nextest --version && \ - cargo chef --version && \ - cargo kani --version && \ refinery --version && \ mold --version - - - + IF [ "$with_cargo_nextest" = "true" ] + RUN cargo nextest --version + END + IF [ "$with_cargo_chef" = "true" ] + RUN cargo chef --version + END + IF [ "$with_kani" = "true" ] + RUN cargo kani --version + END + IF [ "$with_refinery" = "true" ] + RUN refinery --version + END + IF [ "$with_cargo_machete" = "true" ] + RUN cargo machete --version + END diff --git a/earthly/rust/config.toml b/earthly/rust/config.toml index bc0cacbd0..6d6820327 100644 --- a/earthly/rust/config.toml +++ b/earthly/rust/config.toml @@ -13,14 +13,14 @@ rustflags = [ linker = "clang" rustflags = [ "-C", "link-arg=-fuse-ld=/usr/bin/mold", - # "-C", "target-feature=+crt-static" - Doesn't work for nextest. + # "-C", "target-feature=+crt-static" - proc-macro doesn't work with it. `https://github.com/rust-lang/rust/issues/78210` ] [target.aarch64-unknown-linux-gnu] linker = "clang" rustflags = [ "-C", "link-arg=-fuse-ld=/usr/bin/mold", - "-C", "target-feature=+crt-static" + # "-C", "target-feature=+crt-static" - proc-macro doesn't work with it. `https://github.com/rust-lang/rust/issues/78210` ] [target.aarch64-unknown-linux-musl] From 7ade3c141ce30667e438ae070f7b0bee4d14d0c2 Mon Sep 17 00:00:00 2001 From: Mr-Leshiy Date: Tue, 24 Oct 2023 18:05:42 +0300 Subject: [PATCH 2/2] fix --- earthly/rust/Earthfile | 61 +++++------------------------------------- 1 file changed, 6 insertions(+), 55 deletions(-) diff --git a/earthly/rust/Earthfile b/earthly/rust/Earthfile index a53a3ec47..41ed39390 100644 --- a/earthly/rust/Earthfile +++ b/earthly/rust/Earthfile @@ -52,21 +52,10 @@ rustup: # Common Rust setup # Parameters: # * toolchain : The `rust-toolchain` toml file. -# * with_cargo_nextest: Flag to install cargo-nextest tool -# * with_cargo_chef: Flag to install cargo-chef tool -# * with_kani: Flag to install kani-verifier and kani tools -# * with_refinery: Flag to install refinery tool -# * with_cargo_machete: Flag to install cargo-machete tool RUST_SETUP: COMMAND ARG toolchain=./rust-toolchain.toml - ARG with_cargo_nextest=false - ARG with_cargo_chef=false - ARG with_kani=false - ARG with_refinery=false - ARG with_cargo_machete=false - # Poetry Installation directory. # Gives poetry and our poetry project a reliable location. WORKDIR /build @@ -84,40 +73,15 @@ RUST_SETUP: cargo +nightly --version # Install tools we use commonly with `cargo`. - IF [ "$with_cargo_nextest" = "true" ] - RUN cargo install cargo-nextest --locked - END - IF [ "$with_cargo_chef" = "true" ] - RUN cargo install cargo-chef --locked - END - IF [ "$with_kani" = "true" ] - RUN cargo install kani-verifier --locked && \ - cargo kani setup - END - IF [ "$with_refinery" = "true" ] - RUN cargo install refinery_cli --locked - END - IF [ "$with_cargo_machete" = "true" ] - RUN cargo install cargo-machete --locked - END + RUN cargo install cargo-nextest --locked && \ + cargo install refinery_cli --locked && \ + cargo install cargo-machete --locked # Test rust build container check: FROM +rustup - ARG with_cargo_nextest=true - ARG with_cargo_chef=true - ARG with_kani=true - ARG with_refinery=true - ARG with_cargo_machete=true - - DO +RUST_SETUP \ - --toolchain=example/rust-toolchain.toml \ - --with_cargo_nextest="$with_cargo_nextest" \ - --with_cargo_chef="$with_cargo_chef" \ - --with_kani="$with_kani" \ - --with_refinery="$with_refinery" \ - --with_cargo_machete="$with_cargo_machete" + DO +RUST_SETUP --toolchain=example/rust-toolchain.toml # Check all the expected tooling is installed and works for both the stable and nightly versions. RUN rustc --version && \ @@ -126,20 +90,7 @@ check: cargo +nightly --version && \ cargo clippy --version && \ cargo +nightly clippy --version && \ + cargo nextest --version && \ + cargo machete --version \ refinery --version && \ mold --version - IF [ "$with_cargo_nextest" = "true" ] - RUN cargo nextest --version - END - IF [ "$with_cargo_chef" = "true" ] - RUN cargo chef --version - END - IF [ "$with_kani" = "true" ] - RUN cargo kani --version - END - IF [ "$with_refinery" = "true" ] - RUN refinery --version - END - IF [ "$with_cargo_machete" = "true" ] - RUN cargo machete --version - END