Cheng Shao pushed to branch wip/fix-darwin-toolchain-cruft at Glasgow Haskell Compiler / GHC

Commits:

3 changed files:

Changes:

  • .gitlab/darwin/nix/sources.json
    1 1
     {
    
    2
    -    "niv": {
    
    3
    -        "branch": "master",
    
    4
    -        "description": "Easy dependency management for Nix projects",
    
    5
    -        "homepage": "https://github.com/nmattia/niv",
    
    6
    -        "owner": "nmattia",
    
    7
    -        "repo": "niv",
    
    8
    -        "rev": "e0ca65c81a2d7a4d82a189f1e23a48d59ad42070",
    
    9
    -        "sha256": "1pq9nh1d8nn3xvbdny8fafzw87mj7gsmp6pxkdl65w2g18rmcmzx",
    
    10
    -        "type": "tarball",
    
    11
    -        "url": "https://github.com/nmattia/niv/archive/e0ca65c81a2d7a4d82a189f1e23a48d59ad42070.tar.gz",
    
    12
    -        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
    
    13
    -    },
    
    14 2
         "nixpkgs": {
    
    15
    -        "branch": "nixos-unstable",
    
    3
    +        "branch": "nixpkgs-25.05-darwin",
    
    16 4
             "description": "Nix Packages collection",
    
    17 5
             "homepage": "",
    
    18 6
             "owner": "nixos",
    
    19 7
             "repo": "nixpkgs",
    
    20
    -        "rev": "2893f56de08021cffd9b6b6dfc70fd9ccd51eb60",
    
    21
    -        "sha256": "1anwxmjpm21msnnlrjdz19w31bxnbpn4kgf93sn3npihi7wf4a8h",
    
    8
    +        "rev": "3e3f3c7f9977dc123c23ee21e8085ed63daf8c37",
    
    9
    +        "sha256": "0jnmv6gpzhqb0jyhj7qi7vjfwbn4cqs5blm5xia7q5i0ma2bbkcd",
    
    22 10
             "type": "tarball",
    
    23
    -        "url": "https://github.com/nixos/nixpkgs/archive/2893f56de08021cffd9b6b6dfc70fd9ccd51eb60.tar.gz",
    
    11
    +        "url": "https://github.com/nixos/nixpkgs/archive/3e3f3c7f9977dc123c23ee21e8085ed63daf8c37.tar.gz",
    
    24 12
             "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
    
    25 13
         }
    
    26 14
     }

  • .gitlab/darwin/toolchain.nix
    ... ... @@ -11,69 +11,67 @@ let
    11 11
       hsPkgs = pkgs.haskellPackages;
    
    12 12
       alex = hsPkgs.alex;
    
    13 13
       happy = hsPkgs.happy;
    
    14
    -  targetTriple = pkgs.stdenv.targetPlatform.config;
    
    14
    +  targetTriple = pkgs.stdenvNoCC.targetPlatform.config;
    
    15 15
     
    
    16 16
       ghcBindists = let version = ghc.version; in {
    
    17
    -    aarch64-darwin = hostPkgs.fetchurl {
    
    17
    +    aarch64-darwin = hostPkgs.fetchzip {
    
    18 18
           url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-aarch64-apple-darwin.tar.xz";
    
    19
    -      sha256 = "sha256-/6+DtdeossBJIMbjkJwL4h3eJ7rzgNCV+ifoQKOi6AQ=";
    
    19
    +      hash = "sha512-xUlt7zc/OT3a1SR0BxmFFgrabPkWUENATdw4NbQwEi5+nH5yPau+HSrGI5UUoKdO4gdpgZlPaxtI7eSk0fx1+g==";
    
    20 20
         };
    
    21
    -    x86_64-darwin = hostPkgs.fetchurl {
    
    21
    +    x86_64-darwin = hostPkgs.fetchzip {
    
    22 22
           url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
    
    23
    -      sha256 = "sha256-jPIhiJMOENesUnDUJeIaPatgavc6ZVSTY5NFIAxlC+k=";
    
    23
    +      hash = "sha512-4/INeJwPPGbOj9MepwnIvIg2lvFkqS8w/3U/I8f6gCsoNlgwPr78iyY9vd6vfMONR1GxNQU3L/lxE07F3P0Qag==";
    
    24 24
         };
    
    25
    -
    
    26 25
       };
    
    27 26
     
    
    28
    -  ghc = pkgs.stdenv.mkDerivation rec {
    
    29
    -    version = "9.10.1";
    
    27
    +  ghc = pkgs.stdenvNoCC.mkDerivation rec {
    
    28
    +    version = "9.10.3";
    
    30 29
         name = "ghc";
    
    31
    -    src = ghcBindists.${pkgs.stdenv.hostPlatform.system};
    
    30
    +    src = ghcBindists.${pkgs.stdenvNoCC.hostPlatform.system};
    
    31
    +
    
    32
    +    dontUpdateAutotoolsGnuConfigScripts = true;
    
    33
    +
    
    32 34
         configureFlags = [
    
    33
    -      "CC=/usr/bin/clang"
    
    34
    -      "CLANG=/usr/bin/clang"
    
    35 35
           "AR=/usr/bin/ar"
    
    36
    -      "LLC=${llvm}/bin/llc"
    
    37
    -      "OPT=${llvm}/bin/opt"
    
    38
    -      "LLVMAS=${llvm_clang}/bin/clang"
    
    39
    -      "CONF_CC_OPTS_STAGE2=--target=${targetTriple}"
    
    40
    -      "CONF_CXX_OPTS_STAGE2=--target=${targetTriple}"
    
    41
    -      "CONF_GCC_LINKER_OPTS_STAGE2=--target=${targetTriple}"
    
    36
    +      "CC=/usr/bin/clang"
    
    37
    +      "CXX=/usr/bin/clang++"
    
    38
    +      "INSTALL=/usr/bin/install"
    
    39
    +      "INSTALL_NAME_TOOL=/usr/bin/install_name_tool"
    
    40
    +      "MergeObjsCmd=/usr/bin/ld"
    
    41
    +      "NM=/usr/bin/nm"
    
    42
    +      "OTOOL=/usr/bin/otool"
    
    43
    +      "RANLIB=/usr/bin/ranlib"
    
    42 44
         ];
    
    43
    -    buildPhase = "true";
    
    44
    -
    
    45
    -    # This is a horrible hack because the configure script invokes /usr/bin/clang
    
    46
    -    # without a `--target` flag. Then depending on whether the `nix` binary itself is
    
    47
    -    # a native x86 or arm64 binary means that /usr/bin/clang thinks it needs to run in
    
    48
    -    # x86 or arm64 mode.
    
    49
    -
    
    50
    -    # The correct answer for the check in question is the first one we try, so by replacing
    
    51
    -    # the condition to true; we select the right C++ standard library still.
    
    52
    -    preConfigure = ''
    
    53
    -      sed "s/\"\$CC\" -o actest actest.o \''${1} 2>\/dev\/null/true/i" configure > configure.new
    
    54
    -      mv configure.new configure
    
    55
    -      chmod +x configure
    
    56
    -      cat configure
    
    57 45
     
    
    46
    +    # Use the arch command to explicitly specify architecture, so that
    
    47
    +    # configure and its subprocesses would pick up the architecture we
    
    48
    +    # choose via the system argument.
    
    49
    +    preConfigure = pkgs.lib.optionalString (system == "aarch64-darwin") ''
    
    50
    +      substituteInPlace configure \
    
    51
    +        --replace-fail "#! /bin/sh" "#!/usr/bin/env -S /usr/bin/arch -arm64 /bin/sh"
    
    52
    +    '' + pkgs.lib.optionalString (system == "x86_64-darwin") ''
    
    53
    +      substituteInPlace configure \
    
    54
    +        --replace-fail "#! /bin/sh" "#!/usr/bin/env -S /usr/bin/arch -x86_64 /bin/sh"
    
    55
    +    '' + ''
    
    56
    +      unset DEVELOPER_DIR SDKROOT
    
    57
    +      export DEVELOPER_DIR="$(/usr/bin/xcode-select --print-path)"
    
    58
    +      export SDKROOT="$(/usr/bin/xcrun --sdk macosx --show-sdk-path)"
    
    58 59
         '';
    
    59 60
     
    
    61
    +    dontPatchShebangsInConfigure = true;
    
    62
    +
    
    60 63
         # N.B. Work around #20253.
    
    61 64
         nativeBuildInputs = [ pkgs.gnused ];
    
    62
    -    postInstallPhase = ''
    
    63
    -      settings="$out/lib/ghc-${version}/settings"
    
    64
    -      sed -i -e "s%\"llc\"%\"${llvm}/bin/llc\"%" $settings
    
    65
    -      sed -i -e "s%\"opt\"%\"${llvm}/bin/opt\"%" $settings
    
    66
    -      sed -i -e "s%\"clang\"%\"/usr/bin/clang\"%" $settings
    
    67
    -      sed -i -e 's%("C compiler command", "")%("C compiler command", "/usr/bin/clang")%' $settings
    
    68
    -      sed -i -e 's%("C compiler flags", "")%("C compiler flags", "--target=${targetTriple}")%' $settings
    
    69
    -      sed -i -e 's%("C++ compiler flags", "")%("C++ compiler flags", "--target=${targetTriple}")%' $settings
    
    70
    -      sed -i -e 's%("C compiler link flags", "")%("C compiler link flags", "--target=${targetTriple}")%' $settings
    
    71
    -    '';
    
    65
    +
    
    66
    +    dontBuild = true;
    
    67
    +
    
    68
    +    enableParallelInstalling = true;
    
    69
    +
    
    70
    +    dontFixup = true;
    
    72 71
     
    
    73 72
         # Sanity check: verify that we can compile hello world.
    
    74 73
         doInstallCheck = true;
    
    75 74
         installCheckPhase = ''
    
    76
    -      unset DYLD_LIBRARY_PATH
    
    77 75
           $out/bin/ghc --info
    
    78 76
           cd $TMP
    
    79 77
           mkdir test-ghc; cd test-ghc
    
    ... ... @@ -91,13 +89,13 @@ let
    91 89
       ourtexlive = with pkgs;
    
    92 90
         texlive.combine {
    
    93 91
           inherit (texlive)
    
    94
    -        scheme-medium collection-xetex fncychap titlesec tabulary varwidth
    
    92
    +        scheme-small collection-xetex fncychap tex-gyre titlesec tabulary varwidth
    
    95 93
             framed capt-of wrapfig needspace dejavu-otf helvetic upquote;
    
    96 94
         };
    
    97 95
       fonts = with pkgs; makeFontsConf { fontDirectories = [ dejavu_fonts ]; };
    
    98 96
     
    
    99
    -  llvm = pkgs.llvm_15;
    
    100
    -  llvm_clang = pkgs.llvmPackages_15.clang-unwrapped;
    
    97
    +  llvm = pkgs.llvm_21;
    
    98
    +  llvm_clang = pkgs.llvmPackages_21.clang-unwrapped;
    
    101 99
     in
    
    102 100
     pkgs.writeTextFile {
    
    103 101
       name = "toolchain";
    

  • llvm-targets
    ... ... @@ -44,8 +44,8 @@
    44 44
     ,("riscv64-unknown-linux", ("e-m:e-p:64:64-i64:64-i128:128-n64-S128", "", "+m +a +f +d +c +relax"))
    
    45 45
     ,("loongarch64-unknown-linux-gnu", ("e-m:e-p:64:64-i64:64-i128:128-n64-S128", "", "+f +d"))
    
    46 46
     ,("loongarch64-unknown-linux", ("e-m:e-p:64:64-i64:64-i128:128-n64-S128", "", "+f +d"))
    
    47
    -,("x86_64-apple-darwin", ("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", "penryn", ""))
    
    48
    -,("arm64-apple-darwin", ("e-m:o-i64:64-i128:128-n32:64-S128", "generic", "+v8.3a +fp-armv8 +neon +crc +crypto +fullfp16 +ras +lse +rdm +rcpc +zcm +zcz +sha2 +aes"))
    
    47
    +,("x86_64-apple-darwin", ("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", "core2", ""))
    
    48
    +,("arm64-apple-darwin", ("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32", "apple-m1", "+v8.4a +aes +altnzcv +ccdp +ccpp +complxnum +crc +dotprod +flagm +fp-armv8 +fp16fml +fptoint +fullfp16 +jsconv +lse +neon +pauth +perfmon +predres +ras +rcpc +rdm +sb +sha2 +sha3 +specrestrict +ssbs"))
    
    49 49
     ,("aarch64-apple-ios", ("e-m:o-i64:64-i128:128-n32:64-S128", "apple-a7", "+fp-armv8 +neon +crypto +zcm +zcz +sha2 +aes"))
    
    50 50
     ,("x86_64-apple-ios", ("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", "core2", ""))
    
    51 51
     ,("amd64-portbld-freebsd", ("e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", "x86-64", ""))