Skip to content

Commit febdd0b

Browse files
authored
Merge pull request #14 from emscripten-core/merge-19.1.6
Merge 19.1.6 into emscripten-libs-19
2 parents 1304b34 + 4c2a6ab commit febdd0b

File tree

72 files changed

+1309
-240
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1309
-240
lines changed

clang/lib/Driver/ToolChains/Hexagon.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,10 @@ constructHexagonLinkArgs(Compilation &C, const JobAction &JA,
294294
bool IncStartFiles = !Args.hasArg(options::OPT_nostartfiles);
295295
bool IncDefLibs = !Args.hasArg(options::OPT_nodefaultlibs);
296296
bool UseG0 = false;
297-
const char *Exec = Args.MakeArgString(HTC.GetLinkerPath());
298-
bool UseLLD = (llvm::sys::path::filename(Exec).equals_insensitive("ld.lld") ||
299-
llvm::sys::path::stem(Exec).equals_insensitive("ld.lld"));
297+
bool UseLLD = false;
298+
const char *Exec = Args.MakeArgString(HTC.GetLinkerPath(&UseLLD));
299+
UseLLD = UseLLD || llvm::sys::path::filename(Exec).ends_with("ld.lld") ||
300+
llvm::sys::path::stem(Exec).ends_with("ld.lld");
300301
bool UseShared = IsShared && !IsStatic;
301302
StringRef CpuVer = toolchains::HexagonToolChain::GetTargetCPUVersion(Args);
302303

clang/lib/Interpreter/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ set(LLVM_LINK_COMPONENTS
1515
if (EMSCRIPTEN AND "lld" IN_LIST LLVM_ENABLE_PROJECTS)
1616
set(WASM_SRC Wasm.cpp)
1717
set(WASM_LINK lldWasm)
18+
set(COMMON_LINK lldCommon)
1819
endif()
1920

2021
add_clang_library(clangInterpreter
@@ -45,6 +46,7 @@ add_clang_library(clangInterpreter
4546
clangSema
4647
clangSerialization
4748
${WASM_LINK}
49+
${COMMON_LINK}
4850
)
4951

5052
if ((MINGW OR CYGWIN) AND BUILD_SHARED_LIBS)

clang/lib/Interpreter/IncrementalExecutor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class IncrementalExecutor {
5656
virtual llvm::Error addModule(PartialTranslationUnit &PTU);
5757
virtual llvm::Error removeModule(PartialTranslationUnit &PTU);
5858
virtual llvm::Error runCtors() const;
59-
llvm::Error cleanUp();
59+
virtual llvm::Error cleanUp();
6060
llvm::Expected<llvm::orc::ExecutorAddr>
6161
getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
6262

clang/lib/Interpreter/Interpreter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ IncrementalCompilerBuilder::CreateCpp() {
192192
#ifdef __EMSCRIPTEN__
193193
Argv.push_back("-target");
194194
Argv.push_back("wasm32-unknown-emscripten");
195-
Argv.push_back("-pie");
196195
Argv.push_back("-shared");
196+
Argv.push_back("-fvisibility=default");
197197
#endif
198198
Argv.insert(Argv.end(), UserArgs.begin(), UserArgs.end());
199199

clang/lib/Interpreter/Wasm.cpp

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,31 @@
2323
#include <string>
2424

2525
namespace lld {
26+
enum Flavor {
27+
Invalid,
28+
Gnu, // -flavor gnu
29+
MinGW, // -flavor gnu MinGW
30+
WinLink, // -flavor link
31+
Darwin, // -flavor darwin
32+
Wasm, // -flavor wasm
33+
};
34+
35+
using Driver = bool (*)(llvm::ArrayRef<const char *>, llvm::raw_ostream &,
36+
llvm::raw_ostream &, bool, bool);
37+
38+
struct DriverDef {
39+
Flavor f;
40+
Driver d;
41+
};
42+
43+
struct Result {
44+
int retCode;
45+
bool canRunAgain;
46+
};
47+
48+
Result lldMain(llvm::ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
49+
llvm::raw_ostream &stderrOS, llvm::ArrayRef<DriverDef> drivers);
50+
2651
namespace wasm {
2752
bool link(llvm::ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
2853
llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput);
@@ -51,13 +76,14 @@ llvm::Error WasmIncrementalExecutor::addModule(PartialTranslationUnit &PTU) {
5176
llvm::TargetMachine *TargetMachine = Target->createTargetMachine(
5277
PTU.TheModule->getTargetTriple(), "", "", TO, llvm::Reloc::Model::PIC_);
5378
PTU.TheModule->setDataLayout(TargetMachine->createDataLayout());
54-
std::string OutputFileName = PTU.TheModule->getName().str() + ".wasm";
79+
std::string ObjectFileName = PTU.TheModule->getName().str() + ".o";
80+
std::string BinaryFileName = PTU.TheModule->getName().str() + ".wasm";
5581

5682
std::error_code Error;
57-
llvm::raw_fd_ostream OutputFile(llvm::StringRef(OutputFileName), Error);
83+
llvm::raw_fd_ostream ObjectFileOutput(llvm::StringRef(ObjectFileName), Error);
5884

5985
llvm::legacy::PassManager PM;
60-
if (TargetMachine->addPassesToEmitFile(PM, OutputFile, nullptr,
86+
if (TargetMachine->addPassesToEmitFile(PM, ObjectFileOutput, nullptr,
6187
llvm::CodeGenFileType::ObjectFile)) {
6288
return llvm::make_error<llvm::StringError>(
6389
"Wasm backend cannot produce object.", llvm::inconvertibleErrorCode());
@@ -69,27 +95,30 @@ llvm::Error WasmIncrementalExecutor::addModule(PartialTranslationUnit &PTU) {
6995
llvm::inconvertibleErrorCode());
7096
}
7197

72-
OutputFile.close();
98+
ObjectFileOutput.close();
7399

74100
std::vector<const char *> LinkerArgs = {"wasm-ld",
75-
"-pie",
101+
"-shared",
76102
"--import-memory",
77-
"--no-entry",
78-
"--export-all",
79103
"--experimental-pic",
80-
"--no-export-dynamic",
81104
"--stack-first",
82-
OutputFileName.c_str(),
105+
"--allow-undefined",
106+
ObjectFileName.c_str(),
83107
"-o",
84-
OutputFileName.c_str()};
85-
int Result =
86-
lld::wasm::link(LinkerArgs, llvm::outs(), llvm::errs(), false, false);
87-
if (!Result)
108+
BinaryFileName.c_str()};
109+
110+
const lld::DriverDef WasmDriver = {lld::Flavor::Wasm, &lld::wasm::link};
111+
std::vector<lld::DriverDef> WasmDriverArgs;
112+
WasmDriverArgs.push_back(WasmDriver);
113+
lld::Result Result =
114+
lld::lldMain(LinkerArgs, llvm::outs(), llvm::errs(), WasmDriverArgs);
115+
116+
if (Result.retCode)
88117
return llvm::make_error<llvm::StringError>(
89118
"Failed to link incremental module", llvm::inconvertibleErrorCode());
90119

91120
void *LoadedLibModule =
92-
dlopen(OutputFileName.c_str(), RTLD_NOW | RTLD_GLOBAL);
121+
dlopen(BinaryFileName.c_str(), RTLD_NOW | RTLD_GLOBAL);
93122
if (LoadedLibModule == nullptr) {
94123
llvm::errs() << dlerror() << '\n';
95124
return llvm::make_error<llvm::StringError>(
@@ -109,6 +138,12 @@ llvm::Error WasmIncrementalExecutor::runCtors() const {
109138
return llvm::Error::success();
110139
}
111140

141+
llvm::Error WasmIncrementalExecutor::cleanUp() {
142+
// Can't call cleanUp through IncrementalExecutor as it
143+
// tries to deinitialize JIT which hasn't been initialized
144+
return llvm::Error::success();
145+
}
146+
112147
WasmIncrementalExecutor::~WasmIncrementalExecutor() = default;
113148

114-
} // namespace clang
149+
} // namespace clang

clang/lib/Interpreter/Wasm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class WasmIncrementalExecutor : public IncrementalExecutor {
2828
llvm::Error addModule(PartialTranslationUnit &PTU) override;
2929
llvm::Error removeModule(PartialTranslationUnit &PTU) override;
3030
llvm::Error runCtors() const override;
31+
llvm::Error cleanUp() override;
3132

3233
~WasmIncrementalExecutor() override;
3334
};

clang/utils/perf-training/perf-helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def clean(args):
3636
+ "\tRemoves all files with extension from <path>."
3737
)
3838
return 1
39-
for path in args[1:-1]:
39+
for path in args[0:-1]:
4040
for filename in findFilesWithExtension(path, args[-1]):
4141
os.remove(filename)
4242
return 0

cmake/Modules/LLVMVersion.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR)
77
set(LLVM_VERSION_MINOR 1)
88
endif()
99
if(NOT DEFINED LLVM_VERSION_PATCH)
10-
set(LLVM_VERSION_PATCH 4)
10+
set(LLVM_VERSION_PATCH 6)
1111
endif()
1212
if(NOT DEFINED LLVM_VERSION_SUFFIX)
1313
set(LLVM_VERSION_SUFFIX)

compiler-rt/test/asan/TestCases/Windows/delay_dbghelp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// static build, there won't be any clang_rt DLLs.
1010
// RUN: not grep cl""ang_rt %t || \
1111
// RUN: grep cl""ang_rt %t | xargs which | \
12-
// RUN: xargs llvm-readobj --coff-imports | not grep dbghelp.dll %t
12+
// RUN: xargs llvm-readobj --coff-imports | not grep dbghelp.dll
1313

1414
extern "C" int puts(const char *);
1515

libcxx/include/__config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
// _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM.
2828
// Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is
2929
// defined to XXYYZZ.
30-
# define _LIBCPP_VERSION 190104
30+
# define _LIBCPP_VERSION 190106
3131

3232
# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
3333
# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)

0 commit comments

Comments
 (0)