mirror of
https://github.com/tweag/asterius.git
synced 2024-11-11 03:07:47 +03:00
Remove ahc-boot-builtins, only embed rts.Asterius into global store when performing final linking
This commit is contained in:
parent
a4863f24eb
commit
78704df11e
@ -82,13 +82,6 @@ executables:
|
||||
dependencies:
|
||||
- asterius
|
||||
|
||||
tests:
|
||||
ahc-boot-builtins:
|
||||
source-dirs: test
|
||||
main: ahc-boot-builtins.hs
|
||||
dependencies:
|
||||
- asterius
|
||||
|
||||
nir-test:
|
||||
source-dirs: test
|
||||
main: nir-test.hs
|
||||
|
@ -77,7 +77,7 @@ bootCreateProcess args@BootArgs {..} = do
|
||||
bootRTSCmm :: BootArgs -> IO ()
|
||||
bootRTSCmm BootArgs {..} = do
|
||||
is_debug <- isJust <$> lookupEnv "ASTERIUS_DEBUG"
|
||||
store_ref <- newIORef $ builtinsStore builtinsOptions
|
||||
store_ref <- newIORef mempty
|
||||
rts_cmm_mods <-
|
||||
map takeBaseName . filter ((== ".cmm") . takeExtension) <$>
|
||||
listDirectory rts_path
|
||||
|
@ -1,19 +0,0 @@
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
|
||||
import Asterius.Boot
|
||||
import Asterius.Internals
|
||||
import Asterius.Store
|
||||
import Prelude hiding (IO)
|
||||
import System.FilePath
|
||||
|
||||
updateRTSAsteriusCmm :: BootArgs -> IO ()
|
||||
updateRTSAsteriusCmm BootArgs {..} = do
|
||||
orig_store <- decodeFile (obj_topdir </> "asterius_store")
|
||||
encodeFile (obj_topdir </> "asterius_store") $
|
||||
builtinsStore builtinsOptions <> orig_store
|
||||
where
|
||||
obj_topdir = bootDir </> "asterius_lib"
|
||||
|
||||
main :: IO ()
|
||||
main = getDefaultBootArgs >>= updateRTSAsteriusCmm
|
@ -3,6 +3,7 @@
|
||||
|
||||
import Asterius.Boot
|
||||
import Asterius.BuildInfo
|
||||
import Asterius.Builtins
|
||||
import Asterius.CodeGen
|
||||
import Asterius.Internals
|
||||
import Asterius.Marshal
|
||||
@ -28,23 +29,22 @@ main = do
|
||||
pwd <- getCurrentDirectory
|
||||
let test_path = pwd </> "test" </> "fact-dump"
|
||||
withCurrentDirectory test_path $ do
|
||||
putStrLn "Compiling Fact.."
|
||||
[(ms_mod, ir)] <-
|
||||
M.toList <$>
|
||||
runHaskell
|
||||
defaultConfig {ghcFlags = ["-Wall", "-O2", "-fforce-recomp"]}
|
||||
["Fact.hs"]
|
||||
putStrLn "Compiling fact.."
|
||||
[(ms_mod, ir)] <- M.toList <$> runHaskell defaultConfig ["fact.hs"]
|
||||
case runCodeGen (marshalHaskellIR ir) GHC.unsafeGlobalDynFlags ms_mod of
|
||||
Left err -> throwIO err
|
||||
Right m -> do
|
||||
putStrLn "Dumping IR of Fact.."
|
||||
writeFile "Fact.txt" $ ppShow m
|
||||
putStrLn "Chasing Fact_root_closure.."
|
||||
putStrLn "Dumping IR of fact.."
|
||||
writeFile "fact.txt" $ ppShow m
|
||||
putStrLn "Chasing Main_main_closure.."
|
||||
store' <- decodeFile (obj_topdir </> "asterius_store")
|
||||
let store = addModule (marshalToModuleSymbol ms_mod) m store'
|
||||
builtins_opts <- getDefaultBuiltinsOptions
|
||||
let store =
|
||||
addModule (marshalToModuleSymbol ms_mod) m $
|
||||
builtinsStore builtins_opts <> store'
|
||||
(maybe_final_m, report) = linkStart store ["main"]
|
||||
writeDot "Fact.gv" report
|
||||
writeFile "Fact.link-report.txt" $ ppShow report
|
||||
writeDot "fact.gv" report
|
||||
writeFile "fact.link-report.txt" $ ppShow report
|
||||
let Just final_m = maybe_final_m
|
||||
pPrint final_m
|
||||
hFlush stdout
|
||||
@ -53,6 +53,6 @@ main = do
|
||||
c_BinaryenModulePrint m_ref
|
||||
c_BinaryenModuleValidate m_ref >>= print
|
||||
m_bin <- serializeModule m_ref
|
||||
BS.writeFile "Fact.wasm" m_bin
|
||||
BS.writeFile "fact.wasm" m_bin
|
||||
c_BinaryenModuleDispose m_ref
|
||||
callProcess node ["loader.js"]
|
||||
|
@ -34,17 +34,7 @@ data Config = Config
|
||||
}
|
||||
|
||||
defaultConfig :: Config
|
||||
defaultConfig =
|
||||
Config
|
||||
{ ghcFlags =
|
||||
[ "-Wall"
|
||||
, "-O2"
|
||||
, "-fforce-recomp"
|
||||
, "-no-keep-hi-files"
|
||||
, "-no-keep-o-files"
|
||||
]
|
||||
, ghcLibDir = BI.ghcLibDir
|
||||
}
|
||||
defaultConfig = Config {ghcFlags = ["-Wall", "-O2"], ghcLibDir = BI.ghcLibDir}
|
||||
|
||||
runHaskell :: MonadIO m => Config -> [String] -> m (M.Map Module HaskellIR)
|
||||
runHaskell Config {..} targets =
|
||||
@ -52,7 +42,11 @@ runHaskell Config {..} targets =
|
||||
defaultErrorHandler defaultFatalMessager defaultFlushOut $
|
||||
runGhc (Just ghcLibDir) $ do
|
||||
dflags <- getSessionDynFlags
|
||||
(dflags', _, _) <- parseDynamicFlags dflags $ map noLoc ghcFlags
|
||||
(dflags', _, _) <-
|
||||
parseDynamicFlags
|
||||
(dflags `gopt_set` Opt_ForceRecomp `gopt_unset` Opt_KeepHiFiles `gopt_unset`
|
||||
Opt_KeepOFiles) $
|
||||
map noLoc ghcFlags
|
||||
(h, read_mod_map) <-
|
||||
liftIO $ do
|
||||
mod_map_ref <- newIORef M.empty
|
||||
@ -91,7 +85,10 @@ runCmm Config {..} cmm_fns =
|
||||
defaultErrorHandler defaultFatalMessager defaultFlushOut $
|
||||
runGhc (Just ghcLibDir) $ do
|
||||
dflags <- getSessionDynFlags
|
||||
(dflags', _, _) <- parseDynamicFlags dflags $ map noLoc ghcFlags
|
||||
(dflags', _, _) <-
|
||||
parseDynamicFlags
|
||||
(dflags `gopt_set` Opt_ForceRecomp `gopt_unset` Opt_KeepOFiles) $
|
||||
map noLoc ghcFlags
|
||||
(h, read_cmm_irs) <-
|
||||
liftIO $ do
|
||||
cmm_irs_ref <- newIORef []
|
||||
|
Loading…
Reference in New Issue
Block a user