<commit_before>{ stdenv
, fetchurl
, fetchTritonPatch
, linux-headers
, installLocales ? false
}:

import ./common.nix {
  name = "glibc";

  inherit fetchurl fetchTritonPatch stdenv linux-headers installLocales;

  preConfigure = stdenv.lib.optionalString (stdenv.targetSystem != stdenv.hostSystem) ''
    sed -i s/-lgcc_eh//g "../$sourceRoot/Makeconfig"

    cat > config.cache << "EOF"
    libc_cv_forced_unwind=yes
    libc_cv_c_cleanup=yes
    libc_cv_gnu89_inline=yes
    EOF
    export BUILD_CC=gcc
    export CC="$targetSystem-gcc"
    export AR="$targetSystem-ar"
    export RANLIB="$targetSystem-ranlib"

    dontStrip=1
  '';

  installTargets = [
    "install"
  ] ++ stdenv.lib.optionals installLocales [
    "localedata/install-locales"
  ];

  postInstall = ''
    rm $out/etc/ld.so.cache

    # Include the Linux kernel headers in Glibc, except the `scsi'
    # subdirectory, which Glibc provides itself.
    (cd $out/include && \
     ln -sv $(ls -d ${linux-headers}/include/* | grep -v 'scsi''$') .)

    # Fix for NIXOS-54 (ldd not working on x86_64).  Make a symlink
    # "lib64" to "lib".
    #if test -n "$is64bit"; then
    #  ln -s lib $out/lib64
    #fi

    # Get rid of more unnecessary stuff.
    rm -rf $out/var $out/sbin/sln
  '';

  # When building glibc from bootstrap-tools, we need libgcc_s at RPATH for
  # any program we run, because the gcc will have been placed at a new
  # store path than that determined when built (as a source for the
  # bootstrap-tools tarball)
  # Building from a proper gcc staying in the path where it was installed,
  # libgcc_s will not be at {gcc}/lib, and gcc's libgcc will be found without
  # any special hack.
  preInstall = stdenv.lib.optionalString (stdenv.targetSystem == stdenv.hostSystem) ''
    if [ -f ${stdenv.cc.cc}/lib/libgcc_s.so.1 ]; then
      mkdir -p $out/lib
      cp ${stdenv.cc.cc}/lib/libgcc_s.so.1 $out/lib/libgcc_s.so.1
      patchelf --set-rpath $out/lib --force-rpath $out/lib/libgcc_s.so.1<commit_msg>glibc: Fix RTLDLIST in ldd<commit_after>{ stdenv
, fetchurl
, fetchTritonPatch
, linux-headers
, installLocales ? false
}:

import ./common.nix {
  name = "glibc";

  inherit fetchurl fetchTritonPatch stdenv linux-headers installLocales;

  preConfigure = stdenv.lib.optionalString (stdenv.targetSystem != stdenv.hostSystem) ''
    sed -i s/-lgcc_eh//g "../$sourceRoot/Makeconfig"

    cat > config.cache << "EOF"
    libc_cv_forced_unwind=yes
    libc_cv_c_cleanup=yes
    libc_cv_gnu89_inline=yes
    EOF
    export BUILD_CC=gcc
    export CC="$targetSystem-gcc"
    export AR="$targetSystem-ar"
    export RANLIB="$targetSystem-ranlib"

    dontStrip=1
  '';

  installTargets = [
    "install"
  ] ++ stdenv.lib.optionals installLocales [
    "localedata/install-locales"
  ];

  postInstall = ''
    rm $out/etc/ld.so.cache

    # Include the Linux kernel headers in Glibc, except the `scsi'
    # subdirectory, which Glibc provides itself.
    (cd $out/include && \
     ln -sv $(ls -d ${linux-headers}/include/* | grep -v 'scsi''$') .)

    # Fix ldd
    RTLDLIST="$(find $out -name ld\*.so\* | tr '\n' ' ')"
    sed -i "s,^RTLDLIST=,RTLDLIST=\"$RTLDLIST\",g" $out/bin/ldd

    # Get rid of more unnecessary stuff.
    rm -rf $out/var $out/sbin/sln
  '';

  # When building glibc from bootstrap-tools, we need libgcc_s at RPATH for
  # any program we run, because the gcc will have been placed at a new
  # store path than that determined when built (as a source for the
  # bootstrap-tools tarball)
  # Building from a proper gcc staying in the path where it was installed,
  # libgcc_s will not be at {gcc}/lib, and gcc's libgcc will be found without
  # any special hack.
  preInstall = stdenv.lib.optionalString (stdenv.targetSystem == stdenv.hostSystem) ''
    if [ -f ${stdenv.cc.cc}/lib/libgcc_s.so.1 ]; then
      mkdir -p $out/lib
      cp ${stdenv.cc.cc}/lib/libgcc_s.so.1 $out/lib/libgcc_s.so.1
      patchelf --set-rpath $out/lib --force-rpath $out/lib/libgcc_s.so.1
{'fraction_non_alphanumeric': 0.12405826217980914, 'fraction_numerical': 0.0065293822199899544, 'mean_word_length': 3.0477642276422765, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2640865', 'n_tokens_mistral': 1496, 'n_tokens_neox': 1408, 'n_words': 381}