<commit_before>{ lib, stdenv, fetchurl, fetchpatch, pkgconfig, libatomic_ops
, enableLargeConfig ? false # doc: https://github.com/ivmai/bdwgc/blob/v7.6.6/doc/README.macros#L179
}:

stdenv.mkDerivation rec {
  name = "boehm-gc-${version}";
  version = "8.0.2";

  src = fetchurl {
    urls = [
      "https://github.com/ivmai/bdwgc/releases/download/v${version}/gc-${version}.tar.gz"
      "http://www.hboehm.info/gc/gc_source/gc-${version}.tar.gz"
    ];
    sha256 = "1jsixcpdwy5cgq5s9fi3bdlid9zh46vakymf3nbjffianyss932f";
  };

  buildInputs = [ libatomic_ops ];
  nativeBuildInputs = [ pkgconfig ];

  outputs = [ "out" "dev" "doc" ];
  separateDebugInfo = stdenv.isLinux;

  preConfigure = stdenv.lib.optionalString (stdenv.hostPlatform.libc == "musl") ''
    export NIX_CFLAGS_COMPILE+="-D_GNU_SOURCE -DUSE_MMAP -DHAVE_DL_ITERATE_PHDR"
  '';

  patches = [ (fetchpatch {
    name = "boehm-gc-7.6.0-sys_select.patch";
    url = "https://gitweb.gentoo.org/proj/musl.git/plain/dev-libs/boehm-gc/files/boehm-gc-7.6.0-sys_select.patch?id=85b6a600996bdd71162b357e9ba93d8559342432";
    sha256 = "1gydwlklvci30f5dpp5ccw2p2qpph5y41r55wx9idamjlq66fbb3";
  }) ] ++
    # https://github.com/ivmai/bdwgc/pull/208
    lib.optional stdenv.hostPlatform.isRiscV ./riscv.patch;

  configureFlags =
    [ "--enable-cplusplus" ]
    ++ lib.optional enableLargeConfig "--enable-large-config"
    ++ lib.optional (stdenv.hostPlatform.libc == "musl") "--disable-static";<commit_msg>boehm-gc: don't link to libatomic_ops when cross-compiling<commit_after>{ lib, stdenv, fetchurl, fetchpatch, pkgconfig, libatomic_ops
, enableLargeConfig ? false # doc: https://github.com/ivmai/bdwgc/blob/v7.6.6/doc/README.macros#L179
}:

stdenv.mkDerivation rec {
  name = "boehm-gc-${version}";
  version = "8.0.2";

  src = fetchurl {
    urls = [
      "https://github.com/ivmai/bdwgc/releases/download/v${version}/gc-${version}.tar.gz"
      "http://www.hboehm.info/gc/gc_source/gc-${version}.tar.gz"
    ];
    sha256 = "1jsixcpdwy5cgq5s9fi3bdlid9zh46vakymf3nbjffianyss932f";
  };

  buildInputs = [ libatomic_ops ];
  nativeBuildInputs = [ pkgconfig ];

  outputs = [ "out" "dev" "doc" ];
  separateDebugInfo = stdenv.isLinux;

  preConfigure = stdenv.lib.optionalString (stdenv.hostPlatform.libc == "musl") ''
    export NIX_CFLAGS_COMPILE+="-D_GNU_SOURCE -DUSE_MMAP -DHAVE_DL_ITERATE_PHDR"
  '';

  patches = [ (fetchpatch {
    name = "boehm-gc-7.6.0-sys_select.patch";
    url = "https://gitweb.gentoo.org/proj/musl.git/plain/dev-libs/boehm-gc/files/boehm-gc-7.6.0-sys_select.patch?id=85b6a600996bdd71162b357e9ba93d8559342432";
    sha256 = "1gydwlklvci30f5dpp5ccw2p2qpph5y41r55wx9idamjlq66fbb3";
  }) ] ++
    # https://github.com/ivmai/bdwgc/pull/208
    lib.optional stdenv.hostPlatform.isRiscV ./riscv.patch;

  configureFlags =
    [ "--enable-cplusplus" ]
    ++ lib.optional enableLargeConfig "--enable-large-config"
    ++ lib.optional (stdenv.hostPlatform.libc == "musl") "--disable-static"
    # Configure script can't detect whether C11 atomic intrinsics are available
    # when cross-compiling, so it links to libatomic_ops, which has to be
    # propagated to all dependencies. To avoid this, assume that the intrinsics
    # are available.
    ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "--with-libatomic-ops=none";
{'fraction_non_alphanumeric': 0.15303668069753457, 'fraction_numerical': 0.04990980156343957, 'mean_word_length': 3.8854625550660793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2972188', 'n_tokens_mistral': 1430, 'n_tokens_neox': 1337, 'n_words': 169}