diff --git a/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.h b/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.h index 111f8f87ba6..d29e6d33f35 100644 --- a/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.h +++ b/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.h @@ -9,10 +9,11 @@ #include #include #include +#include namespace Wasm { -struct BytecodeInterpreter final : public Interpreter { +struct WASM_API BytecodeInterpreter final : public Interpreter { explicit BytecodeInterpreter(StackInfo const& stack_info) : m_stack_info(stack_info) { diff --git a/Libraries/LibWasm/CMakeLists.txt b/Libraries/LibWasm/CMakeLists.txt index 9cdc992a5de..7af8a8bf3bf 100644 --- a/Libraries/LibWasm/CMakeLists.txt +++ b/Libraries/LibWasm/CMakeLists.txt @@ -7,6 +7,7 @@ set(SOURCES Printer/Printer.cpp ) +# FIXME: Add Windows support if (NOT WIN32) list(APPEND SOURCES WASI/Wasi.cpp) endif() diff --git a/Libraries/LibWasm/Printer/Printer.h b/Libraries/LibWasm/Printer/Printer.h index a3926fcc860..0f44b1b6c6e 100644 --- a/Libraries/LibWasm/Printer/Printer.h +++ b/Libraries/LibWasm/Printer/Printer.h @@ -6,6 +6,7 @@ #pragma once +#include #include namespace Wasm { @@ -16,7 +17,7 @@ class Value; ByteString instruction_name(OpCode const& opcode); Optional instruction_from_name(StringView name); -struct Printer { +struct WASM_API Printer { explicit Printer(Stream& stream, size_t initial_indent = 0) : m_stream(stream) , m_indent(initial_indent) diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt index 4e843682acf..4723a6de966 100644 --- a/Utilities/CMakeLists.txt +++ b/Utilities/CMakeLists.txt @@ -1,7 +1,10 @@ if(WIN32) + # FIXME: Add support for LibLine on Windows lagom_utility(js SOURCES js.cpp LIBS LibCrypto LibJS LibUnicode LibMain LibTextCodec LibGC Threads::Threads) + lagom_utility(wasm SOURCES wasm.cpp LIBS LibFileSystem LibWasm LibMain) else() lagom_utility(js SOURCES js.cpp LIBS LibCrypto LibJS LibLine LibUnicode LibMain LibTextCodec LibGC Threads::Threads) + lagom_utility(wasm SOURCES wasm.cpp LIBS LibFileSystem LibWasm LibLine LibMain) endif() # FIXME: Increase support for building targets on Windows @@ -34,7 +37,6 @@ if (ASSERT_FAIL_HAS_INT OR EMSCRIPTEN) target_compile_definitions(test262-runner PRIVATE ASSERT_FAIL_HAS_INT) endif() -lagom_utility(wasm SOURCES wasm.cpp LIBS LibFileSystem LibWasm LibLine LibMain) lagom_utility(xml SOURCES xml.cpp LIBS LibFileSystem LibMain LibXML LibURL) if (NOT CMAKE_SKIP_INSTALL_RULES) diff --git a/Utilities/wasm.cpp b/Utilities/wasm.cpp index 6d1820aa720..a5e4d394225 100644 --- a/Utilities/wasm.cpp +++ b/Utilities/wasm.cpp @@ -10,19 +10,23 @@ #include #include #include +#include #include #include #include -#include +#if !defined(AK_OS_WINDOWS) +# include +#endif #include #include #include #include #include -#include +#if !defined(AK_OS_WINDOWS) +# include +#endif #include #include -#include static OwnPtr g_stdout {}; static OwnPtr g_printer {}; @@ -277,7 +281,7 @@ ErrorOr ladybird_main(Main::Arguments arguments) bool print_compiled = false; bool attempt_instantiate = false; bool export_all_imports = false; - bool wasi = false; + [[maybe_unused]] bool wasi = false; ByteString exported_function_to_execute; Vector values_to_push; Vector modules_to_link_in; @@ -291,7 +295,9 @@ ErrorOr ladybird_main(Main::Arguments arguments) parser.add_option(attempt_instantiate, "Attempt to instantiate the module", "instantiate", 'i'); parser.add_option(exported_function_to_execute, "Attempt to execute the named exported function from the module (implies -i)", "execute", 'e', "name"); parser.add_option(export_all_imports, "Export noop functions corresponding to imports", "export-noop"); +#if !defined(AK_OS_WINDOWS) parser.add_option(wasi, "Enable WASI", "wasi", 'w'); +#endif parser.add_option(Core::ArgsParser::Option { .argument_mode = Core::ArgsParser::OptionArgumentMode::Required, .help_string = "Directory mappings to expose via WASI", @@ -356,6 +362,7 @@ ErrorOr ladybird_main(Main::Arguments arguments) if (attempt_instantiate || print_compiled) { Wasm::AbstractMachine machine; +#if !defined(AK_OS_WINDOWS) Optional wasi_impl; if (wasi) { @@ -383,6 +390,7 @@ ErrorOr ladybird_main(Main::Arguments arguments) return paths; }, }); } +#endif Core::EventLoop main_loop; // First, resolve the linked modules @@ -416,6 +424,7 @@ ErrorOr ladybird_main(Main::Arguments arguments) for (auto& instance : linked_instances) linker.link(*instance); +#if !defined(AK_OS_WINDOWS) if (wasi) { HashMap wasi_exports; for (auto& entry : linker.unresolved_imports()) { @@ -432,6 +441,7 @@ ErrorOr ladybird_main(Main::Arguments arguments) linker.link(wasi_exports); } +#endif if (export_all_imports) { HashMap exports;