diff options
author | Moritz Angermann <moritz.angermann@gmail.com> | 2021-02-13 11:41:47 +0800 |
---|---|---|
committer | Moritz Angermann <moritz.angermann@gmail.com> | 2021-05-07 09:17:22 +0800 |
commit | c5454dc7467cf6f51d9ab27430271abee5628f6d (patch) | |
tree | 93f08ae87d50ec14bc19ec34fff689f578a7fa64 | |
parent | 30f6923a834ccaca30c3622a0a82421fabcab119 (diff) | |
download | haskell-c5454dc7467cf6f51d9ab27430271abee5628f6d.tar.gz |
[ci] Add support for building on aarch64-darwin
This will fail for now. But allows us to add aarch64-darwin
machines to CI.
(cherry picked from commit a7d22795ed118abfe64f4fc55d96d8561007ce1e)
-rw-r--r-- | .gitlab-ci.yml | 196 | ||||
-rwxr-xr-x | .gitlab/ci.sh | 46 | ||||
-rw-r--r-- | .gitlab/shell.nix | 52 |
3 files changed, 265 insertions, 29 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0c1899d844..dbb088c8da 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -393,11 +393,42 @@ lint-compiler: variables: TEST_TYPE: test MAKE_ARGS: "-Werror" - script: - - .gitlab/ci.sh setup - - .gitlab/ci.sh configure - - .gitlab/ci.sh build_make - - .gitlab/ci.sh test_make + script: | + # Build hyperlinked sources for documentation when building releases + if [[ "$RELEASE_JOB" = "yes" ]]; then + HADDOCK_HYPERLINKED_SOURCES=1 + fi + TIME_START=$(date +%s) + time .gitlab/ci.sh setup 2>&1 + TIME_SETUP=$(date +%s) + TIME_SETUP_DELTA=$(expr $TIME_SETUP - $TIME_START) + echo "Setup took $TIME_SETUP_DELTA seconds" + + time .gitlab/ci.sh configure 2>&1 + TIME_CONFIGURE=$(date +%s) + TIME_CONFIGURE_DELTA=$(expr $TIME_CONFIGURE - $TIME_SETUP) + echo "Configure took $TIME_CONFIGURE_DELTA seconds" + + time .gitlab/ci.sh build_make 2>&1 + TIME_BUILD=$(date +%s) + TIME_BUILD_DELTA=$(expr $TIME_BUILD - $TIME_CONFIGURE) + echo "Build took $TIME_BUILD_DELTA seconds" + + set +e + time .gitlab/ci.sh test_make 2>&1 + status=$? + set -e + TIME_TEST=$(date +%s) + TIME_TEST_DELTA=$(expr $TIME_TEST - $TIME_BUILD) + echo "Test took $TIME_TEST_DELTA seconds" + + echo "=== TIMINGS ===" + echo "Setup | $TIME_SETUP_DELTA" + echo "Configure | $TIME_CONFIGURE_DELTA" + echo "Build | $TIME_BUILD_DELTA" + echo "Test | $TIME_TEST_DELTA" + exit $status + dependencies: [] artifacts: reports: @@ -491,10 +522,13 @@ release-x86_64-freebsd: validate-x86_64-darwin: extends: .validate - needs: [validate-x86_64-linux-deb9-hadrian] stage: full-build tags: - - x86_64-darwin + - x86_64-darwin-m1 + + # for now make this non mandatory to pass. + allow_failure: true + variables: GHC_VERSION: 8.10.4 CABAL_INSTALL_VERSION: 3.2.0.0 @@ -504,7 +538,15 @@ validate-x86_64-darwin: ac_cv_func_clock_gettime: "no" # Only newer OS Xs support utimensat. See #17895 ac_cv_func_utimensat: "no" + + TEST_TYPE: test + MAKE_ARGS: "-Werror" + # we run on M1's for now, getconf can't be built with nix yet, + # and we use a pure shell, so we can't/shouldn't use /usr/bin/getconf + # inside th shell. + CPUS: 8 LANG: "en_US.UTF-8" + # WARNING: this is overridden in the shell.nix, see shell.nix! CONFIGURE_ARGS: "--with-intree-gmp" TEST_ENV: "x86_64-darwin" BUILD_FLAVOUR: "validate" @@ -513,11 +555,149 @@ validate-x86_64-darwin: after_script: - cp -Rf $HOME/.cabal cabal-cache - .gitlab/ci.sh clean + + # I wish we could just use the nix #! logic, but we can't --run and -i bash + # behave very differently. -i bash does not pass any nix related env vars + # the whole $stdenv/setup part seems to be missing. + script: | + set -Eeuo pipefail + function runInNixShell() { + time nix-shell .gitlab/shell.nix \ + -I nixpkgs=https://github.com/angerman/nixpkgs/archive/75f7281738b.tar.gz \ + --argstr system "x86_64-darwin" \ + --pure \ + --keep GHC_VERSION --keep CABAL_INSTALL_VERSION --keep BUILD_FLAVOUR \ + --keep BIN_DIST_PREP_TAR_COMP --keep CPUS --keep PROJECT_DIR \ + --keep CI_PROJECT_DIR --keep MAKE_ARGS \ + --keep LANG --keep CONFIGURE_ARGS \ + --keep MACOSX_DEPLOYMENT_TARGET --keep ac_cv_func_clock_gettime \ + --run "$1" 2>&1 + } + # fix up config.sub in libraries for the time. + # aarch64-darwin is not supported in older config.sub's + TIME_START=$(date +%s) + find libraries -name config.sub -exec cp config.sub {} \; + + runInNixShell ".gitlab/ci.sh setup" 2>&1 + TIME_SETUP=$(date +%s) + TIME_SETUP_DELTA=$(expr $TIME_SETUP - $TIME_START) + echo "Setup took $TIME_SETUP_DELTA seconds" + + runInNixShell ".gitlab/ci.sh configure" 2>&1 + TIME_CONFIGURE=$(date +%s) + TIME_CONFIGURE_DELTA=$(expr $TIME_CONFIGURE - $TIME_SETUP) + echo "Configure took $TIME_CONFIGURE_DELTA seconds" + + runInNixShell ".gitlab/ci.sh build_make" 2>&1 + TIME_BUILD=$(date +%s) + TIME_BUILD_DELTA=$(expr $TIME_BUILD - $TIME_CONFIGURE) + echo "Build took $TIME_BUILD_DELTA seconds" + + set +e + runInNixShell ".gitlab/ci.sh test_make" 2>&1 + status=$? + set -e + + TIME_TEST=$(date +%s) + TIME_TEST_DELTA=$(expr $TIME_TEST - $TIME_BUILD) + echo "Test took $TIME_TEST_DELTA seconds" + + echo "=== TIMINGS ===" + echo "Setup | $TIME_SETUP_DELTA" + echo "Configure | $TIME_CONFIGURE_DELTA" + echo "Build | $TIME_BUILD_DELTA" + echo "Test | $TIME_TEST_DELTA" + exit $status + + artifacts: + when: always + expire_in: 2 week + cache: + key: "darwin-x86_64-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +validate-aarch64-darwin: + extends: .validate + stage: full-build + tags: + - aarch64-darwin-m1 + + # for now make this non mandatory to pass. + allow_failure: true + + variables: + TEST_TYPE: test + MAKE_ARGS: "-Werror" + GHC_VERSION: 8.10.3 + CABAL_INSTALL_VERSION: 3.2.0.0 + BUILD_FLAVOUR: "perf" + BIN_DIST_PREP_TAR_COMP: "ghc-arm64-apple-darwin.tar.xz" + # we run on M1's for now, getconf can't be built with nix yet, + # and we use a pure shell, so we can't/shouldn't use /usr/bin/getconf + # inside th shell. + CPUS: 8 + LANG: "en_US.UTF-8" + # WARNING: this is overridden in the shell.nix, see shell.nix! + CONFIGURE_ARGS: "--with-intree-gmp" + + # I wish we could just use the nix #! logic, but we can't --run and -i bash + # behave very differently. -i bash does not pass any nix related env vars + # the whole $stdenv/setup part seems to be missing. + script: | + set -Eeuo pipefail + function runInNixShell() { + time nix-shell .gitlab/shell.nix \ + -I nixpkgs=https://github.com/angerman/nixpkgs/archive/75f7281738b.tar.gz \ + --argstr system "aarch64-darwin" \ + --pure \ + --keep GHC_VERSION --keep CABAL_INSTALL_VERSION --keep BUILD_FLAVOUR \ + --keep BIN_DIST_PREP_TAR_COMP --keep CPUS --keep PROJECT_DIR \ + --keep CI_PROJECT_DIR --keep MAKE_ARGS \ + --keep LANG --keep CONFIGURE_ARGS \ + --run "$1" 2>&1 + } + # fix up config.sub in libraries for the time. + # aarch64-darwin is not supported in older config.sub's + TIME_START=$(date +%s) + find libraries -name config.sub -exec cp config.sub {} \; + + time runInNixShell ".gitlab/ci.sh setup" 2>&1 + TIME_SETUP=$(date +%s) + TIME_SETUP_DELTA=$(expr $TIME_SETUP - $TIME_START) + echo "Setup took $TIME_SETUP_DELTA seconds" + + runInNixShell ".gitlab/ci.sh configure" 2>&1 + TIME_CONFIGURE=$(date +%s) + TIME_CONFIGURE_DELTA=$(expr $TIME_CONFIGURE - $TIME_SETUP) + echo "Setup took $TIME_CONFIGURE_DELTA seconds" + + runInNixShell ".gitlab/ci.sh build_make" 2>&1 + TIME_BUILD=$(date +%s) + TIME_BUILD_DELTA=$(expr $TIME_BUILD - $TIME_CONFIGURE) + echo "Build took $TIME_BUILD_DELTA seconds" + + set +e + runInNixShell ".gitlab/ci.sh test_make" 2>&1 + status=$? + set -e + TIME_TEST=$(date +%s) + TIME_TEST_DELTA=$(expr $TIME_TEST - $TIME_BUILD) + echo "Test took $TIME_TEST_DELTA seconds" + + echo "=== TIMINGS ===" + echo "Setup | $TIME_SETUP_DELTA" + echo "Configure | $TIME_CONFIGURE_DELTA" + echo "Build | $TIME_BUILD_DELTA" + echo "Test | $TIME_TEST_DELTA" + exit $status + artifacts: when: always expire_in: 2 week cache: - key: "darwin-$GHC_VERSION" + key: "darwin-aarch64-$GHC_VERSION" paths: - cabal-cache - toolchain diff --git a/.gitlab/ci.sh b/.gitlab/ci.sh index 66c52a7c94..db75cc1fef 100755 --- a/.gitlab/ci.sh +++ b/.gitlab/ci.sh @@ -3,9 +3,7 @@ # This is the primary driver of the GitLab CI infrastructure. # Run `ci.sh usage` for usage information. - - -set -e -o pipefail +set -Eeuo pipefail # Configuration: HACKAGE_INDEX_STATE="2020-12-21T14:48:20Z" # TODO dedup with yaml's def @@ -173,12 +171,18 @@ function show_tool() { function set_toolchain_paths() { needs_toolchain="1" - case "$(uname)" in - Linux) needs_toolchain="0" ;; + case "$(uname -m)-$(uname)" in + *-Linux) needs_toolchain="" ;; *) ;; esac - if [[ "$needs_toolchain" = "1" ]]; then + if [[ -n "${IN_NIX_SHELL:-}" ]]; then + needs_toolchain="" + GHC="$(which ghc)" + CABAL="$(which cabal)" + HAPPY="$(which happy)" + ALEX="$(which alex)" + elif [[ -n "$needs_toolchain" ]]; then # These are populated by setup_toolchain GHC="$toolchain/bin/ghc$exe" CABAL="$toolchain/bin/cabal$exe" @@ -354,7 +358,7 @@ BUILD_SPHINX_HTML=$BUILD_SPHINX_HTML BUILD_SPHINX_PDF=$BUILD_SPHINX_PDF BeConservative=YES BIGNUM_BACKEND=$BIGNUM_BACKEND -XZ_CMD=$XZ +XZ_CMD=${XZ:-} BuildFlavour=$BUILD_FLAVOUR ifneq "\$(BuildFlavour)" "" @@ -363,7 +367,7 @@ endif GhcLibHcOpts+=-haddock EOF - if [ -n "$HADDOCK_HYPERLINKED_SOURCES" ]; then + if [ -n "${HADDOCK_HYPERLINKED_SOURCES:-}" ]; then echo "EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump" >> mk/build.mk fi @@ -382,7 +386,7 @@ function configure() { end_section "booting" local target_args="" - if [[ -n "$target_triple" ]]; then + if [[ -n "${target_triple:-}" ]]; then target_args="--target=$target_triple" fi @@ -403,7 +407,7 @@ function build_make() { if [[ -z "$BIN_DIST_PREP_TAR_COMP" ]]; then fail "BIN_DIST_PREP_TAR_COMP is not set" fi - if [[ -n "$VERBOSE" ]]; then + if [[ -n "${VERBOSE:-}" ]]; then MAKE_ARGS="$MAKE_ARGS V=1" else MAKE_ARGS="$MAKE_ARGS V=0" @@ -422,7 +426,7 @@ function fetch_perf_notes() { } function push_perf_notes() { - if [ -n "$CROSS_TARGET" ]; then + if [ -n "${CROSS_TARGET:-}" ]; then info "Can't test cross-compiled build." return fi @@ -439,16 +443,16 @@ function determine_metric_baseline() { } function test_make() { - if [ -n "$CROSS_TARGET" ]; then + if [ -n "${CROSS_TARGET:-}" ]; then info "Can't test cross-compiled build." return fi run "$MAKE" test_bindist TEST_PREP=YES - run "$MAKE" V=0 test \ + run "$MAKE" V=0 VERBOSE=1 test \ THREADS="$cores" \ JUNIT_FILE=../../junit.xml \ - EXTRA_RUNTEST_OPTS="$RUNTEST_ARGS" + EXTRA_RUNTEST_OPTS="${RUNTEST_ARGS:-}" } function build_hadrian() { @@ -462,7 +466,7 @@ function build_hadrian() { } function test_hadrian() { - if [ -n "$CROSS_TARGET" ]; then + if [ -n "${CROSS_TARGET:-}" ]; then info "Can't test cross-compiled build." return fi @@ -476,7 +480,7 @@ function test_hadrian() { test \ --summary-junit=./junit.xml \ --test-compiler="$TOP"/_build/install/bin/ghc \ - "runtest.opts+=$RUNTEST_ARGS" + "runtest.opts+=${RUNTEST_ARGS:-}" } function cabal_test() { @@ -517,14 +521,14 @@ function run_hadrian() { if [ -z "$BUILD_FLAVOUR" ]; then fail "BUILD_FLAVOUR not set" fi - if [ -z "$BIGNUM_BACKEND" ]; then BIGNUM_BACKEND="gmp"; fi - if [ -n "$VERBOSE" ]; then HADRIAN_ARGS="$HADRIAN_ARGS -V"; fi + if [ -z "${BIGNUM_BACKEND:-}" ]; then BIGNUM_BACKEND="gmp"; fi + if [ -n "${VERBOSE:-}" ]; then HADRIAN_ARGS="${HADRIAN_ARGS:-} -V"; fi run hadrian/build-cabal \ --flavour="$BUILD_FLAVOUR" \ -j"$cores" \ - --broken-test="$BROKEN_TESTS" \ + --broken-test="${BROKEN_TESTS:-}" \ --bignum=$BIGNUM_BACKEND \ - $HADRIAN_ARGS \ + ${HADRIAN_ARGS:-} \ $@ } @@ -560,7 +564,7 @@ case "$(uname)" in *) fail "uname $(uname) is not supported" ;; esac -if [ -n "$CROSS_TARGET" ]; then +if [ -n "${CROSS_TARGET:-}" ]; then info "Cross-compiling for $CROSS_TARGET..." target_triple="$CROSS_TARGET" fi diff --git a/.gitlab/shell.nix b/.gitlab/shell.nix new file mode 100644 index 0000000000..f5c691ffaa --- /dev/null +++ b/.gitlab/shell.nix @@ -0,0 +1,52 @@ +{ system ? "aarch64-darwin" +#, nixpkgs ? fetchTarball https://github.com/angerman/nixpkgs/archive/257cb120334.tar.gz #apple-silicon.tar.gz +, pkgs ? import <nixpkgs> { 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; + + # 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"; + + buildInputs = with pkgs; [ + haskell.compiler.${compiler} + haskell.packages.${compiler}.cabal-install + haskell.packages.${compiler}.alex + haskell.packages.${compiler}.happy # _1_19_12 is needed for older GHCs. + + clang_11 + llvm_11 + + automake + autoconf + m4 + + gmp + ncurses + libiconv + zlib.out + zlib.dev + glibcLocales + # locale doesn't build yet :-/ + # locale + + git + + python3 + # python3Full + # python3Packages.sphinx + perl + + which + wget + file + + xz + xlibs.lndir + + cacert + ]; +} |