Skip to content

Commit ea634fe

Browse files
authored
[clang-repl] Fix InstantiateTemplate & Value test while building against emscripten (#154513)
Building with assertions flag (-sAssertions=2) gives me these ``` [ RUN ] InterpreterTest.InstantiateTemplate Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueWithAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Error in loading dynamic library incr_module_3.wasm: RuntimeError: Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueWithAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Could not load dynamic lib: incr_module_3.wasm RuntimeError: Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueWithAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) [ RUN ] InterpreterTest.InstantiateTemplate Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueNoAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Error in loading dynamic library incr_module_3.wasm: RuntimeError: Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueNoAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Could not load dynamic lib: incr_module_3.wasm RuntimeError: Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueNoAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) [ RUN ] InterpreterTest.InstantiateTemplate Aborted(Assertion failed: undefined symbol '_ZnwmPv26__clang_Interpreter_NewTag'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Error in loading dynamic library incr_module_23.wasm: RuntimeError: Aborted(Assertion failed: undefined symbol '_ZnwmPv26__clang_Interpreter_NewTag'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Could not load dynamic lib: incr_module_23.wasm RuntimeError: Aborted(Assertion failed: undefined symbol '_ZnwmPv26__clang_Interpreter_NewTag'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) [ RUN ] InterpreterTest.Value Aborted(Assertion failed: undefined symbol '_Z9getGlobalv'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Error in loading dynamic library incr_module_36.wasm: RuntimeError: Aborted(Assertion failed: undefined symbol '_Z9getGlobalv'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Could not load dynamic lib: incr_module_36.wasm [ RUN ] InterpreterTest.Value Aborted(Assertion failed: undefined symbol '_Z9getGlobalv'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Error in loading dynamic library incr_module_36.wasm: RuntimeError: Aborted(Assertion failed: undefined symbol '_Z9setGlobali'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Could not load dynamic lib: incr_module_36.wasm ``` **So we have some symbols missing here that are needed by the side modules being created here.** First 2 are needed by both tests Last 3 are needed for these lines accordingly in the Value test. https://github.com/llvm/llvm-project/blob/dc23869f98452ca2c4086f12bb431a8d6fdb8169/clang/unittests/Interpreter/InterpreterTest.cpp#L355 https://github.com/llvm/llvm-project/blob/dc23869f98452ca2c4086f12bb431a8d6fdb8169/clang/unittests/Interpreter/InterpreterTest.cpp#L364 https://github.com/llvm/llvm-project/blob/dc23869f98452ca2c4086f12bb431a8d6fdb8169/clang/unittests/Interpreter/InterpreterTest.cpp#L365 Everything should work as expected after this ``` [----------] 9 tests from InterpreterTest [ RUN ] InterpreterTest.Sanity [ OK ] InterpreterTest.Sanity (18 ms) [ RUN ] InterpreterTest.IncrementalInputTopLevelDecls [ OK ] InterpreterTest.IncrementalInputTopLevelDecls (45 ms) [ RUN ] InterpreterTest.Errors [ OK ] InterpreterTest.Errors (29 ms) [ RUN ] InterpreterTest.DeclsAndStatements [ OK ] InterpreterTest.DeclsAndStatements (34 ms) [ RUN ] InterpreterTest.UndoCommand /Users/anutosh491/work/llvm-project/clang/unittests/Interpreter/InterpreterTest.cpp:156: Skipped Test fails for Emscipten builds [ SKIPPED ] InterpreterTest.UndoCommand (0 ms) [ RUN ] InterpreterTest.FindMangledNameSymbol [ OK ] InterpreterTest.FindMangledNameSymbol (85 ms) [ RUN ] InterpreterTest.InstantiateTemplate [ OK ] InterpreterTest.InstantiateTemplate (127 ms) [ RUN ] InterpreterTest.Value [ OK ] InterpreterTest.Value (608 ms) [ RUN ] InterpreterTest.TranslationUnit_CanonicalDecl [ OK ] InterpreterTest.TranslationUnit_CanonicalDecl (64 ms) [----------] 9 tests from InterpreterTest (1014 ms total) ``` This is similar to how we need to take care of some symbols while building side modules during running cppinterop's test suite !
1 parent 6cedf6e commit ea634fe

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

clang/unittests/Interpreter/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ target_link_options(ClangReplInterpreterTests
6060
PUBLIC "SHELL: -s STACK_SIZE=32mb"
6161
PUBLIC "SHELL: -s INITIAL_MEMORY=128mb"
6262
PUBLIC "SHELL: --emrun"
63+
PUBLIC "SHELL: -Wl,--export=__clang_Interpreter_SetValueWithAlloc"
64+
PUBLIC "SHELL: -Wl,--export=__clang_Interpreter_SetValueNoAlloc"
65+
PUBLIC "SHELL: -Wl,--export=_ZnwmPv26__clang_Interpreter_NewTag"
66+
PUBLIC "SHELL: -Wl,--export=_Z9getGlobalv"
67+
PUBLIC "SHELL: -Wl,--export=_Z9setGlobali"
6368
)
6469
set_target_properties(ClangReplInterpreterTests PROPERTIES
6570
SUFFIX ".html"

clang/unittests/Interpreter/InterpreterTest.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,6 @@ static NamedDecl *LookupSingleName(Interpreter &Interp, const char *Name) {
264264
}
265265

266266
TEST_F(InterpreterTest, InstantiateTemplate) {
267-
// FIXME : This test doesn't current work for Emscripten builds.
268-
// It should be possible to make it work.For details on how it fails and
269-
// the current progress to enable this test see
270-
// the following Github issue https: //
271-
// github.com/llvm/llvm-project/issues/153461
272-
#ifdef __EMSCRIPTEN__
273-
GTEST_SKIP() << "Test fails for Emscipten builds";
274-
#endif
275267
// FIXME: We cannot yet handle delayed template parsing. If we run with
276268
// -fdelayed-template-parsing we try adding the newly created decl to the
277269
// active PTU which causes an assert.
@@ -311,14 +303,6 @@ TEST_F(InterpreterTest, InstantiateTemplate) {
311303
}
312304

313305
TEST_F(InterpreterTest, Value) {
314-
// FIXME : This test doesn't current work for Emscripten builds.
315-
// It should be possible to make it work.For details on how it fails and
316-
// the current progress to enable this test see
317-
// the following Github issue https: //
318-
// github.com/llvm/llvm-project/issues/153461
319-
#ifdef __EMSCRIPTEN__
320-
GTEST_SKIP() << "Test fails for Emscipten builds";
321-
#endif
322306
std::vector<const char *> Args = {"-fno-sized-deallocation"};
323307
std::unique_ptr<Interpreter> Interp = createInterpreter(Args);
324308

0 commit comments

Comments
 (0)