summaryrefslogtreecommitdiffstats
path: root/pkgs/applications/emulators/wine/llvm-mingw.nix
blob: 4434c397990052cfe20f1cedf3c336a8f150d33c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{
  lib,
  stdenvNoCC,
  fetchurl,
  autoPatchelfHook,
  zlib,
  stdenv,
}:

# Used as a workaround for ucrtAarch64.
# compiler-rt due to pthread.h not being found during cross-build.

let
  version = "20260421";

  hostArch =
    if stdenv.hostPlatform.isAarch64 then
      "aarch64"
    else if stdenv.hostPlatform.isx86_64 then
      "x86_64"
    else
      throw "llvm-mingw: unsupported host platform ${stdenv.hostPlatform.system}";

  hashes = {
    aarch64 = "sha256-6c+lqTKQy4Utxaa5DM3iVUA6YzMmSL4XFHDKPBrTeCg=";
    x86_64 = "sha256-+LjM53mv/qtHvK7Gzm6edosWYJSjZhI+9kstCzicwSE=";
  };
in
stdenvNoCC.mkDerivation {
  pname = "llvm-mingw-${hostArch}";
  inherit version;

  src = fetchurl {
    url = "https://github.com/mstorsjo/llvm-mingw/releases/download/${version}/llvm-mingw-${version}-ucrt-ubuntu-22.04-${hostArch}.tar.xz";
    hash = hashes.${hostArch};
  };

  nativeBuildInputs = [ autoPatchelfHook ];
  buildInputs = [
    (lib.getLib stdenv.cc.cc) # libstdc++
    zlib
  ];

  dontConfigure = true;
  dontBuild = true;

  installPhase = ''
    runHook preInstall

    mkdir -p $out
    cp -r * $out/

    runHook postInstall
  '';

  autoPatchelfIgnoreMissingDeps = [ "*.dll" ];
  dontStrip = true;

  meta = {
    description = "LLVM/Clang/LLD-based mingw-w64 toolchain (prebuilt)";
    homepage = "https://github.com/mstorsjo/llvm-mingw";
    license = lib.licenses.zlib;
    platforms = [
      "aarch64-linux"
      "x86_64-linux"
    ];
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
  };
}