cross compilation seems to work
Some checks failed
ci/woodpecker/push/debug Pipeline failed

This commit is contained in:
Alex 2025-02-01 23:22:13 +01:00
parent 1127239215
commit e819e1a631
2 changed files with 43 additions and 14 deletions

View file

@ -1,3 +1,3 @@
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=mold"]
#[target.x86_64-unknown-linux-gnu]
#linker = "clang"
#rustflags = ["-C", "link-arg=-fuse-ld=mold"]

View file

@ -15,18 +15,34 @@
let
log = v: builtins.trace v v;
pkgs =
targetEnvMap = {
"armv6l-unknown-linux-musleabihf" = "ARMV6L_UNKNOWN_LINUX_MUSLEABIHF";
"aarch64-unknown-linux-musl" = "AARCH64_UNKNOWN_LINUX_MUSL";
"i686-unknown-linux-musl" = "I686_UNKNOWN_LINUX_MUSL";
"x86_64-unknown-linux-musl" = "X86_64_UNKNOWN_LINUX_MUSL";
};
pkgs = if target != null then
import nixpkgs {
inherit system;
crossSystem = {
config = target;
isStatic = true;
};
overlays = [ (import rust-overlay) ];
}
else
import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
inherit (pkgs) lib;
inherit (pkgs) lib stdenv;
toolchain = pkgs.symlinkJoin {
toolchain = (p: p.symlinkJoin {
name = "garage-rust-toolchain-1.78";
paths = [
(pkgs.rust-bin.stable."1.78.0".default.override {
(p.rust-bin.stable."1.78.0".default.override {
targets = [
"arm-unknown-linux-musleabihf"
"aarch64-unknown-linux-musl"
@ -38,11 +54,12 @@ let
"rustfmt"
];
})
pkgs.clang
pkgs.mold
pkgs.protobuf
p.protobuf
] ++ lib.optionals (target == null) [
# p.clang
# p.mold
];
};
});
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
@ -100,7 +117,7 @@ let
target;
codegenOpts = if target != null then codegenOptsMap.${target} else [
"link-args=-fuse-ld=mold"
# "link-args=-fuse-ld=mold"
];
commonArgs =
@ -112,6 +129,11 @@ let
strictDeps = true;
cargoExtraArgs = "--features ${featuresStr}";
nativeBuildInputs = with pkgs; [
pkg-config
stdenv.cc
];
GIT_VERSION = git_version;
CARGO_PROFILE = if release then "release" else "dev";
@ -123,10 +145,17 @@ let
//
(if rustTarget != null then {
CARGO_BUILD_TARGET = rustTarget;
} else {});
"CARGO_TARGET_${targetEnvMap.${target}}_LINKER" = "${stdenv.cc.targetPrefix}cc";
HOST_CC = "${stdenv.cc.nativePrefix}cc";
TARGET_CC = "${stdenv.cc.targetPrefix}cc";
} else {
# CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER = "clang";
});
in rec {
inherit toolchain;
toolchain = toolchain pkgs;
devShell = pkgs.mkShell {
buildInputs = [