Skip to content

Commit

Permalink
Build s390x binaries using musl libc
Browse files Browse the repository at this point in the history
Building using musl until NixOS/nixpkgs#306473
is resolved.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
  • Loading branch information
saschagrunert committed Apr 24, 2024
1 parent 37670c8 commit a85f1b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion nix/default-s390x.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{ enableSystemd ? false }:
(import ./nixpkgs.nix {
crossSystem = {
config = "s390x-unknown-linux-gnu";
# TODO: Switch back to glibc when
# https://github.com/NixOS/nixpkgs/issues/306473
# is resolved.
config = "s390x-unknown-linux-musl";
};
overlays = [ (import ./overlay.nix) ];
}).callPackage ./derivation.nix
Expand Down
8 changes: 5 additions & 3 deletions nix/derivation.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ pkgs
{ stdenv
, pkgs
, enableCriu
, enableSystemd
}:
Expand All @@ -17,9 +18,10 @@ with pkgs; stdenv.mkDerivation {
python3
which
];
buildInputs = [
buildInputs = lib.optionals (!stdenv.hostPlatform.isMusl) [
glibc
glibc.static
] ++ [
libcap
libseccomp
libsystemd
Expand All @@ -31,7 +33,7 @@ with pkgs; stdenv.mkDerivation {
export LDFLAGS='-s -w -static-libgcc -static'
export EXTRA_LDFLAGS='-s -w -linkmode external -extldflags "-static -lm"'
export CRUN_LDFLAGS='-all-static'
export LIBS='${lib.optionalString enableCriu "${criu}/lib/libcriu.a"} ${glibc.static}/lib/libc.a ${glibc.static}/lib/libpthread.a ${glibc.static}/lib/librt.a ${lib.getLib libcap}/lib/libcap.a ${lib.getLib libseccomp}/lib/libseccomp.a ${lib.optionalString enableSystemd "${lib.getLib libsystemd}/lib/libsystemd.a"} ${yajl}/lib/libyajl.a'
export LIBS='${lib.optionalString enableCriu "${criu}/lib/libcriu.a"} ${lib.optionalString (!stdenv.hostPlatform.isMusl) "${glibc.static}/lib/libc.a ${glibc.static}/lib/libpthread.a ${glibc.static}/lib/librt.a"} ${lib.getLib libcap}/lib/libcap.a ${lib.getLib libseccomp}/lib/libseccomp.a ${lib.optionalString enableSystemd "${lib.getLib libsystemd}/lib/libsystemd.a"} ${yajl}/lib/libyajl.a'
'';
buildPhase = ''
patchShebangs .
Expand Down

0 comments on commit a85f1b4

Please sign in to comment.