[Git][ghc/ghc][wip/T25974] 7 commits: Add Wine support

Serge S. Gulin pushed to branch wip/T25974 at Glasgow Haskell Compiler / GHC Commits: eea552e1 by Serge S. Gulin at 2025-05-07T10:14:07+03:00 Add Wine support - - - - - b4c53dd8 by Serge S. Gulin at 2025-05-08T16:58:40+04:00 Test build wine! - - - - - 3ccf3c01 by Serge S. Gulin at 2025-05-09T15:41:07+04:00 Put updated clang toolchain into bootstrap compiler's `mingw` folder - - - - - a21cee90 by Serge S. Gulin at 2025-05-10T00:10:20+04:00 Enable tests for cross-compiled compiler - - - - - b347c867 by Serge S. Gulin at 2025-05-10T01:42:34+04:00 Update DOCKER_REV - - - - - 0c7c5407 by Serge S. Gulin at 2025-05-10T18:01:43+04:00 Copy mingw from boostrap compiler - - - - - 34b1810d by Serge S. Gulin at 2025-05-11T22:18:07+04:00 Remove CROSS_EMULATOR because we are already in Wine, fix `check_msys2_deps` to support cross-target at Windows - - - - - 12 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - boot - configure.ac - hadrian/src/Builder.hs - hadrian/src/Rules/BinaryDist.hs - libraries/ghc-internal/src/GHC/Internal/Event/Windows.hsc - m4/find_merge_objects.m4 - m4/fp_setup_windows_toolchain.m4 Changes: ===================================== .gitignore ===================================== @@ -256,3 +256,6 @@ ghc.nix/ # clangd .clangd dist-newstyle/ + +# .gitlab/ci.sh for HERMETIC=1 +cabal/* ===================================== .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: 6e9f8f17086e56e83adae4a8a9d63e2fec3cb6c7 + DOCKER_REV: 719761ba598220b9576f82aab39e442cc1a1cf1f # Sequential version number of all cached things. # Bump to invalidate GitLab CI cache. ===================================== .gitlab/ci.sh ===================================== @@ -75,6 +75,15 @@ Environment variables affecting both build systems: NIX_SYSTEM On Darwin, the target platform of the desired toolchain (either "x86-64-darwin" or "aarch-darwin") NO_BOOT Whether to run ./boot or not, used when testing the source dist + TOOLCHAIN_SOURCE Select a source of toolchain. Possible values: + - "env": Toolchains are included in the Docker image via environment + variables. Default for Linux. + - "nix": Toolchains are provided via .gitlab/darwin/toolchain.nix. + Default for Darwin. + - "extracted": + Toolchains will be downloaded and extracted through the + CI process. Default for other systems. Windows and FreeBSD + are included. Environment variables determining build configuration of Hadrian system: @@ -83,14 +92,14 @@ Environment variables determining build configuration of Hadrian system: This tests the "reinstall" configuration CROSS_EMULATOR The emulator to use for testing of cross-compilers. -Environment variables determining bootstrap toolchain (Linux): +Environment variables determining bootstrap toolchain (TOOLCHAIN_SOURCE=env): 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): +Environment variables determining bootstrap toolchain (TOOLCHAIN_SOURCE=extracted): GHC_VERSION Which GHC version to fetch for bootstrapping. CABAL_INSTALL_VERSION @@ -135,7 +144,9 @@ function mingw_init() { case "$MSYSTEM" in CLANG64) target_triple="x86_64-unknown-mingw32" - boot_triple="x86_64-unknown-mingw32" # triple of bootstrap GHC + ;; + CLANGARM64) + target_triple="aarch64-unknown-mingw32" ;; *) fail "win32-init: Unknown MSYSTEM $MSYSTEM" @@ -150,10 +161,19 @@ function mingw_init() { MINGW_MOUNT_POINT="${MINGW_PREFIX}" PATH="$MINGW_MOUNT_POINT/bin:$PATH" - # We always use mingw64 Python to avoid path length issues like #17483. - export PYTHON="/mingw64/bin/python3" - # And need to use sphinx-build from the environment - export SPHINXBUILD="/mingw64/bin/sphinx-build.exe" + case "$MSYSTEM" in + CLANGARM64) + # At MSYS for ARM64 we force to use their special versions to speedup the compiler step + export PYTHON="/clangarm64/bin/python3" + export SPHINXBUILD="/clangarm64/bin/sphinx-build.exe" + ;; + *) + # We always use mingw64 Python to avoid path length issues like #17483. + export PYTHON="/mingw64/bin/python3" + # And need to use sphinx-build from the environment + export SPHINXBUILD="/mingw64/bin/sphinx-build.exe" + ;; + esac } # This will contain GHC's local native toolchain @@ -178,15 +198,21 @@ function show_tool() { } function set_toolchain_paths() { - case "$(uname -m)-$(uname)" in - # Linux toolchains are included in the Docker image - *-Linux) toolchain_source="env" ;; - # Darwin toolchains are provided via .gitlab/darwin/toolchain.nix - *-Darwin) toolchain_source="nix" ;; - *) toolchain_source="extracted" ;; - esac + if [ -z "${TOOLCHAIN_SOURCE:-}" ] + then + # Fallback to automatic detection which could not work for cases + # when cross compiler will be build at Windows environment + # and requires a special mingw compiler (not bundled) + case "$(uname -m)-$(uname)" in + # Linux toolchains are included in the Docker image + *-Linux) TOOLCHAIN_SOURCE="env" ;; + # Darwin toolchains are provided via .gitlab/darwin/toolchain.nix + *-Darwin) TOOLCHAIN_SOURCE="nix" ;; + *) TOOLCHAIN_SOURCE="extracted" ;; + esac + fi - case "$toolchain_source" in + case "$TOOLCHAIN_SOURCE" in extracted) # These are populated by setup_toolchain GHC="$toolchain/bin/ghc$exe" @@ -217,7 +243,7 @@ function set_toolchain_paths() { : ${HAPPY:=$(which happy)} : ${ALEX:=$(which alex)} ;; - *) fail "bad toolchain_source" + *) fail "bad TOOLCHAIN_SOURCE" esac export GHC @@ -247,7 +273,7 @@ function setup() { cp -Rf "$CABAL_CACHE"/* "$CABAL_DIR" fi - case $toolchain_source in + case $TOOLCHAIN_SOURCE in extracted) time_it "setup" setup_toolchain ;; *) ;; esac @@ -273,14 +299,37 @@ function setup() { } function fetch_ghc() { - if [ ! -e "$GHC" ]; then - local v="$GHC_VERSION" + local boot_triple_to_fetch + case "$(uname)" in + MSYS_*|MINGW*) + case "$MSYSTEM" in + CLANG64) + boot_triple_to_fetch="x86_64-unknown-mingw32" # triple of bootstrap GHC + ;; + *) + fail "win32-init: Unknown MSYSTEM $MSYSTEM" + ;; + esac + ;; + Darwin) + boot_triple_to_fetch="x86_64-apple-darwin" + ;; + FreeBSD) + boot_triple_to_fetch="x86_64-portbld-freebsd" + ;; + Linux) + ;; + *) fail "uname $(uname) is not supported by ghc boot fetch" ;; + esac + readonly boot_triple_to_fetch + + local -r v="$GHC_VERSION" if [[ -z "$v" ]]; then fail "neither GHC nor GHC_VERSION are not set" fi start_section "fetch GHC" - url="https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-${boot_triple}.tar.xz" + url="https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-${boot_triple_to_fetch}.tar.xz" info "Fetching GHC binary distribution from $url..." curl "$url" > ghc.tar.xz || fail "failed to fetch GHC binary distribution" $TAR -xJf ghc.tar.xz || fail "failed to extract GHC binary distribution" @@ -297,8 +346,6 @@ function fetch_ghc() { esac rm -Rf "ghc-${GHC_VERSION}" ghc.tar.xz end_section "fetch GHC" - fi - } function fetch_cabal() { @@ -349,7 +396,10 @@ function fetch_cabal() { # here. For Docker platforms this is done in the Docker image # build. function setup_toolchain() { + if [ ! -e "$GHC" ]; then fetch_ghc + fi + fetch_cabal cabal_update @@ -405,6 +455,17 @@ function configure() { if [[ -n "${target_triple:-}" ]]; then args+=("--target=$target_triple") fi + if [[ "${TOOLCHAIN_SOURCE:-}" =~ "extracted" ]]; then + # To extract something need download something first. + args+=("--enable-tarballs-autodownload") + else + # For Windows we should explicitly --enable-distro-toolchain + # if i.e. we decided to use TOOLCHAIN_SOURCE = env + case "$(uname)" in + MSYS_*|MINGW*) args+=("--enable-distro-toolchain") ;; + *) ;; + esac + fi if [[ -n "${ENABLE_NUMA:-}" ]]; then args+=("--enable-numa") else @@ -421,7 +482,6 @@ function configure() { # See https://stackoverflow.com/questions/7577052 for a rationale for the # args[@] symbol-soup below. run ${CONFIGURE_WRAPPER:-} ./configure \ - --enable-tarballs-autodownload \ "${args[@]+"${args[@]}"}" \ GHC="$GHC" \ || ( cat config.log; fail "configure failed" ) @@ -562,12 +622,35 @@ function install_bindist() { read -r -a args <<< "${INSTALL_CONFIGURE_ARGS:-}" if [[ "${CROSS_TARGET:-no_cross_target}" =~ "mingw" ]]; then - # We suppose that host target = build target. + # We assume that BUILD=HOST. # By the fact above it is clearly turning out which host value is # for currently built compiler. # The fix for #21970 will probably remove this if-branch. - local -r CROSS_HOST_GUESS=$($SHELL ./config.guess) - args+=( "--target=$CROSS_TARGET" "--host=$CROSS_HOST_GUESS" ) + # Modifications are needed due of reasons like See Note [Wide Triple Windows]. + + local -r cross_host_triple_guess_origin=$($SHELL ./config.guess) + + # We expect here to have (x86_64|aarch64) + local -r cross_host_triple_guess_arch=$(echo "${cross_host_triple_guess_origin}" | cut -d'-' -f1) + + # Expect to have (apple|unknown) + local -r cross_host_triple_guess_vendor=$(echo "${cross_host_triple_guess_origin}" \ + `# "pc" should be converted to unknown for all supported platforms by GHC` \ + | sed -e "s/-pc-/-unknown-/" | cut -d'-' -f2) + + # 3,4 because it might contain a dash, expect to have (linux-gnu|mingw32|darwin) + local -r cross_host_triple_guess_os=$(echo "${cross_host_triple_guess_origin}" | cut -d'-' -f3,4 \ + `# GHC treats mingw64 as mingw32, so, we need hide this difference` \ + | sed -e "s/mingw.*/mingw32/" \ + `# config.guess may return triple with a release number, i.e. for darwin: aarch64-apple-darwin24.4.0` \ + | sed -e "s/darwin.*/darwin/" \ + | sed -e "s/freebsd.*/freebsd/" \ + ) + + local -r cross_host_triple_guess="$cross_host_triple_guess_arch-$cross_host_triple_guess_vendor-$cross_host_triple_guess_os" + echo "Convert guessed triple ${cross_host_triple_guess_origin} to GHC-compatible: ${cross_host_triple_guess}" + + args+=( "--target=$CROSS_TARGET" "--host=$cross_host_triple_guess" ) # FIXME: The bindist configure script shouldn't need to be reminded of # the target platform. See #21970. @@ -587,7 +670,7 @@ function install_bindist() { } function test_hadrian() { - check_msys2_deps _build/stage1/bin/ghc --version + check_msys2_deps "_build/stage1/bin/${cross_prefix}ghc$exe" --version check_release_build # Ensure that statically-linked builds are actually static @@ -946,10 +1029,12 @@ esac MAKE="make" TAR="tar" case "$(uname)" in - MSYS_*|MINGW*) mingw_init ;; - Darwin) boot_triple="x86_64-apple-darwin" ;; + MSYS_*|MINGW*) + mingw_init + ;; + Darwin) + ;; FreeBSD) - boot_triple="x86_64-portbld-freebsd" MAKE="gmake" TAR="gtar" ;; ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -110,9 +110,19 @@ data Opsys | FreeBSD14 | Windows deriving (Eq) +data WineMode + = OnlyTest + -- ^ Wine will be used only to test binaries after cross-compile + -- which means we do cross-compile from Linux to Windows + | FullBuild + -- ^ Wine will be used for full process of compilation + -- which means compilation itself will be executed under Wine. + -- It makes possible to run compilation for Windows environment at Linux machines. + deriving (Eq) + data LinuxDistro = Debian12 - | Debian12Wine + | Debian12Wine WineMode | Debian12Riscv | Debian11 | Debian11Js @@ -316,7 +326,7 @@ distroName Debian12 = "deb12" distroName Debian11 = "deb11" distroName Debian11Js = "deb11-emsdk-closure" distroName Debian12Riscv = "deb12-riscv" -distroName Debian12Wine = "deb12-wine" +distroName (Debian12Wine _) = "deb12-wine" distroName Debian10 = "deb10" distroName Debian9 = "deb9" distroName Fedora33 = "fedora33" @@ -360,6 +370,7 @@ testEnv arch opsys bc = , ["no_tntc" | not (tablesNextToCode bc) ] , ["cross_"++triple | Just triple <- pure $ crossTarget bc ] , [flavourString (mkJobFlavour bc)] + , if opsys == Linux (Debian12Wine FullBuild) then ["_wine_full_build"] else [] ] -- | The hadrian flavour string we are going to use for this build @@ -728,6 +739,7 @@ data ValidateRule | I386Backend -- ^ Run this job when the "i386" label is set | WinArm64 -- ^ Run this job when the "aarch64" and "Windows" labels are set together without "LLVM backend" | WinArm64LLVM -- ^ Run this job when the "aarch64" and "Windows" labels are set together with "LLVM backend" + | WineArm64 -- ^ Run this job when the "aarch64" and "Wine" labels are set deriving (Show, Ord, Eq) -- | Convert the state of the rule into a string that gitlab understand. @@ -781,6 +793,10 @@ validateRuleString WinArm64LLVM = and_all , labelString "Windows" , validateRuleString LLVMBackend ] +validateRuleString WineArm64 = and_all + [ labelString "aarch64" + , labelString "Wine" + ] --------------------------------------------------------------------- -- The Job type @@ -847,6 +863,19 @@ job arch opsys buildConfig = NamedJob { name = jobName, jobInfo = Job {..} } , "bash .gitlab/ci.sh build_hadrian" , "bash .gitlab/ci.sh test_hadrian" ] + | Linux (Debian12Wine FullBuild) <- opsys + = [ "sudo chown ghc:ghc -R ." + , "/opt/wine-arm64ec-msys2-deb12/bin/wine c:/msys64/usr/bin/bash.exe -l .gitlab/ci.sh setup" + , "/opt/wine-arm64ec-msys2-deb12/bin/wine c:/msys64/usr/bin/bash.exe -l .gitlab/ci.sh configure" + -- We have to trigger cabal build in an independent way to mitigate Wine hangs at MSYS2/Arm64EC + , "/opt/wine-arm64ec-msys2-deb12/bin/wine c:/msys64/usr/bin/bash.exe -l -c './hadrian/build-cabal clean'" + -- We use "--enable-distro-toolchain" due of TOOLCHAIN_SOURCE="env", so we have to manually copy + -- bootstrap's compiler mingw into `_build` because binary-dist-dir requires it at Windows. + -- After './hadrian/build-cabal clean' we have to recreate the build root directory. + , "mkdir ./_build && cp -r ~/.wine/drive_c/msys64/opt/ghc-bootstrap/mingw ./_build/" + , "/opt/wine-arm64ec-msys2-deb12/bin/wine c:/msys64/usr/bin/bash.exe -l .gitlab/ci.sh build_hadrian" + , "/opt/wine-arm64ec-msys2-deb12/bin/wine c:/msys64/usr/bin/bash.exe -l .gitlab/ci.sh test_hadrian" + ] | otherwise = [ "find libraries -name config.sub -exec cp config.sub {} \\;" | Darwin == opsys ] ++ [ "sudo chown ghc:ghc -R ." | Linux {} <- [opsys]] ++ @@ -897,6 +926,10 @@ job arch opsys buildConfig = NamedJob { name = jobName, jobInfo = Job {..} } ] in "RUNTEST_ARGS" =: unwords runtestArgs , if testsuiteUsePerf buildConfig then "RUNTEST_ARGS" =: "--config perf_path=perf" else mempty + -- TODO: move me to an appropriate way + , if crossTarget buildConfig == Just "aarch64-unknown-mingw32" && opsys == Linux (Debian12Wine FullBuild) + then "CONFIGURE_ARGS" =: "--build=x86_64-unknown-mingw32 --host=x86_64-unknown-mingw32" + else mempty ] jobArtifacts = Artifacts @@ -1277,47 +1310,76 @@ cross_jobs = [ -- Linux Aarch64 (Wine + FEX + MSYS64) => Windows Aarch64 , makeWinArmJobs $ addValidateRule WinArm64 - (validateBuilds AArch64 (Linux Debian12Wine) winAarch64Config) + (validateBuilds AArch64 (Linux (Debian12Wine OnlyTest)) winAarch64Config) , makeWinArmJobs $ addValidateRule WinArm64LLVM - (validateBuilds AArch64 (Linux Debian12Wine) (winAarch64Config {llvmBootstrap = True})) + (validateBuilds AArch64 (Linux (Debian12Wine OnlyTest)) (winAarch64Config {llvmBootstrap = True})) + , makeWineArmJobs + $ addValidateRule WineArm64 + (validateBuilds AArch64 (Linux (Debian12Wine FullBuild)) wineAarch64Config) ] where javascriptConfig = (crossConfig "javascript-unknown-ghcjs" (Emulator "js-emulator") (Just "emconfigure")) { bignumBackend = Native } - makeWinArmJobs = modifyJobs - ( -- Cross compiler validate does not need any docs - setVariable "HADRIAN_ARGS" "--docs=none" - . setVariable "AR" (llvm_prefix ++ "llvm-ar") - . setVariable "CC" (llvm_prefix ++ "clang") - . setVariable "CXX" (llvm_prefix ++ "clang++") - . setVariable "NM" (llvm_prefix ++ "nm") - . setVariable "OBJCOPY" (llvm_prefix ++ "objcopy") - . setVariable "OBJDUMP" (llvm_prefix ++ "objdump") - . setVariable "RANLIB" (llvm_prefix ++ "llvm-ranlib") - . setVariable "SIZE" (llvm_prefix ++ "size") - . setVariable "STRINGS" (llvm_prefix ++ "strings") - . setVariable "STRIP" (llvm_prefix ++ "strip") - . setVariable "WindresCmd" (llvm_prefix ++ "windres") - . setVariable "LLVMAS" (llvm_prefix ++ "clang") - . setVariable "LD" (llvm_prefix ++ "ld") - -- Windows target require to make linker merge feature check disabled. - . setVariable "MergeObjsCmd" "" - -- LLVM MinGW Linux Toolchain expects to recieve "aarch64-w64-mingw32" - -- as a triple but we use more common "aarch64-unknown-mingw32". - -- Due of this we need configure ld manually for clang beacause - -- it will use system's ld otherwise when --target will be specified to - -- unexpected triple. - . setVariable "CFLAGS" cflags - . setVariable "CONF_CC_OPTS_STAGE2" cflags - ) where - llvm_prefix = "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-" - cflags = "-fuse-ld=" ++ llvm_prefix ++ "ld --rtlib=compiler-rt" + addWindowsCrossArmVars llvm_prefix exe_suffix cflags = modifyJobs + ( -- Cross compiler validate does not need any docs + setVariable "HADRIAN_ARGS" "--docs=none" + . setVariable "AR" (llvm_prefix ++ "llvm-ar" ++ exe_suffix) + . setVariable "CC" (llvm_prefix ++ "clang") + . setVariable "CXX" (llvm_prefix ++ "clang++") + . setVariable "NM" (llvm_prefix ++ "nm" ++ exe_suffix) + . setVariable "OBJCOPY" (llvm_prefix ++ "objcopy") + . setVariable "OBJDUMP" (llvm_prefix ++ "objdump") + . setVariable "RANLIB" (llvm_prefix ++ "llvm-ranlib" ++ exe_suffix) + . setVariable "SIZE" (llvm_prefix ++ "size") + . setVariable "STRINGS" (llvm_prefix ++ "strings") + . setVariable "STRIP" (llvm_prefix ++ "strip") + . setVariable "WindresCmd" (llvm_prefix ++ "windres") + . setVariable "LLVMAS" (llvm_prefix ++ "clang") + . setVariable "LD" (llvm_prefix ++ "ld") + -- See Note [Empty MergeObjsCmd] + -- Windows target require to make linker merge feature check disabled. + . setVariable "MergeObjsCmd" "" + -- Note [Wide Triple Windows] + -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + -- LLVM MinGW Linux Toolchain expects to recieve "aarch64-w64-mingw32" + -- as a triple but we use more common "aarch64-unknown-mingw32". + -- Due of this we need configure ld manually for clang because + -- it will use system's ld otherwise when --target will be specified to + -- unexpected triple. + . setVariable "CFLAGS" cflags + . setVariable "CONF_CC_OPTS_STAGE2" cflags + ) + + makeWinArmJobs = + let + llvm_prefix = "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-" + -- See Note [Windows Toolchain Standard Library Options] + cflags = "-fuse-ld=" ++ llvm_prefix ++ "ld --rtlib=compiler-rt" + in addWindowsCrossArmVars llvm_prefix "" cflags winAarch64Config = (crossConfig "aarch64-unknown-mingw32" (Emulator "/opt/wine-arm64ec-msys2-deb12/bin/wine") Nothing) { bignumBackend = Native } + wineAarch64Config = (crossConfig "aarch64-unknown-mingw32" NoEmulatorNeeded Nothing) + { bignumBackend = Native } + + makeWineArmJobs = + let + llvm_path = "C:/msys64/opt/ghc-bootstrap/mingw/bin" + llvm_prefix = llvm_path ++ "/aarch64-w64-mingw32-" + exe_suffix = ".exe" + -- See Note [Windows Toolchain Standard Library Options] + cflags = "-fuse-ld=" ++ llvm_path ++ "/ld.lld --rtlib=compiler-rt -D_UCRT" + in modifyJobs + ( setVariable "TOOLCHAIN_SOURCE" "env" + . setVariable "DLLTOOL" (llvm_path ++ "/dlltool" ++ exe_suffix) + . setVariable "CC_STAGE0" (llvm_path ++ "/x86_64-w64-mingw32-clang") + . setVariable "CONF_CC_OPTS_STAGE0" ("--target=x86_64-unknown-mingw32 " ++ cflags) + . setVariable "CONF_CC_OPTS_STAGE1" cflags + ) . (addWindowsCrossArmVars llvm_prefix exe_suffix cflags) + make_wasm_jobs cfg = modifyJobs ( -- See Note [Testing wasm ghci browser mode] @@ -1377,6 +1439,7 @@ platform_mapping = Map.map go combined_result , "x86_64-windows-validate" , "aarch64-linux-deb12-validate" , "aarch64-linux-deb12-wine-int_native-cross_aarch64-unknown-mingw32-validate" + , "aarch64-linux-deb12-wine-int_native-cross_aarch64-unknown-mingw32-validate-_wine_full_build" , "nightly-x86_64-linux-alpine3_20-wasm-cross_wasm32-wasi-release+host_fully_static+text_simdutf" , "nightly-x86_64-linux-deb11-validate" , "nightly-x86_64-linux-deb12-validate" @@ -1385,6 +1448,7 @@ platform_mapping = Map.map go combined_result , "nightly-aarch64-linux-deb10-validate" , "nightly-aarch64-linux-deb12-validate" , "nightly-aarch64-linux-deb12-wine-int_native-cross_aarch64-unknown-mingw32-validate" + , "nightly-aarch64-linux-deb12-wine-int_native-cross_aarch64-unknown-mingw32-validate-_wine_full_build" , "nightly-x86_64-linux-alpine3_12-validate" , "nightly-x86_64-linux-deb10-validate" , "nightly-x86_64-linux-fedora33-release" ===================================== .gitlab/jobs.yaml ===================================== @@ -477,6 +477,93 @@ "WindresCmd": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-windres" } }, + "aarch64-linux-deb12-wine-int_native-cross_aarch64-unknown-mingw32-validate-_wine_full_build": { + "after_script": [ + ".gitlab/ci.sh save_cache", + ".gitlab/ci.sh save_test_output", + ".gitlab/ci.sh clean", + "cat ci_timings" + ], + "allow_failure": false, + "artifacts": { + "expire_in": "2 weeks", + "paths": [ + "ghc-aarch64-linux-deb12-wine-int_native-cross_aarch64-unknown-mingw32-validate-_wine_full_build.tar.xz", + "junit.xml", + "unexpected-test-output.tar.gz" + ], + "reports": { + "junit": "junit.xml" + }, + "when": "always" + }, + "cache": { + "key": "aarch64-linux-deb12-wine-$CACHE_REV", + "paths": [ + "cabal-cache", + "toolchain" + ] + }, + "dependencies": [], + "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb12-wine:$DOCKER_REV", + "needs": [ + { + "artifacts": false, + "job": "hadrian-ghc-in-ghci" + } + ], + "rules": [ + { + "if": "((($ONLY_JOBS) && ($ONLY_JOBS =~ /.*\\baarch64-linux-deb12-wine-int_native-cross_aarch64-unknown-mingw32-validate-_wine_full_build(\\s|$).*/)) || (($ONLY_JOBS == null) && ((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || (($CI_MERGE_REQUEST_LABELS =~ /.*aarch64.*/) && ($CI_MERGE_REQUEST_LABELS =~ /.*Wine.*/))))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "when": "on_success" + } + ], + "script": [ + "sudo chown ghc:ghc -R .", + "/opt/wine-arm64ec-msys2-deb12/bin/wine c:/msys64/usr/bin/bash.exe -l .gitlab/ci.sh setup", + "/opt/wine-arm64ec-msys2-deb12/bin/wine c:/msys64/usr/bin/bash.exe -l .gitlab/ci.sh configure", + "/opt/wine-arm64ec-msys2-deb12/bin/wine c:/msys64/usr/bin/bash.exe -l -c './hadrian/build-cabal clean'", + "mkdir ./_build && cp -r ~/.wine/drive_c/msys64/opt/ghc-bootstrap/mingw ./_build/", + "/opt/wine-arm64ec-msys2-deb12/bin/wine c:/msys64/usr/bin/bash.exe -l .gitlab/ci.sh build_hadrian", + "/opt/wine-arm64ec-msys2-deb12/bin/wine c:/msys64/usr/bin/bash.exe -l .gitlab/ci.sh test_hadrian" + ], + "stage": "full-build", + "tags": [ + "aarch64-linux" + ], + "variables": { + "AR": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-llvm-ar.exe", + "BIGNUM_BACKEND": "native", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb12-wine-int_native-cross_aarch64-unknown-mingw32-validate-_wine_full_build", + "BUILD_FLAVOUR": "validate", + "CC": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-clang", + "CC_STAGE0": "C:/msys64/opt/ghc-bootstrap/mingw/bin/x86_64-w64-mingw32-clang", + "CFLAGS": "-fuse-ld=C:/msys64/opt/ghc-bootstrap/mingw/bin/ld.lld --rtlib=compiler-rt -D_UCRT", + "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check --build=x86_64-unknown-mingw32 --host=x86_64-unknown-mingw32", + "CONF_CC_OPTS_STAGE0": "--target=x86_64-unknown-mingw32 -fuse-ld=C:/msys64/opt/ghc-bootstrap/mingw/bin/ld.lld --rtlib=compiler-rt -D_UCRT", + "CONF_CC_OPTS_STAGE1": "-fuse-ld=C:/msys64/opt/ghc-bootstrap/mingw/bin/ld.lld --rtlib=compiler-rt -D_UCRT", + "CONF_CC_OPTS_STAGE2": "-fuse-ld=C:/msys64/opt/ghc-bootstrap/mingw/bin/ld.lld --rtlib=compiler-rt -D_UCRT", + "CROSS_TARGET": "aarch64-unknown-mingw32", + "CXX": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-clang++", + "DLLTOOL": "C:/msys64/opt/ghc-bootstrap/mingw/bin/dlltool.exe", + "HADRIAN_ARGS": "--docs=none", + "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "LD": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-ld", + "LLVMAS": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-clang", + "MergeObjsCmd": "", + "NM": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-nm.exe", + "OBJCOPY": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-objcopy", + "OBJDUMP": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-objdump", + "RANLIB": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-llvm-ranlib.exe", + "RUNTEST_ARGS": "", + "SIZE": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-size", + "STRINGS": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-strings", + "STRIP": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-strip", + "TEST_ENV": "aarch64-linux-deb12-wine-int_native-cross_aarch64-unknown-mingw32-validate-_wine_full_build", + "TOOLCHAIN_SOURCE": "env", + "WindresCmd": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-windres" + } + }, "i386-linux-alpine3_20-validate": { "after_script": [ ".gitlab/ci.sh save_cache", @@ -1148,6 +1235,94 @@ "XZ_OPT": "-9" } }, + "nightly-aarch64-linux-deb12-wine-int_native-cross_aarch64-unknown-mingw32-validate-_wine_full_build": { + "after_script": [ + ".gitlab/ci.sh save_cache", + ".gitlab/ci.sh save_test_output", + ".gitlab/ci.sh clean", + "cat ci_timings" + ], + "allow_failure": false, + "artifacts": { + "expire_in": "8 weeks", + "paths": [ + "ghc-aarch64-linux-deb12-wine-int_native-cross_aarch64-unknown-mingw32-validate-_wine_full_build.tar.xz", + "junit.xml", + "unexpected-test-output.tar.gz" + ], + "reports": { + "junit": "junit.xml" + }, + "when": "always" + }, + "cache": { + "key": "aarch64-linux-deb12-wine-$CACHE_REV", + "paths": [ + "cabal-cache", + "toolchain" + ] + }, + "dependencies": [], + "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb12-wine:$DOCKER_REV", + "needs": [ + { + "artifacts": false, + "job": "hadrian-ghc-in-ghci" + } + ], + "rules": [ + { + "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY)", + "when": "on_success" + } + ], + "script": [ + "sudo chown ghc:ghc -R .", + "/opt/wine-arm64ec-msys2-deb12/bin/wine c:/msys64/usr/bin/bash.exe -l .gitlab/ci.sh setup", + "/opt/wine-arm64ec-msys2-deb12/bin/wine c:/msys64/usr/bin/bash.exe -l .gitlab/ci.sh configure", + "/opt/wine-arm64ec-msys2-deb12/bin/wine c:/msys64/usr/bin/bash.exe -l -c './hadrian/build-cabal clean'", + "mkdir ./_build && cp -r ~/.wine/drive_c/msys64/opt/ghc-bootstrap/mingw ./_build/", + "/opt/wine-arm64ec-msys2-deb12/bin/wine c:/msys64/usr/bin/bash.exe -l .gitlab/ci.sh build_hadrian", + "/opt/wine-arm64ec-msys2-deb12/bin/wine c:/msys64/usr/bin/bash.exe -l .gitlab/ci.sh test_hadrian" + ], + "stage": "full-build", + "tags": [ + "aarch64-linux" + ], + "variables": { + "AR": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-llvm-ar.exe", + "BIGNUM_BACKEND": "native", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb12-wine-int_native-cross_aarch64-unknown-mingw32-validate-_wine_full_build", + "BUILD_FLAVOUR": "validate", + "CC": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-clang", + "CC_STAGE0": "C:/msys64/opt/ghc-bootstrap/mingw/bin/x86_64-w64-mingw32-clang", + "CFLAGS": "-fuse-ld=C:/msys64/opt/ghc-bootstrap/mingw/bin/ld.lld --rtlib=compiler-rt -D_UCRT", + "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check --build=x86_64-unknown-mingw32 --host=x86_64-unknown-mingw32", + "CONF_CC_OPTS_STAGE0": "--target=x86_64-unknown-mingw32 -fuse-ld=C:/msys64/opt/ghc-bootstrap/mingw/bin/ld.lld --rtlib=compiler-rt -D_UCRT", + "CONF_CC_OPTS_STAGE1": "-fuse-ld=C:/msys64/opt/ghc-bootstrap/mingw/bin/ld.lld --rtlib=compiler-rt -D_UCRT", + "CONF_CC_OPTS_STAGE2": "-fuse-ld=C:/msys64/opt/ghc-bootstrap/mingw/bin/ld.lld --rtlib=compiler-rt -D_UCRT", + "CROSS_TARGET": "aarch64-unknown-mingw32", + "CXX": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-clang++", + "DLLTOOL": "C:/msys64/opt/ghc-bootstrap/mingw/bin/dlltool.exe", + "HADRIAN_ARGS": "--docs=none", + "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "LD": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-ld", + "LLVMAS": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-clang", + "MergeObjsCmd": "", + "NM": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-nm.exe", + "OBJCOPY": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-objcopy", + "OBJDUMP": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-objdump", + "RANLIB": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-llvm-ranlib.exe", + "RUNTEST_ARGS": "", + "SIZE": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-size", + "STRINGS": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-strings", + "STRIP": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-strip", + "TEST_ENV": "aarch64-linux-deb12-wine-int_native-cross_aarch64-unknown-mingw32-validate-_wine_full_build", + "TOOLCHAIN_SOURCE": "env", + "WindresCmd": "C:/msys64/opt/ghc-bootstrap/mingw/bin/aarch64-w64-mingw32-windres", + "XZ_OPT": "-9" + } + }, "nightly-i386-linux-alpine3_20-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ===================================== boot ===================================== @@ -52,6 +52,8 @@ def autoreconf(): # Run autoreconf on everything that needs it. processes = {} if os.name == 'nt': + # Note [ACLOCAL_PATH for Windows] + # ~~~~~~~~~~~~~~~~~~~~~~~~~ # Get the normalized ACLOCAL_PATH for Windows # This is necessary since on Windows this will be a Windows # path, which autoreconf doesn't know doesn't know how to handle. ===================================== configure.ac ===================================== @@ -658,12 +658,13 @@ GHC_LLVM_TARGET_SET_VAR AC_SUBST(LlvmTarget) dnl ** See whether cc supports --target=<triple> and set -dnl CONF_CC_OPTS_STAGE[012] accordingly. -FP_CC_SUPPORTS_TARGET([$CC_STAGE0], [CONF_CC_OPTS_STAGE0], [CONF_CXX_OPTS_STAGE0]) +dnl CONF_CC_OPTS_STAGE[12] accordingly. FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE1], [CONF_CXX_OPTS_STAGE1]) FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE2], [CONF_CXX_OPTS_STAGE2]) -FP_PROG_CC_LINKER_TARGET([$CC_STAGE0], [CONF_CC_OPTS_STAGE0], [CONF_GCC_LINKER_OPTS_STAGE0]) +# CONF_CC_OPTS_STAGE0 should be left as is because it is already configured +# by bootstrap compiler settings + FP_PROG_CC_LINKER_TARGET([$CC], [CONF_CC_OPTS_STAGE1], [CONF_GCC_LINKER_OPTS_STAGE1]) FP_PROG_CC_LINKER_TARGET([$CC], [CONF_CC_OPTS_STAGE2], [CONF_GCC_LINKER_OPTS_STAGE2]) ===================================== hadrian/src/Builder.hs ===================================== @@ -26,7 +26,7 @@ import Hadrian.Builder.Tar import Hadrian.Oracles.Path import Hadrian.Oracles.TextFile import Hadrian.Utilities -import Oracles.Setting (bashPath, targetStage) +import Oracles.Setting (bashPath, targetStage, isWinHost) import System.Exit import System.IO (stderr) @@ -327,8 +327,14 @@ instance H.Builder Builder where Ar Unpack _ -> cmd' [Cwd output] [path] buildArgs buildOptions Autoreconf dir -> do + isWin <- isWinHost + let aclocal_env = + -- It is generally assumed that you would use MinGW's compilers from within an MSYS shell. + -- See Note [ACLOCAL_PATH for Windows] + if isWin then [AddEnv "ACLOCAL_PATH" "/c/msys64/usr/share/aclocal/"] + else [] bash <- bashPath - cmd' [Cwd dir] [bash, path] buildArgs buildOptions + cmd' (Cwd dir `cons` aclocal_env) [bash, path] buildArgs buildOptions Configure dir -> do -- Inject /bin/bash into `libtool`, instead of /bin/sh, ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -115,7 +115,12 @@ installTo relocatable prefix = do targetPlatform <- setting TargetPlatformFull let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform bindistFilesDir = root -/- "bindist" -/- ghcVersionPretty - runBuilder (Configure bindistFilesDir) ["--prefix="++prefix] [] [] + win <- isWinTarget + -- See Note [Empty MergeObjsCmd] + let disabledMerge = + if win then ["MergeObjsCmd="] + else [] + runBuilder (Configure bindistFilesDir) (["--prefix="++prefix] ++ disabledMerge) [] [] let env = case relocatable of Relocatable -> [AddEnv "RelocatableBuild" "YES"] NotRelocatable -> [] @@ -232,7 +237,7 @@ bindistRules = do -- N.B. the ghc-pkg executable may be prefixed with a target triple -- (c.f. #20267). ghcPkgName <- programName (vanillaContext Stage1 ghcPkg) - cmd_ (bindistFilesDir -/- "bin" -/- ghcPkgName) ["recache"] + cmd_ (bindistFilesDir -/- "bin" -/- ghcPkgName <.> exe) ["recache"] ===================================== libraries/ghc-internal/src/GHC/Internal/Event/Windows.hsc ===================================== @@ -861,7 +861,9 @@ expirationTime mgr us = do -- The 'TimeoutCallback' will not be called more than once. -- -- Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only --- 2147483647 μs, less than 36 minutes. +-- 2147483647 microseconds, less than 36 minutes. +-- We can not use here utf/greek symbol due of: +-- _build/stage1/libraries/ghc-internal/build/GHC/Internal/Event/Windows.hs: commitBuffer: invalid argument (cannot encode character '\206') -- {-# NOINLINE registerTimeout #-} registerTimeout :: Manager -> Int -> TimeoutCallback -> IO TimeoutKey @@ -878,7 +880,9 @@ registerTimeout mgr@Manager{..} uSrelTime cb = do -- This has no effect if the timeout has already fired. -- -- Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only --- 2147483647 μs, less than 36 minutes. +-- 2147483647 microseconds, less than 36 minutes. +-- We can not use here utf/greek symbol due of: +-- _build/stage1/libraries/ghc-internal/build/GHC/Internal/Event/Windows.hs: commitBuffer: invalid argument (cannot encode character '\206') -- updateTimeout :: Manager -> TimeoutKey -> Seconds -> IO () updateTimeout mgr (TK key) relTime = do @@ -980,7 +984,7 @@ step maxDelay mgr@Manager{..} = do -- There are some unusual edge cases you need to deal with. The -- GetQueuedCompletionStatus function blocks a thread until there's -- work for it to do. Based on the return value, the number of bytes - -- and the overlapped structure, there’s a lot of possible "reasons" + -- and the overlapped structure, there's a lot of possible "reasons" -- for the function to have returned. Deciphering all the possible -- cases: -- ===================================== m4/find_merge_objects.m4 ===================================== @@ -33,6 +33,8 @@ AC_DEFUN([FIND_MERGE_OBJECTS],[ fi + # Note [Empty MergeObjsCmd] + # ~~~~~~~~~~~~~~~~~~~~~~~~~ # If MergeObjsCmd="" then we assume that the user is explicitly telling us that # they do not want to configure the MergeObjsCmd, this is particularly important for # the bundled windows toolchain. ===================================== m4/fp_setup_windows_toolchain.m4 ===================================== @@ -85,6 +85,8 @@ AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[ mingw_prefix="$1" mingw_install_prefix="$2" + # Note [Windows Toolchain Standard Library Options] + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Our Windows toolchain is based around Clang and LLD. We use compiler-rt # for the runtime, libc++ and libc++abi for the C++ standard library # implementation, and libunwind for C++ unwinding. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b6c4b6a09389c98c358cf840e1a4915... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b6c4b6a09389c98c358cf840e1a4915... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Serge S. Gulin (@gulin.serge)