[Git][ghc/ghc][master] 3 commits: gitlab-ci: Introduce validation job for aarch64 cross-compilation
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Mon Aug 8 23:39:36 UTC 2022
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
5b26f324 by Ben Gamari at 2022-08-08T19:39:20-04:00
gitlab-ci: Introduce validation job for aarch64 cross-compilation
Begins to address #11958.
- - - - -
e866625c by Ben Gamari at 2022-08-08T19:39:20-04:00
Bump process submodule
- - - - -
ae707762 by Ben Gamari at 2022-08-08T19:39:20-04:00
gitlab-ci: Add basic support for cross-compiler testiing
Here we add a simple qemu-based test for cross-compilers.
- - - - -
5 changed files:
- .gitlab-ci.yml
- .gitlab/ci.sh
- .gitlab/gen_ci.hs
- .gitlab/jobs.yaml
- libraries/process
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: 58d08589371e78829a3279c6f8b1241e155d7f70
+ DOCKER_REV: 9e4c540d9e4972a36291dfdf81f079f37d748890
# Sequential version number of all cached things.
# Bump to invalidate GitLab CI cache.
=====================================
.gitlab/ci.sh
=====================================
@@ -93,6 +93,7 @@ Environment variables determining build configuration of Hadrian system:
BUILD_FLAVOUR Which flavour to build.
REINSTALL_GHC Build and test a reinstalled "stage3" ghc built using cabal-install
This tests the "reinstall" configuration
+ CROSS_EMULATOR The emulator to use for testing of cross-compilers.
Environment variables determining bootstrap toolchain (Linux):
@@ -564,15 +565,38 @@ function make_install_destdir() {
fi
info "merging file tree from $destdir to $instdir"
cp -a "$destdir/$instdir"/* "$instdir"/
- "$instdir"/bin/ghc-pkg recache
+ "$instdir"/bin/${cross_prefix}ghc-pkg recache
}
-function test_hadrian() {
- if [ -n "${CROSS_TARGET:-}" ]; then
- info "Can't test cross-compiled build."
- return
- fi
+# install the binary distribution in directory $1 to $2.
+function install_bindist() {
+ local bindist="$1"
+ local instdir="$2"
+ pushd "$bindist"
+ case "$(uname)" in
+ MSYS_*|MINGW*)
+ mkdir -p "$instdir"
+ cp -a * "$instdir"
+ ;;
+ *)
+ read -r -a args <<< "${INSTALL_CONFIGURE_ARGS:-}"
+
+ # FIXME: The bindist configure script shouldn't need to be reminded of
+ # the target platform. See #21970.
+ if [ -n "${CROSS_TARGET:-}" ]; then
+ args+=( "--target=$CROSS_TARGET" "--host=$CROSS_TARGET" )
+ fi
+ run ./configure \
+ --prefix="$instdir" \
+ "${args[@]+"${args[@]}"}"
+ make_install_destdir "$TOP"/destdir "$instdir"
+ ;;
+ esac
+ popd
+}
+
+function test_hadrian() {
check_msys2_deps _build/stage1/bin/ghc --version
check_release_build
@@ -593,7 +617,21 @@ function test_hadrian() {
fi
- if [[ -n "${REINSTALL_GHC:-}" ]]; then
+ if [ -n "${CROSS_TARGET:-}" ]; then
+ if [ -n "${CROSS_EMULATOR:-}" ]; then
+ local instdir="$TOP/_build/install"
+ local test_compiler="$instdir/bin/${cross_prefix}ghc$exe"
+ install_bindist _build/bindist/ghc-*/ "$instdir"
+ echo 'main = putStrLn "hello world"' > hello.hs
+ echo "hello world" > expected
+ run "$test_compiler" hello.hs
+ $CROSS_EMULATOR ./hello > actual
+ run diff expected actual
+ else
+ info "Cannot test cross-compiled build without CROSS_EMULATOR being set."
+ return
+ fi
+ elif [[ -n "${REINSTALL_GHC:-}" ]]; then
run_hadrian \
test \
--test-root-dirs=testsuite/tests/stage1 \
@@ -602,20 +640,9 @@ function test_hadrian() {
--test-root-dirs=testsuite/tests/typecheck \
"runtest.opts+=${RUNTEST_ARGS:-}" || fail "hadrian cabal-install test"
else
- cd _build/bindist/ghc-*/
- case "$(uname)" in
- MSYS_*|MINGW*)
- mkdir -p "$TOP"/_build/install
- cp -a * "$TOP"/_build/install
- ;;
- *)
- read -r -a args <<< "${INSTALL_CONFIGURE_ARGS:-}"
- run ./configure --prefix="$TOP"/_build/install "${args[@]+"${args[@]}"}"
- make_install_destdir "$TOP"/destdir "$TOP"/_build/install
- ;;
- esac
- cd ../../../
- test_compiler="$TOP/_build/install/bin/ghc$exe"
+ local instdir="$TOP/_build/install"
+ local test_compiler="$instdir/bin/ghc$exe"
+ install_bindist _build/bindist/ghc-*/ "$instdir"
if [[ "${WINDOWS_HOST}" == "no" ]]; then
run_hadrian \
@@ -779,6 +806,9 @@ esac
if [ -n "${CROSS_TARGET:-}" ]; then
info "Cross-compiling for $CROSS_TARGET..."
target_triple="$CROSS_TARGET"
+ cross_prefix="$target_triple-"
+else
+ cross_prefix=""
fi
echo "Branch name ${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:-}"
=====================================
.gitlab/gen_ci.hs
=====================================
@@ -116,6 +116,8 @@ data BuildConfig
, llvmBootstrap :: Bool
, withAssertions :: Bool
, withNuma :: Bool
+ , crossTarget :: Maybe String
+ , crossEmulator :: Maybe String
, fullyStatic :: Bool
, tablesNextToCode :: Bool
, threadSanitiser :: Bool
@@ -126,6 +128,7 @@ configureArgsStr :: BuildConfig -> String
configureArgsStr bc = intercalate " " $
["--enable-unregisterised"| unregisterised bc ]
++ ["--disable-tables-next-to-code" | not (tablesNextToCode bc) ]
+ ++ ["--with-intree-gmp" | Just _ <- pure (crossTarget bc) ]
-- Compute the hadrian flavour from the BuildConfig
mkJobFlavour :: BuildConfig -> Flavour
@@ -156,6 +159,8 @@ vanilla = BuildConfig
, llvmBootstrap = False
, withAssertions = False
, withNuma = False
+ , crossTarget = Nothing
+ , crossEmulator = Nothing
, fullyStatic = False
, tablesNextToCode = True
, threadSanitiser = False
@@ -186,6 +191,14 @@ static = vanilla { fullyStatic = True }
staticNativeInt :: BuildConfig
staticNativeInt = static { bignumBackend = Native }
+crossConfig :: String -- ^ target triple
+ -> Maybe String -- ^ emulator for testing
+ -> BuildConfig
+crossConfig triple emulator =
+ vanilla { crossTarget = Just triple
+ , crossEmulator = emulator
+ }
+
llvm :: BuildConfig
llvm = vanilla { llvmBootstrap = True }
@@ -252,6 +265,7 @@ testEnv arch opsys bc = intercalate "-" $
++ ["unreg" | unregisterised bc ]
++ ["numa" | withNuma bc ]
++ ["no_tntc" | not (tablesNextToCode bc) ]
+ ++ ["cross_"++triple | Just triple <- pure $ crossTarget bc ]
++ [flavourString (mkJobFlavour bc)]
-- | The hadrian flavour string we are going to use for this build
@@ -597,7 +611,8 @@ job arch opsys buildConfig = (jobName, Job {..})
, "BUILD_FLAVOUR" =: flavourString jobFlavour
, "BIGNUM_BACKEND" =: bignumString (bignumBackend buildConfig)
, "CONFIGURE_ARGS" =: configureArgsStr buildConfig
-
+ , maybe M.empty ("CROSS_TARGET" =:) (crossTarget buildConfig)
+ , maybe M.empty ("CROSS_EMULATOR" =:) (crossEmulator buildConfig)
, if withNuma buildConfig then "ENABLE_NUMA" =: "1" else M.empty
]
@@ -774,6 +789,7 @@ jobs = M.fromList $ concatMap flattenJobGroup $
, standardBuilds I386 (Linux Debian9)
, allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) static)
, disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt))
+ , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Just "qemu-aarch64 -L /usr/aarch64-linux-gnu"))
]
where
=====================================
.gitlab/jobs.yaml
=====================================
@@ -1378,6 +1378,67 @@
"XZ_OPT": "-9"
}
},
+ "nightly-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": {
+ "after_script": [
+ ".gitlab/ci.sh save_cache",
+ ".gitlab/ci.sh clean",
+ "cat ci_timings"
+ ],
+ "allow_failure": false,
+ "artifacts": {
+ "expire_in": "8 weeks",
+ "paths": [
+ "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz",
+ "junit.xml"
+ ],
+ "reports": {
+ "junit": "junit.xml"
+ },
+ "when": "always"
+ },
+ "cache": {
+ "key": "x86_64-linux-deb11-$CACHE_REV",
+ "paths": [
+ "cabal-cache",
+ "toolchain"
+ ]
+ },
+ "dependencies": [],
+ "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV",
+ "needs": [
+ {
+ "artifacts": false,
+ "job": "hadrian-ghc-in-ghci"
+ }
+ ],
+ "rules": [
+ {
+ "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")",
+ "when": "on_success"
+ }
+ ],
+ "script": [
+ "sudo chown ghc:ghc -R .",
+ ".gitlab/ci.sh setup",
+ ".gitlab/ci.sh configure",
+ ".gitlab/ci.sh build_hadrian",
+ ".gitlab/ci.sh test_hadrian"
+ ],
+ "stage": "full-build",
+ "tags": [
+ "x86_64-linux"
+ ],
+ "variables": {
+ "BIGNUM_BACKEND": "gmp",
+ "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
+ "BUILD_FLAVOUR": "validate",
+ "CONFIGURE_ARGS": "--with-intree-gmp",
+ "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu",
+ "CROSS_TARGET": "aarch64-linux-gnu",
+ "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
+ "XZ_OPT": "-9"
+ }
+ },
"nightly-x86_64-linux-deb11-validate": {
"after_script": [
".gitlab/ci.sh save_cache",
@@ -3857,6 +3918,66 @@
"TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions"
}
},
+ "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": {
+ "after_script": [
+ ".gitlab/ci.sh save_cache",
+ ".gitlab/ci.sh clean",
+ "cat ci_timings"
+ ],
+ "allow_failure": false,
+ "artifacts": {
+ "expire_in": "2 weeks",
+ "paths": [
+ "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz",
+ "junit.xml"
+ ],
+ "reports": {
+ "junit": "junit.xml"
+ },
+ "when": "always"
+ },
+ "cache": {
+ "key": "x86_64-linux-deb11-$CACHE_REV",
+ "paths": [
+ "cabal-cache",
+ "toolchain"
+ ]
+ },
+ "dependencies": [],
+ "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV",
+ "needs": [
+ {
+ "artifacts": false,
+ "job": "hadrian-ghc-in-ghci"
+ }
+ ],
+ "rules": [
+ {
+ "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")",
+ "when": "on_success"
+ }
+ ],
+ "script": [
+ "sudo chown ghc:ghc -R .",
+ ".gitlab/ci.sh setup",
+ ".gitlab/ci.sh configure",
+ ".gitlab/ci.sh build_hadrian",
+ ".gitlab/ci.sh test_hadrian"
+ ],
+ "stage": "full-build",
+ "tags": [
+ "x86_64-linux"
+ ],
+ "variables": {
+ "BIGNUM_BACKEND": "gmp",
+ "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
+ "BUILD_FLAVOUR": "validate",
+ "CONFIGURE_ARGS": "--with-intree-gmp",
+ "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu",
+ "CROSS_TARGET": "aarch64-linux-gnu",
+ "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate"
+ }
+ },
"x86_64-linux-deb11-validate": {
"after_script": [
".gitlab/ci.sh save_cache",
=====================================
libraries/process
=====================================
@@ -1 +1 @@
-Subproject commit 7a7431a0ef586c0f1e602e382398b988c699dfc2
+Subproject commit b95e5fbdeb74e0cc36b6878b60f9807bd0001fa8
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5765e13370634979eb6a0d9f67aa9afa797bee46...ae707762335dabe2bb7e40639fd2ab2c7d3234fd
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5765e13370634979eb6a0d9f67aa9afa797bee46...ae707762335dabe2bb7e40639fd2ab2c7d3234fd
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/20220808/7e610c97/attachment-0001.html>
More information about the ghc-commits
mailing list