diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 577a52eb8d3..8ab20f2c044 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,11 @@ +stages: + - build + +# Used for ci setup in the gitlab mirror of the project: +# https://gitlab.haskell.org/haskell/haskell-language-server/-/pipelines variables: # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: "853f348f9caf38b08740b280296fbd34e09abb3a" + DOCKER_REV: "4ed1a4f27828ba96a34662dc954335e29b470cd2" GHC_VERSION: 8.10.7 CABAL_INSTALL_VERSION: 3.6.2.0 @@ -9,11 +14,13 @@ workflow: rules: - if: $CI_COMMIT_TAG when: always + # Triggered if you start it from the gitlab web ui - if: '$CI_PIPELINE_SOURCE == "web"' when: always - when: never .build: + stage: build script: - bash .gitlab/ci.sh artifacts: @@ -84,15 +91,6 @@ build-i386-linux-alpine: # temp, because 3.6.2.0 is broken CABAL_INSTALL_VERSION: 3.4.0.0 -build-x86_64-freebsd13: - extends: .build - tags: - - x86_64-freebsd13 - variables: - TARBALL_ARCHIVE_SUFFIX: x86_64-freebsd13 - TARBALL_EXT: tar.xz - ADD_CABAL_ARGS: "--enable-split-sections" - build-x86_64-freebsd12: extends: .build tags: @@ -112,25 +110,24 @@ build-x86_64-darwin: ADD_CABAL_ARGS: "" build-aarch64-darwin: + stage: build tags: - aarch64-darwin-m1 + before_script: + - export HOMEBREW_CHANGE_ARCH_TO_ARM=1 + - arch -arm64 /bin/bash ./.gitlab/brew.sh llvm autoconf automake coreutils make tree + # C_INCLUDE_PATH: https://gitlab.haskell.org/ghc/ghc/-/issues/20592 script: | - set -Eeuo pipefail - function runInNixShell() { - time nix-shell $CI_PROJECT_DIR/.gitlab/shell.nix \ - -I nixpkgs=https://github.com/angerman/nixpkgs/archive/75f7281738b.tar.gz \ - --argstr system "aarch64-darwin" \ - --pure \ - --keep CI_PROJECT_DIR \ - --keep MACOSX_DEPLOYMENT_TARGET \ - --keep GHC_VERSION \ - --keep CABAL_INSTALL_VERSION \ - --keep TARBALL_ARCHIVE_SUFFIX \ - --keep TARBALL_EXT \ - --keep ADD_CABAL_ARGS \ - --run "$1" 2>&1 - } - runInNixShell "./.gitlab/ci.sh" 2>&1 + export PATH="$CI_PROJECT_DIR/.brew/opt/llvm/bin:$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" + export CC=$CI_PROJECT_DIR/.brew/opt/llvm/bin/clang + export CXX=$CI_PROJECT_DIR/.brew/opt/llvm/bin/clang++ + export LD=ld + export AR=$CI_PROJECT_DIR/.brew/opt/llvm/bin/llvm-ar + export RANLIB=$CI_PROJECT_DIR/.brew/opt/llvm/bin/llvm-ranlib + export C_INCLUDE_PATH="`xcrun --show-sdk-path`/usr/include/ffi" + arch -arm64 /bin/bash ./.gitlab/ci.sh + after_script: + - rm -Rf /private/tmp/.brew_tmp variables: MACOSX_DEPLOYMENT_TARGET: "10.7" TARBALL_ARCHIVE_SUFFIX: aarch64-darwin @@ -144,14 +141,8 @@ build-aarch64-darwin: build-x86_64-windows: extends: .build script: - - Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;Invoke-Command -ScriptBlock ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -ArgumentList $false, $true, $true, $false, $false, $false, $false, "$CI_PROJECT_DIR" - - ./ghcup/msys64/usr/bin/bash '-lc' 'pacman --noconfirm -S zip' - $env:CHERE_INVOKING = "yes" - - ./ghcup/msys64/usr/bin/bash '-lc' "TARBALL_ARCHIVE_SUFFIX=$env:TARBALL_ARCHIVE_SUFFIX TARBALL_EXT=$env:TARBALL_EXT ADD_CABAL_ARGS=$env:ADD_CABAL_ARGS GHC_VERSION=$env:GHC_VERSION CABAL_INSTALL_VERSION=$CABAL_INSTALL_VERSION .gitlab/ci.sh" - after_script: - - "[Environment]::SetEnvironmentVariable('GHCUP_INSTALL_BASE_PREFIX', $null, [System.EnvironmentVariableTarget]::User)" - - "[Environment]::SetEnvironmentVariable('GHCUP_MSYS2', $null, [System.EnvironmentVariableTarget]::User)" - - "[Environment]::SetEnvironmentVariable('CABAL_DIR', $null, [System.EnvironmentVariableTarget]::User)" + - bash '-lc' "ADD_CABAL_ARGS=$env:ADD_CABAL_ARGS GHC_VERSION=$env:GHC_VERSION CABAL_INSTALL_VERSION=$CABAL_INSTALL_VERSION .gitlab/ci.sh" tags: - new-x86_64-windows variables: diff --git a/.gitlab/brew.sh b/.gitlab/brew.sh new file mode 100644 index 00000000000..de769632e6f --- /dev/null +++ b/.gitlab/brew.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -Eeuxo pipefail + +# Install brew locally in the project dir. Packages will also be installed here. +[ -e "$CI_PROJECT_DIR/.brew" ] || git clone --depth=1 https://github.com/Homebrew/brew $CI_PROJECT_DIR/.brew +export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" + +# make sure to not pollute the machine with temp files etc +mkdir -p $CI_PROJECT_DIR/.brew_cache +export HOMEBREW_CACHE=$CI_PROJECT_DIR/.brew_cache +mkdir -p $CI_PROJECT_DIR/.brew_logs +export HOMEBREW_LOGS=$CI_PROJECT_DIR/.brew_logs +mkdir -p /private/tmp/.brew_tmp +export HOMEBREW_TEMP=/private/tmp/.brew_tmp + +# update and install packages +brew update +brew install ${1+"$@"} diff --git a/.gitlab/ci.sh b/.gitlab/ci.sh index 19a9f9c4cdf..469be94242f 100755 --- a/.gitlab/ci.sh +++ b/.gitlab/ci.sh @@ -1,10 +1,9 @@ #!/usr/bin/env bash -set -Eeuo pipefail +set -Eeuxo pipefail source "$CI_PROJECT_DIR/.gitlab/common.sh" - export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR/toolchain" export CABAL_DIR="$CI_PROJECT_DIR/cabal" @@ -28,7 +27,23 @@ export BOOTSTRAP_HASKELL_CABAL_VERSION=$CABAL_INSTALL_VERSION export BOOTSTRAP_HASKELL_VERBOSE=1 export BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=yes -curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh +# for some reason the subshell doesn't pick up the arm64 environment on darwin +# and starts installing x86_64 GHC +case "$(uname -s)" in + "Darwin"|"darwin") + case "$(/usr/bin/arch)" in + aarch64|arm64|armv8l) + curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | arch -arm64 /bin/bash + ;; + *) + curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh + ;; + esac + ;; + *) + curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh + ;; +esac # https://github.com/haskell/cabal/issues/7313#issuecomment-811851884 if [ "$(getconf LONG_BIT)" == "32" ] ; then diff --git a/.gitlab/shell.nix b/.gitlab/shell.nix deleted file mode 100644 index 33c7c67beee..00000000000 --- a/.gitlab/shell.nix +++ /dev/null @@ -1,90 +0,0 @@ -{ system ? "aarch64-darwin" -#, nixpkgs ? fetchTarball https://github.com/angerman/nixpkgs/archive/257cb120334.tar.gz #apple-silicon.tar.gz -, pkgs ? import { inherit system; } -, compiler ? if system == "aarch64-darwin" then "ghc8103Binary" else "ghc8103" -}: pkgs.mkShell { - # this prevents nix from trying to write the env-vars file. - # we can't really, as NIX_BUILD_TOP/env-vars is not set. - noDumpEnvVars=1; - - # stop polluting LDFLAGS with -liconv - dontAddExtraLibs = true; - - # we need to inject ncurses into --with-curses-libraries. - # the real fix is to teach terminfo to use libcurses on macOS. - # CONFIGURE_ARGS = "--with-intree-gmp --with-curses-libraries=${pkgs.ncurses.out}/lib"; - CONFIGURE_ARGS = "--with-intree-gmp --with-curses-libraries=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib --with-iconv-includes=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include --with-iconv-libraries=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib SH=/bin/bash"; - - # magic speedup pony :facepalm: - # - # nix has the ugly habbit of duplicating ld flags more than necessary. This - # somewhat consolidates this. - shellHook = '' - export NIX_LDFLAGS=$(for a in $NIX_LDFLAGS; do echo $a; done |sort|uniq|xargs) - export NIX_LDFLAGS_FOR_TARGET=$(for a in $NIX_LDFLAGS_FOR_TARGET; do echo $a; done |sort|uniq|xargs) - export NIX_LDFLAGS_FOR_TARGET=$(comm -3 <(for l in $NIX_LDFLAGS_FOR_TARGET; do echo $l; done) <(for l in $NIX_LDFLAGS; do echo $l; done)) - - - # Impurity hack for GHC releases. - ################################# - # We don't want binary releases to depend on nix, thus we'll need to make sure we don't leak in references. - # GHC externally depends only on iconv and curses. However we can't force a specific curses library for - # the terminfo package, as such we'll need to make sure we only look in the system path for the curses library - # and not pick up the tinfo from the nix provided ncurses package. - # - # We also need to force us to use the systems COREFOUNDATION, not the one that nix builds. Again this is impure, - # but it will allow us to have proper binary distributions. - # - # do not use nixpkgs provided core foundation - export NIX_COREFOUNDATION_RPATH=/System/Library/Frameworks - # drop curses from the LDFLAGS, we really want the system ones, not the nix ones. - export NIX_LDFLAGS=$(for lib in $NIX_LDFLAGS; do case "$lib" in *curses*);; *) echo -n "$lib ";; esac; done;) - export NIX_CFLAGS_COMPILE+=" -Wno-nullability-completeness -Wno-availability -Wno-expansion-to-defined -Wno-builtin-requires-header -Wno-unused-command-line-argument" - - # unconditionally add the MacOSX.sdk and TargetConditional.h - export NIX_CFLAGS_COMPILE+=" -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include" - export NIX_LDFLAGS="-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib $NIX_LDFLAGS" - - ''; - - nativeBuildInputs = (with pkgs; [ - # This needs to come *before* ghc, - # otherwise we migth end up with the clang from - # the bootstrap GHC in PATH with higher priority. - clang_11 - llvm_11 - - haskell.compiler.${compiler} - haskell.packages.${compiler}.cabal-install - haskell.packages.${compiler}.alex - haskell.packages.${compiler}.happy # _1_19_12 is needed for older GHCs. - - automake - autoconf - m4 - - gmp - zlib.out - zlib.dev - glibcLocales - # locale doesn't build yet :-/ - # locale - - git - - python3 - # python3Full - # python3Packages.sphinx - perl - - which - wget - curl - file - - xz - xlibs.lndir - - cacert ]) - ++ (with pkgs.darwin.apple_sdk.frameworks; [ Foundation Security ]); -}