diff --git a/.github/scripts/cross.sh b/.github/scripts/cross.sh index d29024c7..c6bbb808 100644 --- a/.github/scripts/cross.sh +++ b/.github/scripts/cross.sh @@ -1,9 +1,12 @@ #!/usr/bin/env bash -set -eux +set -ex . .github/scripts/common.sh +run() { + "$@" +} if [ "${OS}" = "Windows" ] ; then GHCUP_DIR="${GHCUP_INSTALL_BASE_PREFIX}"/ghcup @@ -39,9 +42,11 @@ cabal --version eghcup debug-info -eghcup -v \ +ecabal update + +"${WRAPPER}" "$GHCUP_BIN/ghcup${ext}" -c -s "file://$CI_PROJECT_DIR/data/metadata/ghcup-${JSON_VERSION}.yaml" -v \ compile ghc \ - $(if [ -n "${HADRIAN_FLAVOUR}" ] ; then printf "%s" "--flavour=${HADRIAN_FLAVOUR}" else true ; fi) \ + $(if [ -n "${HADRIAN_FLAVOUR}" ] ; then printf "%s" "--flavour=${HADRIAN_FLAVOUR}" ; else true ; fi) \ -j "$(nproc)" \ -v "${GHC_TARGET_VERSION}" \ -b "${GHC_VER}" \ diff --git a/.github/workflows/cross.yaml b/.github/workflows/cross.yaml index 017f3aa0..c5403730 100644 --- a/.github/workflows/cross.yaml +++ b/.github/workflows/cross.yaml @@ -74,6 +74,7 @@ jobs: DISTRO: Debian ARTIFACT: "x86_64-linux-ghcup" CROSS: "arm-linux-gnueabihf" + WRAPPER: "run" steps: - name: Checkout code uses: actions/checkout@v3 @@ -95,3 +96,45 @@ jobs: sudo apt-get install -y libncurses-dev:armhf sh .github/scripts/cross.sh + test-cross-js: + name: Test GHC JS cross + needs: "build" + runs-on: [self-hosted, Linux, X64] + container: + image: registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:8d0224e6b2a08157649651e69302380b2bd24e11 + options: --user root + env: + CABAL_VER: 3.6.2.0 + BUILD_CONF_ARGS: "" + HADRIAN_FLAVOUR: "default+native_bignum" + JSON_VERSION: "0.0.7" + GHC_VER: 9.6.2 + GHC_TARGET_VERSION: "9.6.2" + ARCH: 64 + DISTRO: Debian + ARTIFACT: "x86_64-linux-ghcup" + CROSS: "javascript-unknown-ghcjs" + WRAPPER: "emconfigure" + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + submodules: 'true' + + - uses: actions/download-artifact@v3 + with: + name: artifacts + path: ./out + + - name: Run test (64 bit linux) + run: | + sudo apt-get update -y + sudo apt-get install -y libnuma-dev zlib1g-dev libgmp-dev libgmp10 libssl-dev liblzma-dev libbz2-dev git wget lsb-release software-properties-common gnupg2 apt-transport-https gcc autoconf automake build-essential curl gzip + git clone https://github.com/emscripten-core/emsdk.git + cd emsdk + ./emsdk install latest + ./emsdk activate latest + . ./emsdk_env.sh + cd .. + bash .github/scripts/cross.sh + diff --git a/lib/GHCup/GHC.hs b/lib/GHCup/GHC.hs index 42372b9d..26633704 100644 --- a/lib/GHCup/GHC.hs +++ b/lib/GHCup/GHC.hs @@ -1013,8 +1013,8 @@ compileGHC targetGhc crossTarget ov bstrap jobs mbuildConfig patches aargs build => GHCupPath -> Excepts '[ProcessError, ParseError] m Version getGHCVer tmpUnpack = do - lEM $ execWithGhcEnv "python3" ["./boot"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap" - lEM $ execWithGhcEnv "sh" ["./configure"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap" + lEM $ execLogged "python3" ["./boot"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap" Nothing + lEM $ configureWithGhcBoot Nothing [] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap" let versionFile = fromGHCupPath tmpUnpack "VERSION" hasVersionFile <- liftIO $ doesFileExist versionFile if hasVersionFile @@ -1065,12 +1065,13 @@ compileGHC targetGhc crossTarget ov bstrap jobs mbuildConfig patches aargs build lift $ logInfo "Building (this may take a while)..." hadrian_build <- liftE $ findHadrianFile workdir - lEM $ execWithGhcEnv hadrian_build + lEM $ execLogged hadrian_build ( maybe [] (\j -> ["-j" <> show j] ) jobs ++ maybe [] (\bf -> ["--flavour=" <> bf]) buildFlavour ++ ["binary-dist"] ) (Just workdir) "ghc-make" + Nothing [tar] <- liftIO $ findFiles (workdir "_build" "bindist") (makeRegexOpts compExtended @@ -1259,64 +1260,50 @@ compileGHC targetGhc crossTarget ov bstrap jobs mbuildConfig patches aargs build () configureBindist tver workdir (fromInstallDir -> ghcdir) = do lift $ logInfo [s|configuring build|] - - if | _tvVersion tver >= [vver|8.8.0|] -> do - lEM $ execWithGhcEnv - "sh" - ("./configure" : maybe mempty - (\x -> ["--target=" <> T.unpack x]) - (_tvTarget tver) - ++ ["--prefix=" <> ghcdir] - ++ (if isWindows then ["--enable-tarballs-autodownload"] else []) - ++ fmap T.unpack aargs - ) - (Just workdir) - "ghc-conf" - | otherwise -> do - lEM $ execLogged - "sh" - ( [ "./configure", "--with-ghc=" <> either id id bghc - ] - ++ maybe mempty - (\x -> ["--target=" <> T.unpack x]) - (_tvTarget tver) - ++ ["--prefix=" <> ghcdir] - ++ (if isWindows then ["--enable-tarballs-autodownload"] else []) - ++ fmap T.unpack aargs - ) - (Just workdir) - "ghc-conf" - Nothing + lEM $ configureWithGhcBoot (Just tver) + (maybe mempty + (\x -> ["--target=" <> T.unpack x]) + (_tvTarget tver) + ++ ["--prefix=" <> ghcdir] + ++ (if isWindows then ["--enable-tarballs-autodownload"] else []) + ++ fmap T.unpack aargs + ) + (Just workdir) + "ghc-conf" pure () - execWithGhcEnv :: ( MonadReader env m - , HasSettings env - , HasDirs env - , HasLog env - , MonadIO m - , MonadThrow m) - => FilePath -- ^ thing to execute - -> [String] -- ^ args for the thing - -> Maybe FilePath -- ^ optionally chdir into this - -> FilePath -- ^ log filename (opened in append mode) - -> m (Either ProcessError ()) - execWithGhcEnv fp args dir logf = do - env <- ghcEnv - execLogged fp args dir logf (Just env) + configureWithGhcBoot :: ( MonadReader env m + , HasSettings env + , HasDirs env + , HasLog env + , MonadIO m + , MonadThrow m) + => Maybe GHCTargetVersion + -> [String] -- ^ args for configure + -> Maybe FilePath -- ^ optionally chdir into this + -> FilePath -- ^ log filename (opened in append mode) + -> m (Either ProcessError ()) + configureWithGhcBoot mtver args dir logf = do + let execNew = execLogged + "sh" + ("./configure" : ("GHC=" <> bghc) : args) + dir + logf + Nothing + execOld = execLogged + "sh" + ("./configure" : ("--with-ghc=" <> bghc) : args) + dir + logf + Nothing + if | Just tver <- mtver + , _tvVersion tver >= [vver|8.8.0|] -> execNew + | Nothing <- mtver -> execNew -- need some default for git checkouts where we don't know yet + | otherwise -> execOld bghc = case bstrap of - Right g -> Right g - Left bver -> Left ("ghc-" <> (T.unpack . prettyVer $ bver) <> exeExt) - - ghcEnv :: (MonadThrow m, MonadIO m) => m [(String, String)] - ghcEnv = do - cEnv <- liftIO getEnvironment - bghcPath <- case bghc of - Right ghc' -> pure ghc' - Left bver -> do - spaths <- liftIO getSearchPath - throwMaybeM (NotFoundInPATH bver) $ liftIO (searchPath spaths bver) - pure (("GHC", bghcPath) : cEnv) + Right g -> g + Left bver -> ("ghc-" <> (T.unpack . prettyVer $ bver) <> exeExt)