Add GHC JS cross test

This commit is contained in:
Julian Ospald 2023-07-18 16:30:27 +08:00
parent 5170baf074
commit 6623e4b1c8
No known key found for this signature in database
GPG Key ID: CCC85C0E40C06A8C
3 changed files with 95 additions and 60 deletions

View File

@ -1,9 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eux set -ex
. .github/scripts/common.sh . .github/scripts/common.sh
run() {
"$@"
}
if [ "${OS}" = "Windows" ] ; then if [ "${OS}" = "Windows" ] ; then
GHCUP_DIR="${GHCUP_INSTALL_BASE_PREFIX}"/ghcup GHCUP_DIR="${GHCUP_INSTALL_BASE_PREFIX}"/ghcup
@ -39,9 +42,11 @@ cabal --version
eghcup debug-info 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 \ 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)" \ -j "$(nproc)" \
-v "${GHC_TARGET_VERSION}" \ -v "${GHC_TARGET_VERSION}" \
-b "${GHC_VER}" \ -b "${GHC_VER}" \

View File

@ -74,6 +74,7 @@ jobs:
DISTRO: Debian DISTRO: Debian
ARTIFACT: "x86_64-linux-ghcup" ARTIFACT: "x86_64-linux-ghcup"
CROSS: "arm-linux-gnueabihf" CROSS: "arm-linux-gnueabihf"
WRAPPER: "run"
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
@ -95,3 +96,45 @@ jobs:
sudo apt-get install -y libncurses-dev:armhf sudo apt-get install -y libncurses-dev:armhf
sh .github/scripts/cross.sh 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

View File

@ -1013,8 +1013,8 @@ compileGHC targetGhc crossTarget ov bstrap jobs mbuildConfig patches aargs build
=> GHCupPath => GHCupPath
-> Excepts '[ProcessError, ParseError] m Version -> Excepts '[ProcessError, ParseError] m Version
getGHCVer tmpUnpack = do getGHCVer tmpUnpack = do
lEM $ execWithGhcEnv "python3" ["./boot"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap" lEM $ execLogged "python3" ["./boot"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap" Nothing
lEM $ execWithGhcEnv "sh" ["./configure"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap" lEM $ configureWithGhcBoot Nothing [] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap"
let versionFile = fromGHCupPath tmpUnpack </> "VERSION" let versionFile = fromGHCupPath tmpUnpack </> "VERSION"
hasVersionFile <- liftIO $ doesFileExist versionFile hasVersionFile <- liftIO $ doesFileExist versionFile
if hasVersionFile if hasVersionFile
@ -1065,12 +1065,13 @@ compileGHC targetGhc crossTarget ov bstrap jobs mbuildConfig patches aargs build
lift $ logInfo "Building (this may take a while)..." lift $ logInfo "Building (this may take a while)..."
hadrian_build <- liftE $ findHadrianFile workdir hadrian_build <- liftE $ findHadrianFile workdir
lEM $ execWithGhcEnv hadrian_build lEM $ execLogged hadrian_build
( maybe [] (\j -> ["-j" <> show j] ) jobs ( maybe [] (\j -> ["-j" <> show j] ) jobs
++ maybe [] (\bf -> ["--flavour=" <> bf]) buildFlavour ++ maybe [] (\bf -> ["--flavour=" <> bf]) buildFlavour
++ ["binary-dist"] ++ ["binary-dist"]
) )
(Just workdir) "ghc-make" (Just workdir) "ghc-make"
Nothing
[tar] <- liftIO $ findFiles [tar] <- liftIO $ findFiles
(workdir </> "_build" </> "bindist") (workdir </> "_build" </> "bindist")
(makeRegexOpts compExtended (makeRegexOpts compExtended
@ -1259,64 +1260,50 @@ compileGHC targetGhc crossTarget ov bstrap jobs mbuildConfig patches aargs build
() ()
configureBindist tver workdir (fromInstallDir -> ghcdir) = do configureBindist tver workdir (fromInstallDir -> ghcdir) = do
lift $ logInfo [s|configuring build|] lift $ logInfo [s|configuring build|]
lEM $ configureWithGhcBoot (Just tver)
if | _tvVersion tver >= [vver|8.8.0|] -> do (maybe mempty
lEM $ execWithGhcEnv (\x -> ["--target=" <> T.unpack x])
"sh" (_tvTarget tver)
("./configure" : maybe mempty ++ ["--prefix=" <> ghcdir]
(\x -> ["--target=" <> T.unpack x]) ++ (if isWindows then ["--enable-tarballs-autodownload"] else [])
(_tvTarget tver) ++ fmap T.unpack aargs
++ ["--prefix=" <> ghcdir] )
++ (if isWindows then ["--enable-tarballs-autodownload"] else []) (Just workdir)
++ fmap T.unpack aargs "ghc-conf"
)
(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
pure () pure ()
execWithGhcEnv :: ( MonadReader env m configureWithGhcBoot :: ( MonadReader env m
, HasSettings env , HasSettings env
, HasDirs env , HasDirs env
, HasLog env , HasLog env
, MonadIO m , MonadIO m
, MonadThrow m) , MonadThrow m)
=> FilePath -- ^ thing to execute => Maybe GHCTargetVersion
-> [String] -- ^ args for the thing -> [String] -- ^ args for configure
-> Maybe FilePath -- ^ optionally chdir into this -> Maybe FilePath -- ^ optionally chdir into this
-> FilePath -- ^ log filename (opened in append mode) -> FilePath -- ^ log filename (opened in append mode)
-> m (Either ProcessError ()) -> m (Either ProcessError ())
execWithGhcEnv fp args dir logf = do configureWithGhcBoot mtver args dir logf = do
env <- ghcEnv let execNew = execLogged
execLogged fp args dir logf (Just env) "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 bghc = case bstrap of
Right g -> Right g Right g -> g
Left bver -> Left ("ghc-" <> (T.unpack . prettyVer $ bver) <> exeExt) Left bver -> ("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)