Skip to content

Commit de87852

Browse files
committed
Enable running ClangReplInterpreterTests in an Emscripten environment
1 parent 4b1d5b8 commit de87852

File tree

5 files changed

+65
-15
lines changed

5 files changed

+65
-15
lines changed

clang/unittests/Interpreter/CMakeLists.txt

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
if(EMSCRIPTEN)
2+
set(LLVM_COMPONENTS_TO_LINK
3+
""
4+
)
5+
set(LLVM_LIBS_TO_LINK
6+
""
7+
)
8+
set(CLANG_LIBS_TO_LINK
9+
clangInterpreter
10+
)
11+
else()
12+
set(LLVM_COMPONENTS_TO_LINK
13+
${LLVM_TARGETS_TO_BUILD}
14+
Core
15+
MC
16+
OrcJIT
17+
Support
18+
TargetParser
19+
)
20+
set(LLVM_LIBS_TO_LINK
21+
LLVMTestingSupport
22+
)
23+
set(CLANG_LIBS_TO_LINK
24+
clangAST
25+
clangBasic
26+
clangInterpreter
27+
clangFrontend
28+
clangSema
29+
)
30+
endif()
31+
132
add_distinct_clang_unittest(ClangReplInterpreterTests
233
IncrementalCompilerBuilderTest.cpp
334
IncrementalProcessingTest.cpp
@@ -8,24 +39,28 @@ add_distinct_clang_unittest(ClangReplInterpreterTests
839
EXPORT_SYMBOLS
940

1041
CLANG_LIBS
11-
clangAST
12-
clangBasic
13-
clangInterpreter
14-
clangFrontend
15-
clangSema
42+
${CLANG_LIBS_TO_LINK}
1643

1744
LINK_LIBS
18-
LLVMTestingSupport
45+
${LLVM_LIBS_TO_LINK}
1946

2047
LLVM_COMPONENTS
21-
${LLVM_TARGETS_TO_BUILD}
22-
Core
23-
MC
24-
OrcJIT
25-
Support
26-
TargetParser
48+
${LLVM_COMPONENTS_TO_LINK}
2749
)
2850

51+
if(EMSCRIPTEN)
52+
target_link_options(ClangReplInterpreterTests
53+
PUBLIC "SHELL: -s MAIN_MODULE=1"
54+
PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1"
55+
PUBLIC "SHELL: -s STACK_SIZE=32mb"
56+
PUBLIC "SHELL: -s INITIAL_MEMORY=128mb"
57+
PUBLIC "SHELL: --emrun"
58+
)
59+
set_target_properties(ClangReplInterpreterTests PROPERTIES
60+
SUFFIX ".html"
61+
)
62+
endif()
63+
2964
# Exceptions on Windows are not yet supported.
3065
if(NOT WIN32)
3166
add_subdirectory(ExceptionTests)

clang/unittests/Interpreter/IncrementalCompilerBuilderTest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ TEST(IncrementalCompilerBuilder, SetCompilerArgs) {
3737
}
3838

3939
TEST(IncrementalCompilerBuilder, SetTargetTriple) {
40+
#ifdef EMSCRIPTEN
41+
GTEST_SKIP() << "Test fails for Emscipten builds";
42+
#endif
4043
auto CB = clang::IncrementalCompilerBuilder();
4144
CB.SetTargetTriple("armv6-none-eabi");
4245
auto CI = cantFail(CB.CreateCpp());

clang/unittests/Interpreter/InterpreterTest.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ TEST_F(InterpreterTest, DeclsAndStatements) {
147147
}
148148

149149
TEST_F(InterpreterTest, UndoCommand) {
150+
#ifdef EMSCRIPTEN
151+
GTEST_SKIP() << "Test fails for Emscipten builds";
152+
#endif
150153
Args ExtraArgs = {"-Xclang", "-diagnostic-log-file", "-Xclang", "-"};
151154

152155
// Create the diagnostic engine with unowned consumer.
@@ -256,6 +259,9 @@ static NamedDecl *LookupSingleName(Interpreter &Interp, const char *Name) {
256259
}
257260

258261
TEST_F(InterpreterTest, InstantiateTemplate) {
262+
#ifdef EMSCRIPTEN
263+
GTEST_SKIP() << "Test fails for Emscipten builds";
264+
#endif
259265
// FIXME: We cannot yet handle delayed template parsing. If we run with
260266
// -fdelayed-template-parsing we try adding the newly created decl to the
261267
// active PTU which causes an assert.
@@ -295,6 +301,9 @@ TEST_F(InterpreterTest, InstantiateTemplate) {
295301
}
296302

297303
TEST_F(InterpreterTest, Value) {
304+
#ifdef EMSCRIPTEN
305+
GTEST_SKIP() << "Test fails for Emscipten builds";
306+
#endif
298307
std::vector<const char *> Args = {"-fno-sized-deallocation"};
299308
std::unique_ptr<Interpreter> Interp = createInterpreter(Args);
300309

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,9 @@ function(add_unittest test_suite test_name)
17641764
set(LLVM_REQUIRES_RTTI OFF)
17651765
endif()
17661766
1767-
list(APPEND LLVM_LINK_COMPONENTS Support) # gtest needs it for raw_ostream
1767+
if(NOT EMSCRIPTEN)
1768+
list(APPEND LLVM_LINK_COMPONENTS Support) # gtest needs it for raw_ostream
1769+
endif()
17681770
add_llvm_executable(${test_name} IGNORE_EXTERNALIZE_DEBUGINFO NO_INSTALL_RPATH ${ARGN})
17691771
get_subproject_title(subproject_title)
17701772
set_target_properties(${test_name} PROPERTIES FOLDER "${subproject_title}/Tests/Unit")

llvm/lib/Target/WebAssembly/TargetInfo/WebAssemblyTargetInfo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ Target &llvm::getTheWebAssemblyTarget64() {
2929

3030
extern "C" LLVM_ABI LLVM_EXTERNAL_VISIBILITY void
3131
LLVMInitializeWebAssemblyTargetInfo() {
32-
RegisterTarget<Triple::wasm32> X(getTheWebAssemblyTarget32(), "wasm32",
33-
"WebAssembly 32-bit", "WebAssembly");
32+
RegisterTarget<Triple::wasm32, /*HasJIT=*/true> X(
33+
getTheWebAssemblyTarget32(), "wasm32", "WebAssembly 32-bit",
34+
"WebAssembly");
3435
RegisterTarget<Triple::wasm64> Y(getTheWebAssemblyTarget64(), "wasm64",
3536
"WebAssembly 64-bit", "WebAssembly");
3637
}

0 commit comments

Comments
 (0)