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.

Refers to cri-o/cri-o#7911

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
  • Loading branch information
saschagrunert committed Apr 25, 2024
1 parent affab49 commit 0f0366d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 33 deletions.
5 changes: 4 additions & 1 deletion nix/default-s390x.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
(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
15 changes: 7 additions & 8 deletions nix/derivation.nix
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
{ pkgs }:
{ stdenv
, pkgs
}:
with pkgs; stdenv.mkDerivation rec {
name = "conmon";
src = ./..;
vendorSha256 = null;
vendorHash = null;
doCheck = false;
enableParallelBuilding = true;
outputs = [ "out" ];
nativeBuildInputs = with buildPackages; [
bash
gitMinimal
pkg-config
which
];
buildInputs = [
glib
glibc
buildInputs = lib.optionals (!stdenv.hostPlatform.isMusl) [
glibc.static
] ++ [
pkgsStatic.glib
libseccomp
pcre2
];
prePatch = ''
export CFLAGS='-static -pthread'
Expand Down
10 changes: 5 additions & 5 deletions nix/nixpkgs.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"url": "https://github.com/nixos/nixpkgs",
"rev": "f4f097b65b336b1f4cdf947b7fbe076bd2a69126",
"date": "2024-02-28T11:07:01+01:00",
"path": "/nix/store/4blmmjaibdghqzk1wa8la3w9afvyldpq-nixpkgs",
"sha256": "0r1kbfbh3rbpl4w7rvyxyl3q6nchnmmd6bjwsqbz0gbsrsly7vbg",
"hash": "sha256-b+3jqc56PfAX1lwu02q1kFmDB/Xd73w4oXflAZdbM2Q=",
"rev": "17d58b30575bb965966d67e8ca1070f9a71cfb41",
"date": "2024-04-25T11:03:10+03:00",
"path": "/nix/store/01ql69ya47924icr0sm5vclrcl98ryr2-nixpkgs",
"sha256": "1szc653551qmd1iqk6lqcnamsr7bdd5qrfimi4r1ma199cblpd14",
"hash": "sha256-JLRLF0spqBoyiTW6jEtr62RdlWWYmoljaBWHUkYx7Os=",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": false,
Expand Down
19 changes: 0 additions & 19 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,4 @@ self: super:
doCheck = false;
dontDisableStatic = true;
});
pcre2 = super.pcre2.overrideAttrs (x: {
configureFlags = x.configureFlags ++ [ "--enable-static" ];
});
glib = super.glib.overrideAttrs (x: {
outputs = [ "bin" "out" "dev" ];
mesonFlags = [
"-Ddefault_library=static"
"-Ddevbindir=${placeholder ''dev''}/bin"
"-Dgtk_doc=false"
"-Dnls=disabled"
];
postInstall = ''
moveToOutput "share/glib-2.0" "$dev"
substituteInPlace "$dev/bin/gdbus-codegen" --replace "$out" "$dev"
sed -i "$dev/bin/glib-gettextize" -e "s|^gettext_dir=.*|gettext_dir=$dev/share/glib-2.0/gettext|"
sed '1i#line 1 "${x.pname}-${x.version}/include/glib-2.0/gobject/gobjectnotifyqueue.c"' \
-i "$dev"/include/glib-2.0/gobject/gobjectnotifyqueue.c
'';
});
}

0 comments on commit 0f0366d

Please sign in to comment.