[Git][ghc/ghc][wip/T18234] 4 commits: Hadrian: fix binary-dist target for cross-compilation

Ben Gamari gitlab at gitlab.haskell.org
Fri May 29 19:10:54 UTC 2020



Ben Gamari pushed to branch wip/T18234 at Glasgow Haskell Compiler / GHC


Commits:
46f62bcd by Sylvain Henry at 2020-05-29T19:53:17+02:00
Hadrian: fix binary-dist target for cross-compilation

- - - - -
e448cc40 by Ben Gamari at 2020-05-29T15:10:47-04:00
gitlab-ci: Add usage message to ci.sh

- - - - -
681a58d4 by Ben Gamari at 2020-05-29T15:10:47-04:00
gitlab-ci: Make names more consistent

- - - - -
21cb2c3d by Ben Gamari at 2020-05-29T15:10:47-04:00
gitlab-ci: Introduce a nightly cross-compilation job

This adds a job to test cross-compilation from x86-64 to AArch64 with
Hadrian.

Fixes #18234.

- - - - -


3 changed files:

- .gitlab-ci.yml
- .gitlab/ci.sh
- hadrian/src/Rules/BinaryDist.hs


Changes:

=====================================
.gitlab-ci.yml
=====================================
@@ -2,7 +2,7 @@ variables:
   GIT_SSL_NO_VERIFY: "1"
 
   # Commit of ghc/ci-images repository from which to pull Docker images
-  DOCKER_REV: 6223fe0b5942f4fa35bdec92c74566cf195bfb42
+  DOCKER_REV: ba119705df5222fe74208a85019cb980e2c4318f
 
   # Sequential version number capturing the versions of all tools fetched by
   # .gitlab/ci.sh.
@@ -178,7 +178,7 @@ lint-release-changelogs:
 # Validation via Pipelines (hadrian)
 ############################################################
 
-.validate-hadrian:
+.build-hadrian:
   variables:
     FLAVOUR: "validate"
   script:
@@ -198,11 +198,8 @@ lint-release-changelogs:
       - ghc.tar.xz
       - junit.xml
 
-.validate-linux-hadrian:
-  extends: .validate-hadrian
-  image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
-  variables:
-    TEST_ENV: "x86_64-linux-deb9-hadrian"
+.build-linux-hadrian:
+  extends: .build-hadrian
   before_script:
     # workaround for docker permissions
     - sudo chown ghc:ghc -R .
@@ -212,20 +209,54 @@ lint-release-changelogs:
     - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
   after_script:
     - .gitlab/ci.sh clean
+
+.build-x86_64-linux-deb9-hadrian:
+  extends: .build-linux-hadrian
+  image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
   tags:
     - x86_64-linux
 
 validate-x86_64-linux-deb9-hadrian:
-  extends: .validate-linux-hadrian
+  extends: .build-x86_64-linux-deb9-hadrian
   stage: build
+  variables:
+    TEST_ENV: "x86_64-linux-deb9-hadrian"
 
 validate-x86_64-linux-deb9-unreg-hadrian:
-  extends: .validate-linux-hadrian
+  extends: .build-x86_64-linux-deb9-hadrian
   stage: full-build
   variables:
     CONFIGURE_ARGS: --enable-unregisterised
     TEST_ENV: "x86_64-linux-deb9-unreg-hadrian"
 
+.build-x86_64-linux-deb10-hadrian:
+  extends: .build-hadrian
+  image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV"
+  before_script:
+    # workaround for docker permissions
+    - sudo chown ghc:ghc -R .
+    - git submodule sync --recursive
+    - git submodule update --init --recursive
+    - git checkout .gitmodules
+    - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
+  after_script:
+    - .gitlab/ci.sh clean
+  tags:
+    - x86_64-linux
+
+nightly-x86_64-linux-deb10-hadrian-cross-aarch64:
+  #<<: *nightly
+  stage: build
+  extends: .build-x86_64-linux-deb10-hadrian
+  variables:
+    CONFIGURE_ARGS: --with-intree-gmp
+    CROSS_TARGET: "aarch64-linux-gnu"
+
+
+############################################################
+# GHC-in-GHCi (Hadrian)
+############################################################
+
 hadrian-ghc-in-ghci:
   stage: quick-build
   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
@@ -327,7 +358,7 @@ release-x86_64-freebsd:
   stage: full-build
 
 .build-x86_64-freebsd-hadrian:
-  extends: .validate-hadrian
+  extends: .build-hadrian
   stage: full-build
   tags:
     - x86_64-freebsd
@@ -678,7 +709,7 @@ release-x86_64-linux-deb8:
 #################################
 
 .build-x86_64-linux-alpine-hadrian:
-  extends: .validate-linux-hadrian
+  extends: .build-linux-hadrian
   stage: full-build
   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine:$DOCKER_REV"
   # There are currently a few failing tests


=====================================
.gitlab/ci.sh
=====================================
@@ -2,6 +2,8 @@
 # shellcheck disable=SC2230
 
 # This is the primary driver of the GitLab CI infrastructure.
+# Run `ci.sh usage` for usage information.
+
 
 set -e -o pipefail
 
@@ -60,14 +62,64 @@ function run() {
 
 TOP="$(pwd)"
 
+function usage() {
+  cat <<EOF
+$0 - GHC continuous integration driver
+
+Modes:
+
+  usage         Show this usage message.
+  setup         Prepare environment for a build.
+  configure     Run ./configure.
+  build_make    Build GHC via the make build system
+  build_hadrian Build GHC via the Hadrian build system
+  test_make     Test GHC via the make build system
+  test_hadrian  Test GHC via the Hadrian build system
+  clean         Clean the tree
+  shell         Run an interactive shell with a configured build environment.
+
+Environment variables:
+
+  CROSS_TARGET      Triple of cross-compilation target.
+  MSYSTEM           (Windows-only) Which platform to build form (MINGW64 or MINGW32).
+
+Environment variables determining build configuration of Make system:
+
+  BUILD_FLAVOUR     Which flavour to build.
+  BUILD_SPHINX_HTML Whether to build Sphinx HTML documentation.
+  BUILD_SPHINX_PDF  Whether to build Sphinx PDF documentation.
+  INTEGER_LIBRARY   Which integer library to use (integer-simple or integer-gmp).
+  HADDOCK_HYPERLINKED_SOURCES
+                    Whether to build hyperlinked Haddock sources.
+  TEST_TYPE         Which test rule to run.
+
+Environment variables determining build configuration of Hadrian system:
+
+  FLAVOUR       Which build flavour to build.
+
+Environment variables determining bootstrap toolchain (Linux):
+
+  GHC           Path of GHC executable to use for bootstrapping.
+  CABAL         Path of cabal-install executable to use for bootstrapping.
+  ALEX          Path of alex executable to use for bootstrapping.
+  HAPPY         Path of alex executable to use for bootstrapping.
+
+Environment variables determining bootstrap toolchain (non-Linux):
+
+  GHC_VERSION   Which GHC version to fetch for bootstrapping.
+  CABAL_INSTALL_VERSION
+                Cabal-install version to fetch for bootstrapping.
+EOF
+}
+
 function mingw_init() {
   case "$MSYSTEM" in
     MINGW32)
-      triple="i386-unknown-mingw32"
+      target_triple="i386-unknown-mingw32"
       boot_triple="i386-unknown-mingw32" # triple of bootstrap GHC
       ;;
     MINGW64)
-      triple="x86_64-unknown-mingw32"
+      target_triple="x86_64-unknown-mingw32"
       boot_triple="x86_64-unknown-mingw32" # triple of bootstrap GHC
       ;;
     *)
@@ -324,8 +376,8 @@ function configure() {
   end_section "booting"
 
   local target_args=""
-  if [[ -n "$triple" ]]; then
-    target_args="--target=$triple"
+  if [[ -n "$target_triple" ]]; then
+    target_args="--target=$target_triple"
   fi
 
   start_section "configuring"
@@ -364,6 +416,11 @@ function push_perf_notes() {
 }
 
 function test_make() {
+  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 \
     THREADS="$cores" \
@@ -381,6 +438,11 @@ function build_hadrian() {
 }
 
 function test_hadrian() {
+  if [ -n "$CROSS_TARGET" ]; then
+    info "Can't test cross-compiled build."
+    return
+  fi
+
   cd _build/bindist/ghc-*/
   run ./configure --prefix="$TOP"/_build/install
   run "$MAKE" install
@@ -435,9 +497,15 @@ case "$(uname)" in
   *) fail "uname $(uname) is not supported" ;;
 esac
 
+if [ -n "$CROSS_TARGET" ]; then
+  info "Cross-compiling for $CROSS_TARGET..."
+  target_triple="$CROSS_TARGET"
+fi
+
 set_toolchain_paths
 
 case $1 in
+  usage) usage ;;
   setup) setup && cleanup_submodules ;;
   configure) configure ;;
   build_make) build_make ;;


=====================================
hadrian/src/Rules/BinaryDist.hs
=====================================
@@ -5,6 +5,7 @@ import Hadrian.Haskell.Cabal
 import Context
 import Expression
 import Oracles.Setting
+import Oracles.Flag
 import Packages
 import Settings
 import Settings.Program (programContext)
@@ -101,8 +102,9 @@ bindistRules = do
     phony "binary-dist-dir" $ do
         -- We 'need' all binaries and libraries
         targets <- mapM pkgTarget =<< stagePackages Stage1
+        cross <- flag CrossCompiling
         need targets
-        needIservBins
+        unless cross $ needIservBins
 
         version        <- setting ProjectVersion
         targetPlatform <- setting TargetPlatformFull
@@ -121,7 +123,7 @@ bindistRules = do
         copyDirectory (ghcBuildDir -/- "bin") bindistFilesDir
         copyDirectory (ghcBuildDir -/- "lib") bindistFilesDir
         copyDirectory (rtsIncludeDir)         bindistFilesDir
-        need ["docs"]
+        unless cross $ need ["docs"]
         -- TODO: we should only embed the docs that have been generated
         -- depending on the current settings (flavours' "ghcDocs" field and
         -- "--docs=.." command-line flag)
@@ -138,9 +140,10 @@ bindistRules = do
 
         -- We copy the binary (<build root>/stage1/bin/haddock[.exe]) to
         -- the bindist's bindir (<build root>/bindist/ghc-.../bin/).
-        haddockPath <- programPath (vanillaContext Stage1 haddock)
-        copyFile haddockPath
-                 (bindistFilesDir -/- "bin" -/- takeFileName haddockPath)
+        unless cross $ do
+          haddockPath <- programPath (vanillaContext Stage1 haddock)
+          copyFile haddockPath
+                   (bindistFilesDir -/- "bin" -/- takeFileName haddockPath)
 
         -- We then 'need' all the files necessary to configure and install
         -- (as in, './configure [...] && make install') this build on some



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6d2b964c01912b39d352b0e4421981ae449629a5...21cb2c3df1cb5857aebd0f5ba69c7f0e19eb1419

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6d2b964c01912b39d352b0e4421981ae449629a5...21cb2c3df1cb5857aebd0f5ba69c7f0e19eb1419
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200529/a9603b4a/attachment-0001.html>


More information about the ghc-commits mailing list