From e89e047c5af33ac47dabbcfdc12305d544a13ade Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 14 Oct 2022 15:45:37 +0200 Subject: [PATCH] Fix i386 build with custom toolchain (armv6 unknown state) --- default.nix | 5 ++++- nix/common.nix | 8 ++++---- nix/compile.nix | 48 ++++++++++++++++++++--------------------------- nix/toolchain.nix | 10 ++++++---- 4 files changed, 34 insertions(+), 37 deletions(-) diff --git a/default.nix b/default.nix index 170b1f2..efbc4c8 100644 --- a/default.nix +++ b/default.nix @@ -43,10 +43,13 @@ in { target = "x86_64-unknown-linux-musl"; features = [ "garage/bundled-libs" - "garage/sled" "garage/k2v" + "garage/sled" "garage/lmdb" "garage/sqlite" + "garage_db/sled" + "garage_db/lmdb" + "garage_db/sqlite" ]; }); }; diff --git a/nix/common.nix b/nix/common.nix index 031a75c..2b9cc75 100644 --- a/nix/common.nix +++ b/nix/common.nix @@ -8,12 +8,12 @@ rec { #sha256 = "1xy9zpypqfxs5gcq5dcla4bfkhxmh5nzn9dyqkr03lqycm9wg5cr"; # NixOS 22.05 - url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/22.05.zip"; - sha256 = "0d643wp3l77hv2pmg2fi7vyxn4rwy0iyr8djcw1h5x72315ck9ik"; + #url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/22.05.zip"; + #sha256 = "0d643wp3l77hv2pmg2fi7vyxn4rwy0iyr8djcw1h5x72315ck9ik"; # As of 2022-10-13 - #url = "https://github.com/NixOS/nixpkgs/archive/a3073c49bc0163fea6a121c276f526837672b555.zip"; - #sha256 = "1bz632psfbpmicyzjb8b4265y50shylccvfm6ry6mgnv5hvz324s"; + url = "https://github.com/NixOS/nixpkgs/archive/a3073c49bc0163fea6a121c276f526837672b555.zip"; + sha256 = "1bz632psfbpmicyzjb8b4265y50shylccvfm6ry6mgnv5hvz324s"; }; cargo2nixSrc = fetchGit { # As of 2022-10-14: (TODO) diff --git a/nix/compile.nix b/nix/compile.nix index 62eb956..9406bb4 100644 --- a/nix/compile.nix +++ b/nix/compile.nix @@ -13,9 +13,10 @@ let log = v: builtins.trace v v; pkgs = import pkgsSrc { - inherit system; + inherit system; crossSystem = { config = target; + isStatic = true; }; overlays = [ cargo2nixOverlay ]; }; @@ -30,26 +31,22 @@ let we emulate the structure of the Rust object created by rustOverlay. In practise, rustOverlay ships rustc+cargo in a single derivation while NixOS ships them in separate ones. We reunite them with symlinkJoin. - */ - /* - rustToolchain = { - rustc = pkgs.symlinkJoin { - name = "rust-channel"; - paths = [ - pkgs.rustPlatform.rust.cargo - pkgs.rustPlatform.rust.rustc - ]; - }; - clippy = pkgs.symlinkJoin { - name = "clippy-channel"; - paths = [ - pkgs.rustPlatform.rust.cargo - pkgs.rustPlatform.rust.rustc - pkgs.clippy - ]; - }; - }.${compiler}; */ + toolchainOptions = + if target == "x86_64-unknown-linux-musl" || target == "aarch64-unknown-linux-musl" then { + rustVersion = "1.63.0"; + extraRustComponents = [ "clippy" ]; + } else { + rustToolchain = pkgs.symlinkJoin { + name = "rust-static-toolchain-${target}"; + paths = [ + pkgs.rustPlatform.rust.cargo + pkgs.rustPlatform.rust.rustc + # clippy not needed, it only runs on amd64 + ]; + }; + }; + buildEnv = (drv: { rustc = drv.setBuildEnv; @@ -57,7 +54,7 @@ let ${drv.setBuildEnv or "" } echo echo --- BUILDING WITH CLIPPY --- - echo + echo export NIX_RUST_BUILD_FLAGS="''${NIX_RUST_BUILD_FLAGS} --deny warnings" export RUSTC="''${CLIPPY_DRIVER}" @@ -215,12 +212,7 @@ let else target; in - pkgs.rustBuilder.makePackageSet { + pkgs.rustBuilder.makePackageSet ({ inherit release packageFun packageOverrides codegenOpts rootFeatures; - - #inherit rustToolchain; - rustVersion = "1.63.0"; - target = rustTarget; - extraRustComponents = [ "clippy" ]; - } + } // toolchainOptions) diff --git a/nix/toolchain.nix b/nix/toolchain.nix index d6fe295..079fcf1 100644 --- a/nix/toolchain.nix +++ b/nix/toolchain.nix @@ -6,14 +6,17 @@ with import ./common.nix; let platforms = [ - "x86_64-unknown-linux-musl" + #"x86_64-unknown-linux-musl" "i686-unknown-linux-musl" - "aarch64-unknown-linux-musl" + #"aarch64-unknown-linux-musl" "armv6l-unknown-linux-musleabihf" ]; pkgsList = builtins.map (target: import pkgsSrc { inherit system; - crossSystem = { config = target; }; + crossSystem = { + config = target; + isStatic = true; + }; overlays = [ cargo2nixOverlay ]; }) platforms; pkgsHost = import pkgsSrc {}; @@ -25,7 +28,6 @@ in lib.flatten (builtins.map (pkgs: [ pkgs.rustPlatform.rust.rustc pkgs.rustPlatform.rust.cargo - pkgs.clippy pkgs.buildPackages.stdenv.cc ]) pkgsList) ++ [ kaniko