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

minimal-bootstrap.gcc-glibc: init at 13.2.0 (#471642)

parents e3412284 79225589
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -166,12 +166,17 @@ lib.makeScope
        gawk = gawk-mes;
      };

      gcc-glibc = callPackage ./gcc/glibc.nix {
        gcc = gcc-latest;
        gnumake = gnumake-musl;
        gnutar = gnutar-latest;
      };

      glibc = callPackage ./glibc {
        gcc = gcc-latest;
        gnumake = gnumake-musl;
        gnutar = gnutar-latest;
        gnugrep = gnugrep-static;
        gawk = gawk-static;
      };

      gnugrep = callPackage ./gnugrep {
@@ -388,6 +393,7 @@ lib.makeScope
        echo ${gcc46-cxx.tests.hello-world}
        echo ${gcc8.tests.hello-world}
        echo ${gcc-latest.tests.hello-world}
        echo ${gcc-glibc.tests.hello-world}
        echo ${glibc.tests.hello-world}
        echo ${gnugrep.tests.get-version}
        echo ${gnugrep-static.tests.get-version}
+149 −0
Original line number Diff line number Diff line
{
  lib,
  buildPlatform,
  hostPlatform,
  fetchurl,
  bash,
  coreutils,
  gcc,
  glibc,
  musl,
  binutils,
  gnumake,
  gnused,
  gnugrep,
  gawk,
  diffutils,
  findutils,
  gnutar,
  gzip,
  bzip2,
  xz,
}:
let
  pname = "gcc";
  version = "13.2.0";
  linkerName =
    {
      i686-linux = "ld-linux.so.2";
      x86_64-linux = "ld-linux-x86-64.so.2";
    }
    .${hostPlatform.system};

  src = fetchurl {
    url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.xz";
    hash = "sha256-4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
  };

  gmpVersion = "6.3.0";
  gmp = fetchurl {
    url = "mirror://gnu/gmp/gmp-${gmpVersion}.tar.xz";
    hash = "sha256-o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
  };

  mpfrVersion = "4.2.1";
  mpfr = fetchurl {
    url = "mirror://gnu/mpfr/mpfr-${mpfrVersion}.tar.xz";
    hash = "sha256-J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
  };

  mpcVersion = "1.3.1";
  mpc = fetchurl {
    url = "mirror://gnu/mpc/mpc-${mpcVersion}.tar.gz";
    hash = "sha256-q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
  };

  islVersion = "0.24";
  isl = fetchurl {
    url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${islVersion}.tar.bz2";
    hash = "sha256-/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
  };
in
bash.runCommand "${pname}-${version}"
  {
    inherit pname version;

    nativeBuildInputs = [
      gcc
      binutils
      gnumake
      gnused
      gnugrep
      gawk
      diffutils
      findutils
      gnutar
      gzip
      bzip2
      xz
    ];

    passthru.tests.hello-world =
      result:
      bash.runCommand "${pname}-simple-program-${version}"
        {
          nativeBuildInputs = [
            binutils
            result
          ];
        }
        ''
          cat <<EOF >> test.c
          #include <stdio.h>
          int main() {
            printf("Hello World!\n");
            return 0;
          }
          EOF
          gcc -o test test.c
          ./test
          mkdir $out
        '';

    meta = {
      description = "GNU Compiler Collection, version ${version}";
      homepage = "https://gcc.gnu.org";
      license = lib.licenses.gpl3Plus;
      teams = [ lib.teams.minimal-bootstrap ];
      platforms = lib.platforms.unix;
      mainProgram = "gcc";
    };
  }
  ''
    # Unpack
    tar xf ${src}
    tar xf ${gmp}
    tar xf ${mpfr}
    tar xf ${mpc}
    tar xf ${isl}
    cd gcc-${version}

    ln -s ../gmp-${gmpVersion} gmp
    ln -s ../mpfr-${mpfrVersion} mpfr
    ln -s ../mpc-${mpcVersion} mpc
    ln -s ../isl-${islVersion} isl

    # Configure
    export CC="gcc -Wl,-dynamic-linker -Wl,${musl}/lib/libc.so"
    export CXX="g++ -Wl,-dynamic-linker -Wl,${musl}/lib/libc.so"

    bash ./configure \
      --prefix=$out \
      --build=${buildPlatform.config} \
      --host=${hostPlatform.config} \
      --with-native-system-header-dir=${glibc}/include \
      --enable-languages=c,c++ \
      --disable-bootstrap \
      --disable-dependency-tracking \
      --disable-libsanitizer \
      --disable-lto \
      --disable-multilib \
      --disable-plugin \
      --with-specs="%x{-dynamic-linker=${glibc}/lib/${linkerName}} %x{-L${glibc}/lib/} -B${glibc}/lib"

    # Build
    make -j $NIX_BUILD_CORES

    # Install
    make -j $NIX_BUILD_CORES install-strip
  ''
+1 −0
Original line number Diff line number Diff line
@@ -108,5 +108,6 @@ bash.runCommand "${pname}-${version}"

    # Install
    make -j $NIX_BUILD_CORES INSTALL_UNCOMPRESSED=yes install
    ln -s $(ls -d ${linux-headers}/include/* | grep -v scsi\$) $out/include/
    find $out/{bin,sbin,lib,libexec} -type f -exec strip --strip-unneeded {} + || true
  ''