[Git][ghc/ghc][wip/T25974] 2 commits: Rewrite `fetch_cabal` in same fashion as `fetch_ghc`, introduce...

Serge S. Gulin pushed to branch wip/T25974 at Glasgow Haskell Compiler / GHC Commits: df8f9c89 by Serge S. Gulin at 2025-05-16T12:59:48+04:00 Rewrite `fetch_cabal` in same fashion as `fetch_ghc`, introduce `cross_target_exe` suffix for cross-compile windows builds - - - - - acbfc775 by Serge S. Gulin at 2025-05-19T12:52:39+03:00 Manually pass "WindresCmd" from parent process to child to fix MSYS2 behaviour at Wine - - - - - 2 changed files: - .gitlab/ci.sh - hadrian/src/Rules/BinaryDist.hs Changes: ===================================== .gitlab/ci.sh ===================================== @@ -349,47 +349,45 @@ function fetch_ghc() { } function fetch_cabal() { - if [ ! -e "$CABAL" ]; then - local v="$CABAL_INSTALL_VERSION" - if [[ -z "$v" ]]; then - fail "neither CABAL nor CABAL_INSTALL_VERSION are not set" - fi + local v="$CABAL_INSTALL_VERSION" + if [[ -z "$v" ]]; then + fail "neither CABAL nor CABAL_INSTALL_VERSION are not set" + fi - start_section "fetch cabal" + start_section "fetch cabal" + case "$(uname)" in + # N.B. Windows uses zip whereas all others use .tar.xz + MSYS_*|MINGW*) + case "$MSYSTEM" in + CLANG64) cabal_arch="x86_64" ;; + *) fail "unknown MSYSTEM $MSYSTEM" ;; + esac + url="https://downloads.haskell.org/~cabal/cabal-install-$v/cabal-install-$v-$caba..." + info "Fetching cabal binary distribution from $url..." + curl "$url" > "$TMP/cabal.zip" + unzip "$TMP/cabal.zip" + mv cabal.exe "$CABAL" + ;; + *) + local base_url="https://downloads.haskell.org/~cabal/cabal-install-$v/" case "$(uname)" in - # N.B. Windows uses zip whereas all others use .tar.xz - MSYS_*|MINGW*) - case "$MSYSTEM" in - CLANG64) cabal_arch="x86_64" ;; - *) fail "unknown MSYSTEM $MSYSTEM" ;; - esac - url="https://downloads.haskell.org/~cabal/cabal-install-$v/cabal-install-$v-$caba..." - info "Fetching cabal binary distribution from $url..." - curl "$url" > "$TMP/cabal.zip" - unzip "$TMP/cabal.zip" - mv cabal.exe "$CABAL" - ;; - *) - local base_url="https://downloads.haskell.org/~cabal/cabal-install-$v/" - case "$(uname)" in - Darwin) cabal_url="$base_url/cabal-install-$v-x86_64-apple-darwin17.7.0.tar.xz" ;; - FreeBSD) cabal_url="$base_url/cabal-install-$v-x86_64-freebsd14.tar.xz" ;; - *) fail "don't know where to fetch cabal-install for $(uname)" - esac - echo "Fetching cabal-install from $cabal_url" - curl "$cabal_url" > cabal.tar.xz - tmp="$(tar -tJf cabal.tar.xz | head -n1)" - $TAR -xJf cabal.tar.xz - # Check if the bindist has directory structure - if [[ "$tmp" = "cabal" ]]; then - mv cabal "$toolchain/bin" - else - mv "$tmp/cabal" "$toolchain/bin" - fi - ;; + Darwin) cabal_url="$base_url/cabal-install-$v-x86_64-apple-darwin17.7.0.tar.xz" ;; + FreeBSD) cabal_url="$base_url/cabal-install-$v-x86_64-freebsd14.tar.xz" ;; + *) fail "don't know where to fetch cabal-install for $(uname)" esac - end_section "fetch cabal" - fi + echo "Fetching cabal-install from $cabal_url" + curl "$cabal_url" > cabal.tar.xz + tmp="$(tar -tJf cabal.tar.xz | head -n1)" + $TAR -xJf cabal.tar.xz + # Check if the bindist has directory structure + if [[ "$tmp" = "cabal" ]]; then + mv cabal "$toolchain/bin" + else + mv "$tmp/cabal" "$toolchain/bin" + fi + ;; + esac + end_section "fetch cabal" } # For non-Docker platforms we prepare the bootstrap toolchain @@ -397,10 +395,13 @@ function fetch_cabal() { # build. function setup_toolchain() { if [ ! -e "$GHC" ]; then - fetch_ghc + fetch_ghc + fi + + if [ ! -e "$CABAL" ]; then + fetch_cabal fi - fetch_cabal cabal_update local cabal_install="$CABAL v2-install \ @@ -723,11 +724,14 @@ function test_hadrian() { echo 'main = putStrLn "hello world"' > expected run "$test_compiler" -package ghc "$TOP/.gitlab/hello.hs" -v -o hello + # If build is targeted to Windows/MinGW we should use .exe suffix to test cross compiler output + local cross_target_exe="" if [[ "${CROSS_TARGET:-no_cross_target}" =~ "mingw" ]]; then - ${CROSS_EMULATOR:-} ./hello.exe > actual - else - ${CROSS_EMULATOR:-} ./hello > actual + cross_target_exe=".exe" fi + readonly cross_target_exe + + ${CROSS_EMULATOR:-} ./hello${cross_target_exe} > actual # We have to use `-w` to make the test more stable across supported # platforms, i.e. Windows: ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -9,6 +9,7 @@ import Oracles.Flag import Packages import Settings import Settings.Program (programContext) +import System.Environment (lookupEnv) import Target import Utilities import qualified System.Directory.Extra as IO @@ -120,7 +121,14 @@ installTo relocatable prefix = do let disabledMerge = if win then ["MergeObjsCmd="] else [] - runBuilder (Configure bindistFilesDir) (["--prefix="++prefix] ++ disabledMerge) [] [] + + env_windres_cmd_m <- liftIO $ lookupEnv "WindresCmd" + runBuilderWithCmdOptions + -- By unknown reason when MSYS2 environment is used under Wine it does not + -- pass non-CAPS environment variables to child processes, so + -- "WINDRESCMD" would be fine, but "WindresCmd" requires manual attention. + (maybe mempty (pure . AddEnv "WindresCmd") env_windres_cmd_m) + (Configure bindistFilesDir) (["--prefix="++prefix] ++ disabledMerge) [] [] let env = case relocatable of Relocatable -> [AddEnv "RelocatableBuild" "YES"] NotRelocatable -> [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/caa9b692569eb03a2a4d1e4ae990cbc... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/caa9b692569eb03a2a4d1e4ae990cbc... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Serge S. Gulin (@gulin.serge)