diff --git a/clang/unittests/Interpreter/CMakeLists.txt b/clang/unittests/Interpreter/CMakeLists.txt index 1dda9024075a1..b6825f9461ad7 100644 --- a/clang/unittests/Interpreter/CMakeLists.txt +++ b/clang/unittests/Interpreter/CMakeLists.txt @@ -1,3 +1,34 @@ +if(EMSCRIPTEN) +set(LLVM_COMPONENTS_TO_LINK + "" + ) +set(LLVM_LIBS_TO_LINK + "" + ) +set(CLANG_LIBS_TO_LINK + clangInterpreter + ) +else() +set(LLVM_COMPONENTS_TO_LINK + ${LLVM_TARGETS_TO_BUILD} + Core + MC + OrcJIT + Support + TargetParser + ) +set(LLVM_LIBS_TO_LINK + LLVMTestingSupport + ) +set(CLANG_LIBS_TO_LINK + clangAST + clangBasic + clangInterpreter + clangFrontend + clangSema + ) +endif() + add_distinct_clang_unittest(ClangReplInterpreterTests IncrementalCompilerBuilderTest.cpp IncrementalProcessingTest.cpp @@ -8,24 +39,33 @@ add_distinct_clang_unittest(ClangReplInterpreterTests EXPORT_SYMBOLS CLANG_LIBS - clangAST - clangBasic - clangInterpreter - clangFrontend - clangSema + ${CLANG_LIBS_TO_LINK} LINK_LIBS - LLVMTestingSupport + ${LLVM_LIBS_TO_LINK} LLVM_COMPONENTS - ${LLVM_TARGETS_TO_BUILD} - Core - MC - OrcJIT - Support - TargetParser + ${LLVM_COMPONENTS_TO_LINK} ) +if(EMSCRIPTEN) +# Without the above you try to link to LLVMSupport twice, and end +# up with a duplicate symbol error when creating the main module +get_target_property(LINKED_LIBS ClangReplInterpreterTests LINK_LIBRARIES) +list(REMOVE_ITEM LINKED_LIBS LLVMSupport) +set_target_properties(ClangReplInterpreterTests PROPERTIES LINK_LIBRARIES "${LINKED_LIBS}") +target_link_options(ClangReplInterpreterTests + PUBLIC "SHELL: -s MAIN_MODULE=1" + PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1" + PUBLIC "SHELL: -s STACK_SIZE=32mb" + PUBLIC "SHELL: -s INITIAL_MEMORY=128mb" + PUBLIC "SHELL: --emrun" +) +set_target_properties(ClangReplInterpreterTests PROPERTIES + SUFFIX ".html" +) +endif() + # Exceptions on Windows are not yet supported. if(NOT WIN32) add_subdirectory(ExceptionTests) diff --git a/clang/unittests/Interpreter/CodeCompletionTest.cpp b/clang/unittests/Interpreter/CodeCompletionTest.cpp index 23cfc469695d2..ceb683497ac74 100644 --- a/clang/unittests/Interpreter/CodeCompletionTest.cpp +++ b/clang/unittests/Interpreter/CodeCompletionTest.cpp @@ -29,8 +29,14 @@ class CodeCompletionTest : public InterpreterTestBase { std::unique_ptr Interp; void SetUp() override { +// FIXME : WebAssembly doesn't currently support Jit (see +// https: // github.com/llvm/llvm-project/pull/150977#discussion_r2237521095). +// so this check of HostSupportsJIT has been skipped +// over until support is added, and HostSupportsJIT can return true. +#ifndef __EMSCRIPTEN__ if (!HostSupportsJIT()) GTEST_SKIP(); +#endif std::unique_ptr CI = cantFail(CB.CreateCpp()); this->Interp = cantFail(clang::Interpreter::create(std::move(CI))); } diff --git a/clang/unittests/Interpreter/IncrementalCompilerBuilderTest.cpp b/clang/unittests/Interpreter/IncrementalCompilerBuilderTest.cpp index c4a40071f55cf..7b4633bfc9e7a 100644 --- a/clang/unittests/Interpreter/IncrementalCompilerBuilderTest.cpp +++ b/clang/unittests/Interpreter/IncrementalCompilerBuilderTest.cpp @@ -37,6 +37,14 @@ TEST(IncrementalCompilerBuilder, SetCompilerArgs) { } TEST(IncrementalCompilerBuilder, SetTargetTriple) { +// FIXME : This test doesn't current work for Emscripten builds. +// It should be possible to make it work.For details on how it fails and +// the current progress to enable this test see +// the following Github issue https: // +// github.com/llvm/llvm-project/issues/153461 +#ifdef __EMSCRIPTEN__ + GTEST_SKIP() << "Test fails for Emscipten builds"; +#endif auto CB = clang::IncrementalCompilerBuilder(); CB.SetTargetTriple("armv6-none-eabi"); auto CI = cantFail(CB.CreateCpp()); diff --git a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp index 1c27cfb2c48fa..f50f6e320776d 100644 --- a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp +++ b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp @@ -75,9 +75,14 @@ struct OutOfProcInterpreter : public Interpreter { }; TEST_F(InterpreterExtensionsTest, FindRuntimeInterface) { +// FIXME : WebAssembly doesn't currently support Jit (see +// https: // github.com/llvm/llvm-project/pull/150977#discussion_r2237521095). +// so this check of HostSupportsJIT has been skipped +// over until support is added, and HostSupportsJIT can return true. +#ifndef __EMSCRIPTEN__ if (!HostSupportsJIT()) GTEST_SKIP(); - +#endif clang::IncrementalCompilerBuilder CB; llvm::Error ErrOut = llvm::Error::success(); auto CI = cantFail(CB.CreateCpp()); diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp b/clang/unittests/Interpreter/InterpreterTest.cpp index 768058b954d49..8639fb668f1fe 100644 --- a/clang/unittests/Interpreter/InterpreterTest.cpp +++ b/clang/unittests/Interpreter/InterpreterTest.cpp @@ -147,6 +147,14 @@ TEST_F(InterpreterTest, DeclsAndStatements) { } TEST_F(InterpreterTest, UndoCommand) { +// FIXME : This test doesn't current work for Emscripten builds. +// It should be possible to make it work.For details on how it fails and +// the current progress to enable this test see +// the following Github issue https: // +// github.com/llvm/llvm-project/issues/153461 +#ifdef __EMSCRIPTEN__ + GTEST_SKIP() << "Test fails for Emscipten builds"; +#endif Args ExtraArgs = {"-Xclang", "-diagnostic-log-file", "-Xclang", "-"}; // Create the diagnostic engine with unowned consumer. @@ -256,6 +264,14 @@ static NamedDecl *LookupSingleName(Interpreter &Interp, const char *Name) { } TEST_F(InterpreterTest, InstantiateTemplate) { +// FIXME : This test doesn't current work for Emscripten builds. +// It should be possible to make it work.For details on how it fails and +// the current progress to enable this test see +// the following Github issue https: // +// github.com/llvm/llvm-project/issues/153461 +#ifdef __EMSCRIPTEN__ + GTEST_SKIP() << "Test fails for Emscipten builds"; +#endif // FIXME: We cannot yet handle delayed template parsing. If we run with // -fdelayed-template-parsing we try adding the newly created decl to the // active PTU which causes an assert. @@ -295,6 +311,14 @@ TEST_F(InterpreterTest, InstantiateTemplate) { } TEST_F(InterpreterTest, Value) { +// FIXME : This test doesn't current work for Emscripten builds. +// It should be possible to make it work.For details on how it fails and +// the current progress to enable this test see +// the following Github issue https: // +// github.com/llvm/llvm-project/issues/153461 +#ifdef __EMSCRIPTEN__ + GTEST_SKIP() << "Test fails for Emscipten builds"; +#endif std::vector Args = {"-fno-sized-deallocation"}; std::unique_ptr Interp = createInterpreter(Args); diff --git a/clang/unittests/Interpreter/InterpreterTestFixture.h b/clang/unittests/Interpreter/InterpreterTestFixture.h index 113599ff98894..b088fa4a5f896 100644 --- a/clang/unittests/Interpreter/InterpreterTestFixture.h +++ b/clang/unittests/Interpreter/InterpreterTestFixture.h @@ -38,8 +38,14 @@ class InterpreterTestBase : public ::testing::Test { } void SetUp() override { +// FIXME : WebAssembly doesn't currently support Jit (see +// https: // github.com/llvm/llvm-project/pull/150977#discussion_r2237521095). +// so this check of HostSupportsJIT has been skipped +// over until support is added, and HostSupportsJIT can return true. +#ifndef __EMSCRIPTEN__ if (!HostSupportsJIT()) GTEST_SKIP(); +#endif } void TearDown() override {}