Unverified Commit 3d007e8a authored by John Ericson's avatar John Ericson Committed by GitHub
Browse files

Merge pull request #257559 from emilytrau/minimal-glibc-removal

minimal-bootstrap.*: rebuild packages with musl
parents 1486c62d adf49a8b
Loading
Loading
Loading
Loading
+21 −14
Original line number Diff line number Diff line
@@ -4,15 +4,14 @@
, fetchurl
, bootBash
, gnumake
, gnupatch
, gnused
, gnugrep
, gnutar
, gawk
, gzip
, gcc
, glibc
, binutils
, linux-headers
, diffutils
, tinycc
, derivationWithMeta
, bash
, coreutils
@@ -25,19 +24,26 @@ let
    url = "mirror://gnu/bash/bash-${version}.tar.gz";
    sha256 = "132qng0jy600mv1fs95ylnlisx2wavkkgpb19c6kmz7lnmjhjwhk";
  };

  patches = [
    # flush output for generated code
    ./mksignames-flush.patch
  ];
in
bootBash.runCommand "${pname}-${version}" {
  inherit pname version;

  nativeBuildInputs = [
    gcc
    binutils
    coreutils
    tinycc.compiler
    gnumake
    gnupatch
    gnused
    gnugrep
    gnutar
    gawk
    gzip
    diffutils
  ];

  passthru.runCommand = name: env: buildCommand:
@@ -78,22 +84,23 @@ bootBash.runCommand "${pname}-${version}" {
  tar xzf ${src}
  cd bash-${version}

  # Patch
  ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches}

  # Configure
  export CC="gcc -I${glibc}/include -I${linux-headers}/include"
  export LIBRARY_PATH="${glibc}/lib"
  export LIBS="-lc -lnss_files -lnss_dns -lresolv"
  export ac_cv_func_dlopen=no
  export CC="tcc -B ${tinycc.libs}/lib"
  export AR="tcc -ar"
  export LD=tcc
  bash ./configure \
    --prefix=$out \
    --build=${buildPlatform.config} \
    --host=${hostPlatform.config} \
    --disable-nls \
    --disable-net-redirections
    --without-bash-malloc

  # Build
  make SHELL=bash
  make -j $NIX_BUILD_CORES SHELL=bash

  # Install
  make install
  make -j $NIX_BUILD_CORES install
  ln -s bash $out/bin/sh
''
+10 −0
Original line number Diff line number Diff line
--- a/support/mksignames.c
+++ b/support/mksignames.c
@@ -68,6 +68,7 @@ write_signames (stream)
   fprintf (stream, "};\n\n");
   fprintf (stream, "#define initialize_signames()\n\n");
 #endif
+  fflush(stream);
 }
 
 int
+39 −41
Original line number Diff line number Diff line
@@ -3,35 +3,29 @@
, hostPlatform
, fetchurl
, bash
, coreutils
, gnumake
, gnupatch
, gnused
, gnugrep
, gnutar
, gawk
, bzip2
, sed
, mesBootstrap ? false, tinycc ? null
, gcc ? null, glibc ? null, binutils ? null, linux-headers
, diffutils
, gnutar
, xz
, tinycc
}:
assert mesBootstrap -> tinycc != null;
assert !mesBootstrap -> gcc != null && glibc != null && binutils != null;

let
  pname = "binutils" + lib.optionalString mesBootstrap "-mes";
  version = "2.20.1";
  rev = "a";
  # Based on https://github.com/ZilchOS/bootstrap-from-tcc/blob/2e0c68c36b3437386f786d619bc9a16177f2e149/using-nix/2a1-static-binutils.nix
  pname = "binutils";
  version = "2.41";

  src = fetchurl {
    url = "mirror://gnu/binutils/binutils-${version}${rev}.tar.bz2";
    sha256 = "0r7dr0brfpchh5ic0z9r4yxqn4ybzmlh25sbp30cacqk8nb7rlvi";
    url = "mirror://gnu/binutils/binutils-${version}.tar.xz";
    hash = "sha256-rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA=";
  };

  patches = [
    # Enables building binutils using TCC and Mes C Library
    (fetchurl {
      url = "https://git.savannah.gnu.org/cgit/guix.git/plain/gnu/packages/patches/binutils-boot-2.20.1a.patch?id=50249cab3a98839ade2433456fe618acc6f804a5";
      sha256 = "086sf6an2k56axvs4jlky5n3hs2l3rq8zq5d37h0b69cdyh7igpn";
    })

    # Make binutils output deterministic by default.
    ./deterministic.patch
  ];
@@ -40,10 +34,10 @@ let
    "--prefix=${placeholder "out"}"
    "--build=${buildPlatform.config}"
    "--host=${hostPlatform.config}"
    "--disable-nls"
    "--disable-shared"
    "--disable-werror"
    "--with-sysroot=/"
    "--enable-deterministic-archives"
    # depends on bison
    "--disable-gprofng"

    # Turn on --enable-new-dtags by default to make the linker set
    # RUNPATH instead of RPATH on binaries.  This is important because
@@ -60,15 +54,16 @@ bash.runCommand "${pname}-${version}" {
  inherit pname version;

  nativeBuildInputs = [
    (if mesBootstrap then tinycc.compiler else gcc)
    tinycc.compiler
    gnumake
    gnupatch
    gnused
    gnugrep
    gnutar
    gawk
    bzip2
    sed
  ] ++ lib.optional (!mesBootstrap) binutils;
    diffutils
    gnutar
    xz
  ];

  passthru.tests.get-version = result:
    bash.runCommand "${pname}-get-version-${version}" {} ''
@@ -85,32 +80,35 @@ bash.runCommand "${pname}-${version}" {
  };
} ''
  # Unpack
  cp ${src} binutils.tar.bz2
  bunzip2 binutils.tar.bz2
  cp ${src} binutils.tar.xz
  unxz binutils.tar.xz
  tar xf binutils.tar
  rm binutils.tar
  cd binutils-${version}

  # Patch
  ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches}
  sed -i 's|/bin/sh|${bash}/bin/bash|' \
    missing install-sh mkinstalldirs
  # see libtool's 74c8993c178a1386ea5e2363a01d919738402f30
  sed -i 's/| \$NL2SP/| sort | $NL2SP/' ltmain.sh
  # alias makeinfo to true
  mkdir aliases
  ln -s ${coreutils}/bin/true aliases/makeinfo
  export PATH="$(pwd)/aliases/:$PATH"

  # Configure
  ${if mesBootstrap then ''
    export CC="tcc -B ${tinycc.libs}/lib -D __GLIBC_MINOR__=6 -D MES_BOOTSTRAP=1"
  export CC="tcc -B ${tinycc.libs}/lib"
  export AR="tcc -ar"
  '' else ''
    export CC="gcc -B ${glibc}/lib -I${glibc}/include -I${linux-headers}/include"
    export CPP="gcc -E -I${glibc}/include -I${linux-headers}/include"
    export AR="ar"
    export LIBRARY_PATH="${glibc}/lib"
    export LIBS="-lc -lnss_files -lnss_dns -lresolv"
  ''}
  export SED=sed
  export lt_cv_sys_max_cmd_len=32768
  export CFLAGS="-D__LITTLE_ENDIAN__=1"
  bash ./configure ${lib.concatStringsSep " " configureFlags}

  # Build
  make
  make -j $NIX_BUILD_CORES all-libiberty all-gas all-bfd all-libctf all-zlib all-gprof
  make all-ld # race condition on ld/.deps/ldwrite.Po, serialize
  make -j $NIX_BUILD_CORES

  # Install
  make install
  make -j $NIX_BUILD_CORES install
''
+7 −22
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
, bash
, tinycc
, gnumake
, gnupatch
, gnutar
, gzip
}:
let
@@ -14,16 +14,6 @@ let
    url = "https://sourceware.org/pub/bzip2/bzip2-${version}.tar.gz";
    sha256 = "0s92986cv0p692icqlw1j42y9nld8zd83qwhzbqd61p1dqbh6nmb";
  };

  patches = [
    # mes libc has no time support, so we remove that.
    # It also does not have fch{own,mod}, which we don't care about in the bootstrap
    # anyway, so we can null-op those calls.
    (fetchurl {
      url = "https://github.com/fosslinux/live-bootstrap/raw/87e9d7db9d22b400d1c05247254ac39ee2577e80/sysa/bzip2-1.0.8/patches/mes-libc.patch";
      sha256 = "14dciwib28h413skzfkh7samzh8x87dmwhldyxxphff04pvl1j3c";
    })
  ];
in
bash.runCommand "${pname}-${version}" {
  inherit pname version;
@@ -31,13 +21,13 @@ bash.runCommand "${pname}-${version}" {
  nativeBuildInputs = [
    tinycc.compiler
    gnumake
    gnupatch
    gnutar
    gzip
  ];

  passthru.tests.get-version = result:
    bash.runCommand "${pname}-get-version-${version}" {} ''
      ${result}/bin/bzip2 --version --help
      ${result}/bin/bzip2 --help
      mkdir $out
    '';

@@ -50,21 +40,16 @@ bash.runCommand "${pname}-${version}" {
  };
} ''
  # Unpack
  cp ${src} bzip2.tar.gz
  gunzip bzip2.tar.gz
  untar --file bzip2.tar
  rm bzip2.tar
  tar xzf ${src}
  cd bzip2-${version}

  # Patch
  ${lib.concatMapStringsSep "\n" (f: "patch -Np0 -i ${f}") patches}

  # Build
  make \
    CC="tcc -B ${tinycc.libs}/lib -I ." \
    -j $NIX_BUILD_CORES \
    CC="tcc -B ${tinycc.libs}/lib" \
    AR="tcc -ar" \
    bzip2 bzip2recover

  # Install
  make install PREFIX=$out
  make install -j $NIX_BUILD_CORES PREFIX=$out
''
+74 −0
Original line number Diff line number Diff line
{ lib
, buildPlatform
, hostPlatform
, fetchurl
, bash
, tinycc
, gnumake
, gnugrep
, gnused
, gawk
, gnutar
, gzip
}:
let
  pname = "coreutils";
  version = "9.4";

  src = fetchurl {
    url = "mirror://gnu/coreutils/coreutils-${version}.tar.gz";
    hash = "sha256-X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk=";
  };

  configureFlags = [
    "--prefix=${placeholder "out"}"
    "--build=${buildPlatform.config}"
    "--host=${hostPlatform.config}"
    # musl 1.1.x doesn't use 64bit time_t
    "--disable-year2038"
    # libstdbuf.so fails in static builds
    "--enable-no-install-program=stdbuf"
  ];
in
bash.runCommand "${pname}-${version}" {
  inherit pname version;

  nativeBuildInputs = [
    tinycc.compiler
    gnumake
    gnused
    gnugrep
    gawk
    gnutar
    gzip
  ];

  passthru.tests.get-version = result:
    bash.runCommand "${pname}-get-version-${version}" {} ''
      ${result}/bin/cat --version
      mkdir $out
    '';

  meta = with lib; {
    description = "The GNU Core Utilities";
    homepage = "https://www.gnu.org/software/coreutils";
    license = licenses.gpl3Plus;
    maintainers = teams.minimal-bootstrap.members;
    platforms = platforms.unix;
  };
} ''
  # Unpack
  tar xzf ${src}
  cd coreutils-${version}

  # Configure
  export CC="tcc -B ${tinycc.libs}/lib"
  export LD=tcc
  bash ./configure ${lib.concatStringsSep " " configureFlags}

  # Build
  make -j $NIX_BUILD_CORES AR="tcc -ar" MAKEINFO="true"

  # Install
  make -j $NIX_BUILD_CORES install MAKEINFO="true"
''
Loading