<commit_before>{ stdenv, fetchurl, fetchpatch, gfortran, perl, which, config, coreutils
# Most packages depending on openblas expect integer width to match
# pointer width, but some expect to use 32-bit integers always
# (for compatibility with reference BLAS).
, blas64 ? null
}:

with stdenv.lib;

let blas64_ = blas64; in

let
  # To add support for a new platform, add an element to this set.
  configs = {
    armv6l-linux = {
      BINARY = "32";
      TARGET = "ARMV6";
      DYNAMIC_ARCH = "0";
      CC = "gcc";
      USE_OPENMP = "1";
    };

    armv7l-linux = {
      BINARY = "32";
      TARGET = "ARMV7";
      DYNAMIC_ARCH = "0";
      CC = "gcc";
      USE_OPENMP = "1";
    };

    aarch64-linux = {
      BINARY = "64";
      TARGET = "ARMV8";
      DYNAMIC_ARCH = "1";
      CC = "gcc";
      USE_OPENMP = "1";
    };

    i686-linux = {
      BINARY = "32";
      TARGET = "P2";
      DYNAMIC_ARCH = "1";
      CC = "gcc";
      USE_OPENMP = "1";
    };

    x86_64-darwin = {
      BINARY = "64";
      TARGET = "ATHLON";
      DYNAMIC_ARCH = "1";
      # Note that clang is available through the stdenv on OSX and
      # thus is not an explicit dependency.
      CC = "clang";
      USE_OPENMP = "0";
      MACOSX_DEPLOYMENT_TARGET = "10.7";
    };

    x86_64-linux = {
      BINARY = "64";
      TARGET = "ATHLON";
      DYNAMIC_ARCH = "1";
      CC = "gcc";
      USE_OPENMP = if stdenv.hostPlatform.isMusl then "0" else "1";
    };
  };
in

let
  config =
    configs.${stdenv.system}
    or (throw "unsupported system: ${stdenv.system}");
in

let
  blas64 =
    if blas64_ != null
      then blas64_
      else hasPrefix "x86_64" stdenv.system;

  version = "0.2.20";
in
stdenv.mkDerivation {
  name = "openblas-${version}";
  src = fetchurl {
    url = "https://github.com/xianyi/OpenBLAS/archive/v${version}.tar.gz";
    sha256 = "157kpkbpwlr57dkmqiwr3qp9fglfidagv7l6fibrhln6v4aqpwsy";
    name = "openblas-${version}.tar.gz";
  };

  inherit blas64;

  # Some hardening features are disabled due to sporadic failures in
  # OpenBLAS-based programs. The problem may not be with OpenBLAS itself, but
  # with how these flags interact with hardening measures used downstream.
  # In either case, OpenBLAS must only be used by trusted code--it is
  # inherently unsuitable for security-conscious applications--so there should
  # be no objection to disabling these hardening measures.
  hardeningDisable = [
    # don't modify or move the stack
    "stackprotector" "pic"
    # don't alter index arithmetic
    "strictoverflow"
    # don't interfere with dynamic target detection
    "relro" "bindnow"
  ];

  nativeBuildInputs =
    [gfortran perl which]
    ++ optionals stdenv.isDarwin [coreutils];

  makeFlags =
    [
      "FC=gfortran"
      ''PREFIX="''$(out)"''
      "NUM_THREADS=64"
      "INTERFACE64=${if blas64 then "1" else "0"}"
      "NO_STATIC=1"
    ] ++ stdenv.lib.optional (stdenv.hostPlatform.libc == "musl") "NO_AFFINITY=1"
    ++ mapAttrsToList (var: val: var + "=" + val) config;

  patches = stdenv.lib.optional (stdenv.hostPlatform.libc != "glibc")
    # https://github.com/xianyi/OpenBLAS/pull/1247
    (fetchpatch {
      url = "https://github.com/xianyi/OpenBLAS/commit/88a35ff457f55e527e0e8a503a0dc61976c1846d.patch";
      sha256 = "1a3qrhvl5hp06c53fjqghq4zgf6ls7narm06l0shcvs57hznh09n";
    });

  doCheck = true;
  checkTarget = "tests";

  meta = with stdenv.lib; {
    description = "Basic Linear Algebra Subprograms";
    license = licenses.bsd3;
    homepage = https://github.com/xianyi/OpenBLAS;
    platforms = platforms.unix;
    maintainers = with maintainers; [ ttuegel ];
  };
}
<commit_msg>openblas: 0.2.20 -> 0.3.0 (#41054)<commit_after>{ stdenv, fetchurl, fetchpatch, gfortran, perl, which, config, coreutils
# Most packages depending on openblas expect integer width to match
# pointer width, but some expect to use 32-bit integers always
# (for compatibility with reference BLAS).
, blas64 ? null
}:

with stdenv.lib;

let blas64_ = blas64; in

let
  # To add support for a new platform, add an element to this set.
  configs = {
    armv6l-linux = {
      BINARY = "32";
      TARGET = "ARMV6";
      DYNAMIC_ARCH = "0";
      CC = "gcc";
      USE_OPENMP = "1";
    };

    armv7l-linux = {
      BINARY = "32";
      TARGET = "ARMV7";
      DYNAMIC_ARCH = "0";
      CC = "gcc";
      USE_OPENMP = "1";
    };

    aarch64-linux = {
      BINARY = "64";
      TARGET = "ARMV8";
      DYNAMIC_ARCH = "1";
      CC = "gcc";
      USE_OPENMP = "1";
    };

    i686-linux = {
      BINARY = "32";
      TARGET = "P2";
      DYNAMIC_ARCH = "1";
      CC = "gcc";
      USE_OPENMP = "1";
    };

    x86_64-darwin = {
      BINARY = "64";
      TARGET = "ATHLON";
      DYNAMIC_ARCH = "1";
      # Note that clang is available through the stdenv on OSX and
      # thus is not an explicit dependency.
      CC = "clang";
      USE_OPENMP = "0";
      MACOSX_DEPLOYMENT_TARGET = "10.7";
    };

    x86_64-linux = {
      BINARY = "64";
      TARGET = "ATHLON";
      DYNAMIC_ARCH = "1";
      CC = "gcc";
      USE_OPENMP = if stdenv.hostPlatform.isMusl then "0" else "1";
    };
  };
in

let
  config =
    configs.${stdenv.system}
    or (throw "unsupported system: ${stdenv.system}");
in

let
  blas64 =
    if blas64_ != null
      then blas64_
      else hasPrefix "x86_64" stdenv.system;

  version = "0.3.0";
in
stdenv.mkDerivation {
  name = "openblas-${version}";
  src = fetchurl {
    url = "https://github.com/xianyi/OpenBLAS/archive/v${version}.tar.gz";
    sha256 = "18giv3lsh8cva01z4rhsx8jvgliknni0jp7vxkc69qxb14vm8lfg";
    name = "openblas-${version}.tar.gz";
  };

  inherit blas64;

  # Some hardening features are disabled due to sporadic failures in
  # OpenBLAS-based programs. The problem may not be with OpenBLAS itself, but
  # with how these flags interact with hardening measures used downstream.
  # In either case, OpenBLAS must only be used by trusted code--it is
  # inherently unsuitable for security-conscious applications--so there should
  # be no objection to disabling these hardening measures.
  hardeningDisable = [
    # don't modify or move the stack
    "stackprotector" "pic"
    # don't alter index arithmetic
    "strictoverflow"
    # don't interfere with dynamic target detection
    "relro" "bindnow"
  ];

  nativeBuildInputs =
    [gfortran perl which]
    ++ optionals stdenv.isDarwin [coreutils];

  makeFlags =
    [
      "FC=gfortran"
      ''PREFIX="''$(out)"''
      "NUM_THREADS=64"
      "INTERFACE64=${if blas64 then "1" else "0"}"
      "NO_STATIC=1"
    ] ++ stdenv.lib.optional (stdenv.hostPlatform.libc == "musl") "NO_AFFINITY=1"
    ++ mapAttrsToList (var: val: var + "=" + val) config;

  patches = stdenv.lib.optional (stdenv.hostPlatform.libc != "glibc")
    # https://github.com/xianyi/OpenBLAS/pull/1247
    (fetchpatch {
      url = "https://github.com/xianyi/OpenBLAS/commit/88a35ff457f55e527e0e8a503a0dc61976c1846d.patch";
      sha256 = "1a3qrhvl5hp06c53fjqghq4zgf6ls7narm06l0shcvs57hznh09n";
    });

  doCheck = true;
  checkTarget = "tests";

  meta = with stdenv.lib; {
    description = "Basic Linear Algebra Subprograms";
    license = licenses.bsd3;
    homepage = https://github.com/xianyi/OpenBLAS;
    platforms = platforms.unix;
    maintainers = with maintainers; [ ttuegel ];
  };
}

{'fraction_non_alphanumeric': 0.1255446623093682, 'fraction_numerical': 0.042075163398692814, 'mean_word_length': 2.7133468149646105, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 8, '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': '5273182', 'n_tokens_mistral': 2923, 'n_tokens_neox': 2666, 'n_words': 651}