Merge pull request #254888 from emilytrau/minimal-musl-1.2
minimal-bootstrap.musl: init at 1.2.4
This commit is contained in:
commit
9ac44c653e
2 changed files with 93 additions and 0 deletions
|
@ -144,6 +144,11 @@ lib.makeScope
|
|||
mes = lib.recurseIntoAttrs (callPackage ./mes { });
|
||||
mes-libc = callPackage ./mes/libc.nix { };
|
||||
|
||||
musl = callPackage ./musl {
|
||||
gcc = gcc46;
|
||||
gawk = gawk-mes;
|
||||
};
|
||||
|
||||
stage0-posix = callPackage ./stage0-posix { };
|
||||
|
||||
inherit (self.stage0-posix) kaem m2libc mescc-tools mescc-tools-extra;
|
||||
|
@ -180,6 +185,7 @@ lib.makeScope
|
|||
echo ${gzip.tests.get-version}
|
||||
echo ${heirloom.tests.get-version}
|
||||
echo ${mes.compiler.tests.get-version}
|
||||
echo ${musl.tests.hello-world}
|
||||
echo ${tinycc-mes.compiler.tests.chain}
|
||||
echo ${xz.tests.get-version}
|
||||
mkdir ''${out}
|
||||
|
|
87
pkgs/os-specific/linux/minimal-bootstrap/musl/default.nix
Normal file
87
pkgs/os-specific/linux/minimal-bootstrap/musl/default.nix
Normal file
|
@ -0,0 +1,87 @@
|
|||
{ lib
|
||||
, buildPlatform
|
||||
, hostPlatform
|
||||
, fetchurl
|
||||
, bash
|
||||
, gcc
|
||||
, binutils
|
||||
, gnumake
|
||||
, gnugrep
|
||||
, gnused
|
||||
, gawk
|
||||
, gnutar
|
||||
, gzip
|
||||
}:
|
||||
let
|
||||
pname = "musl";
|
||||
version = "1.2.4";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://musl.libc.org/releases/musl-${version}.tar.gz";
|
||||
hash = "sha256-ejXq4z1TcqfA2hGI3nmHJvaIJVE7euPr6XqqpSEU8Dk=";
|
||||
};
|
||||
in
|
||||
bash.runCommand "${pname}-${version}" {
|
||||
inherit pname version;
|
||||
|
||||
nativeBuildInputs = [
|
||||
gcc
|
||||
binutils
|
||||
gnumake
|
||||
gnused
|
||||
gnugrep
|
||||
gawk
|
||||
gnutar
|
||||
gzip
|
||||
];
|
||||
|
||||
passthru.tests.hello-world = result:
|
||||
bash.runCommand "${pname}-simple-program-${version}" {
|
||||
nativeBuildInputs = [ gcc binutils ];
|
||||
} ''
|
||||
cat <<EOF >> test.c
|
||||
#include <stdio.h>
|
||||
int main() {
|
||||
printf("Hello World!\n");
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
gcc -static -B${result}/lib -I${result}/include -o test test.c
|
||||
./test
|
||||
mkdir $out
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "An efficient, small, quality libc implementation";
|
||||
homepage = "https://musl.libc.org";
|
||||
license = licenses.mit;
|
||||
maintainers = teams.minimal-bootstrap.members;
|
||||
platforms = platforms.unix;
|
||||
};
|
||||
} ''
|
||||
# Unpack
|
||||
tar xzf ${src}
|
||||
cd musl-${version}
|
||||
|
||||
# Patch
|
||||
# https://github.com/ZilchOS/bootstrap-from-tcc/blob/2e0c68c36b3437386f786d619bc9a16177f2e149/using-nix/2a3-intermediate-musl.nix
|
||||
sed -i 's|/bin/sh|${bash}/bin/bash|' \
|
||||
tools/*.sh
|
||||
# patch popen/system to search in PATH instead of hardcoding /bin/sh
|
||||
sed -i 's|posix_spawn(&pid, "/bin/sh",|posix_spawnp(\&pid, "sh",|' \
|
||||
src/stdio/popen.c src/process/system.c
|
||||
sed -i 's|execl("/bin/sh", "sh", "-c",|execlp("sh", "-c",|'\
|
||||
src/misc/wordexp.c
|
||||
|
||||
# Configure
|
||||
bash ./configure \
|
||||
--prefix=$out \
|
||||
--build=${buildPlatform.config} \
|
||||
--host=${hostPlatform.config}
|
||||
|
||||
# Build
|
||||
make
|
||||
|
||||
# Install
|
||||
make install
|
||||
''
|
Loading…
Reference in a new issue