Created
August 23, 2024 21:21
-
-
Save RubenVerg/ed11b5b0aa5b4e430f213bb73b212c06 to your computer and use it in GitHub Desktop.
wasm wizer embed file test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Error: failed to run main module `w.wasm` | |
Caused by: | |
0: failed to invoke command default | |
1: error while executing at wasm backtrace: | |
0: 0xdb309 - wasm-embed-test.wasm!StgRun | |
1: 0xbc4d5 - wasm-embed-test.wasm!scheduleWaitThread | |
2: 0xaf5a9 - wasm-embed-test.wasm!rts_evalLazyIO | |
3: 0xb2027 - wasm-embed-test.wasm!hs_main | |
4: 0x8dff - wasm-embed-test.wasm!main | |
5: 0xfdcd5 - wasm-embed-test.wasm!__main_void | |
6: 0x8695 - wasm-embed-test.wasm!_start | |
2: wasm trap: undefined element: out of bounds table access |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import System.IO.Unsafe | |
import Control.DeepSeq | |
import Control.Monad | |
import Control.Exception | |
file :: String | |
file = unsafePerformIO $ readFile "/src/Main.hs" | |
{-# NOINLINE file #-} | |
foreign export ccall loadFile :: IO () | |
loadFile :: IO () | |
loadFile = void $ evaluate $ rnf file | |
main :: IO () | |
main = putStrLn file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wasm32-wasi-cabal build | |
wizer --allow-wasi --wasm-bulk-memory true $(wasm32-wasi-cabal list-bin wasm-embed-test) -o w.wasm --mapdir /src::./app | |
wasmtime w.wasm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cabal-version: 3.4 | |
name: wasm-embed-test | |
version: 0.1.0.0 | |
license: MIT | |
license-file: LICENSE | |
author: RubenVerg | |
maintainer: [email protected] | |
build-type: Simple | |
common warnings | |
ghc-options: -Wall | |
executable wasm-embed-test | |
import: warnings | |
main-is: Main.hs | |
build-depends: base ^>=4.20.0.0, deepseq | |
hs-source-dirs: app | |
default-language: Haskell2010 | |
c-sources: app/wizer.c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Rts.h" | |
#include "Main_stub.h" | |
__attribute__((export_name("wizer.initialize"))) void __wizer_initialize(void) { | |
hs_init(NULL, NULL); | |
loadFile(); | |
hs_perform_gc(); | |
hs_perform_gc(); | |
rts_clearMemory(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment