From b90e879cb5523218a595aafac091f24c367ac869 Mon Sep 17 00:00:00 2001 From: Shao Cheng Date: Sun, 3 May 2020 22:44:58 +0200 Subject: [PATCH] WIP --- .circleci/config.yml | 85 +++++++++++++++++++++++++++++++++++ asterius/src/Asterius/Boot.hs | 12 ++--- 2 files changed, 89 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9f4a402e5c..6a3a5ef7c8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,8 +34,93 @@ jobs: netlify deploy --dir=_build --message="$CIRCLE_SHA1" fi + asterius-darwin: + macos: + xcode: "11.5.0" + steps: + - run: + name: Install dependencies + command: | + mkdir -p ~/.local/bin + export PATH=~/.local/bin:$PATH + + brew install \ + binaryen + + curl -L https://github.com/commercialhaskell/stack/releases/download/v2.3.1/stack-2.3.1-osx-x86_64-bin -o ~/.local/bin/stack + chmod +x ~/.local/bin/stack + stack --no-terminal update + - checkout + - run: + name: Boot + command: | + export PATH=~/.local/bin:$PATH + stack --no-terminal -j4 build --test --no-run-tests + export ASTERIUS_CONFIGURE_OPTIONS=-v3 + . .envrc + ahc-boot + - run: + name: Test asterius + command: | + export PATH=~/.local/bin:$PATH + + stack --no-terminal test asterius:fib + stack --no-terminal test asterius:jsffi + stack --no-terminal test asterius:array + stack --no-terminal test asterius:stableptr + stack --no-terminal test asterius:rtsapi + stack --no-terminal test asterius:teletype + stack --no-terminal test asterius:bytearray + stack --no-terminal test asterius:bigint + stack --no-terminal test asterius:todomvc + stack --no-terminal test asterius:cloudflare + stack --no-terminal test asterius:exception + stack --no-terminal test asterius:regression60 + stack --no-terminal test asterius:sizeof_md5context + stack --no-terminal test asterius:largenum + + stack --no-terminal test asterius:fib --test-arguments="--backend=wasm-toolkit" + stack --no-terminal test asterius:jsffi --test-arguments="--backend=wasm-toolkit" + stack --no-terminal test asterius:array --test-arguments="--backend=wasm-toolkit" + stack --no-terminal test asterius:stableptr --test-arguments="--backend=wasm-toolkit" + stack --no-terminal test asterius:rtsapi --test-arguments="--backend=wasm-toolkit" + stack --no-terminal test asterius:teletype --test-arguments="--backend=wasm-toolkit" + stack --no-terminal test asterius:bytearray --test-arguments="--backend=wasm-toolkit" + stack --no-terminal test asterius:bigint --test-arguments="--backend=wasm-toolkit" + stack --no-terminal test asterius:todomvc --test-arguments="--backend=wasm-toolkit" + stack --no-terminal test asterius:cloudflare --test-arguments="--backend=wasm-toolkit" + stack --no-terminal test asterius:exception --test-arguments="--backend=wasm-toolkit" + stack --no-terminal test asterius:regression60 --test-arguments="--backend=wasm-toolkit" + stack --no-terminal test asterius:sizeof_md5context --test-arguments="--backend=wasm-toolkit" + stack --no-terminal test asterius:largenum --test-arguments="--backend=wasm-toolkit" + + stack --no-terminal test asterius:bytearray --test-arguments="--yolo" + stack --no-terminal test asterius:bytearray --test-arguments="--gc-threshold=128" + stack --no-terminal test asterius:fib --test-arguments="--no-gc-sections" + + stack --no-terminal test asterius:fib --test-arguments="--debug" > /dev/null + stack --no-terminal test asterius:jsffi --test-arguments="--debug" > /dev/null + stack --no-terminal test asterius:array --test-arguments="--debug" > /dev/null + stack --no-terminal test asterius:stableptr --test-arguments="--debug" > /dev/null + stack --no-terminal test asterius:rtsapi --test-arguments="--debug" > /dev/null + stack --no-terminal test asterius:teletype --test-arguments="--debug" > /dev/null + # stack --no-terminal test asterius:bytearray --test-arguments="--debug" > /dev/null + stack --no-terminal test asterius:bigint --test-arguments="--debug" > /dev/null + stack --no-terminal test asterius:exception --test-arguments="--debug" > /dev/null + + stack --no-terminal test asterius:fib --test-arguments="--tail-calls" + stack --no-terminal test asterius:fib --test-arguments="--tail-calls --no-gc-sections" + + stack --no-terminal test asterius:nomain + stack --no-terminal test asterius:nomain --test-arguments="--tail-calls" + + stack --no-terminal test asterius:th + + stack --no-terminal test asterius:primitive + workflows: version: 2 build: jobs: - asterius-build-docs + - asterius-darwin diff --git a/asterius/src/Asterius/Boot.hs b/asterius/src/Asterius/Boot.hs index d4885ca46f..5b705b6841 100644 --- a/asterius/src/Asterius/Boot.hs +++ b/asterius/src/Asterius/Boot.hs @@ -11,6 +11,7 @@ module Asterius.Boot ) where +import Ar import Asterius.Binary.File import Asterius.BuildInfo import Asterius.Builtins @@ -23,6 +24,7 @@ import Control.Monad import Control.Monad.IO.Class import Data.IORef import Data.Maybe +import Data.Traversable import qualified DynFlags as GHC import qualified GHC import Language.Haskell.GHC.Toolkit.BuildInfo @@ -143,14 +145,8 @@ bootRTSCmm BootArgs {..} = ) liftIO $ do obj_paths <- readIORef obj_paths_ref - tmpdir <- getTemporaryDirectory - (rsp_path, rsp_h) <- openTempFile tmpdir "ar.rsp" - hPutStr rsp_h $ unlines obj_paths - hClose rsp_h - callProcess - "ar" - ["-r", "-c", obj_topdir "rts" "libHSrts.a", '@' : rsp_path] - removeFile rsp_path + ar <- Archive <$> for obj_paths loadObj + writeGNUAr (obj_topdir "rts" "libHSrts.a") ar where rts_path = bootLibsPath "rts" obj_topdir = bootDir "asterius_lib"