Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions clang/lib/Driver/ToolChains/WebAssembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ void cheerp::Link::ConstructJob(Compilation &C, const JobAction &JA,
AddStdLib("libc.bc");
AddStdLib("crt1.bc");
}
if (getToolChain().getTriple().getOS() == llvm::Triple::WASI)
if (getToolChain().getTriple().isCheerpWasi())
AddStdLib("libwasi.bc");
else
AddStdLib("libsystem.bc");
Expand Down Expand Up @@ -699,7 +699,7 @@ void cheerp::CheerpOptimizer::ConstructJob(Compilation &C, const JobAction &JA,
cheerpFixFuncCasts->render(Args, CmdArgs);
if(Arg* cheerpUseBigInts = Args.getLastArg(options::OPT_cheerp_use_bigints))
cheerpUseBigInts->render(Args, CmdArgs);
else if (getToolChain().getTriple().getOS() == llvm::Triple::WASI)
else if (getToolChain().getTriple().isCheerpWasmStandalone())
CmdArgs.push_back("-cheerp-use-bigints");

// Malloc/Free are probably intercepted when using sanitizers, don't optimize
Expand Down Expand Up @@ -878,7 +878,6 @@ void cheerp::CheerpCompiler::ConstructJob(Compilation &C, const JobAction &JA,
}

bool isCheerpWasm = getToolChain().getTriple().isCheerpWasm();
llvm::Triple::OSType os = getToolChain().getTriple().getOS();
Arg* cheerpLinearOutput = Args.getLastArg(options::OPT_cheerp_linear_output_EQ);
if (cheerpLinearOutput)
cheerpLinearOutput->render(Args, CmdArgs);
Expand Down Expand Up @@ -918,7 +917,7 @@ void cheerp::CheerpCompiler::ConstructJob(Compilation &C, const JobAction &JA,
if(Arg* cheerpSecondaryOutputFile = Args.getLastArg(options::OPT_cheerp_secondary_output_file_EQ))
cheerpSecondaryOutputFile->render(Args, CmdArgs);
else if(
((isCheerpWasm && os != llvm::Triple::WASI && !cheerpLinearOutput) ||
((isCheerpWasm && !getToolChain().getTriple().isCheerpWasmStandalone() && !cheerpLinearOutput) ||
(cheerpLinearOutput && cheerpLinearOutput->getValue() != StringRef("asmjs"))))
{
SmallString<64> path(Output.getFilename());
Expand Down Expand Up @@ -1072,7 +1071,7 @@ void cheerp::CheerpCompiler::ConstructJob(Compilation &C, const JobAction &JA,
cheerpFixFuncCasts->render(Args, CmdArgs);
if(Arg* cheerpUseBigInts = Args.getLastArg(options::OPT_cheerp_use_bigints))
cheerpUseBigInts->render(Args, CmdArgs);
else if (getToolChain().getTriple().getOS() == llvm::Triple::WASI)
else if (getToolChain().getTriple().isCheerpWasmStandalone())
CmdArgs.push_back("-cheerp-use-bigints");
if(Arg* cheerpMakeDTS = Args.getLastArg(options::OPT_cheerp_make_dts))
cheerpMakeDTS->render(Args, CmdArgs);
Expand Down
3 changes: 3 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ override_dh_auto_build:

override_dh_auto_install:
CHEERP_DEST=$$(pwd)/debian/cheerp-core ./debian/build.sh install

override_dh_strip:
dh_strip --no-automatic-dbgsym
8 changes: 8 additions & 0 deletions llvm/include/llvm/ADT/Triple.h
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,14 @@ class Triple {
return getArch() == Triple::cheerp && getEnvironment() == Triple::WebAssembly;
}

bool isCheerpWasi() const {
return getArch() == Triple::cheerp && getOS() == Triple::WASI;
}

bool isCheerpWasmStandalone() const {
return isCheerpWasi();
}

/// Tests whether the target is cheerp (including cheerp-wasm and cheerp-genericjs)
bool isCheerp() const{
return getArch() == Triple::cheerp;
Expand Down
11 changes: 6 additions & 5 deletions llvm/lib/CheerpUtils/CallConstructors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ namespace cheerp

PreservedAnalyses CallConstructorsPass::run(llvm::Module &M, llvm::ModuleAnalysisManager &MPA)
{
bool Wasi = Triple(M.getTargetTriple()).getOS() == Triple::WASI;
bool useUtilityThread = !LowerAtomics && !Wasi;
Triple triple = Triple(M.getTargetTriple());
bool isWasmStandalone = triple.isCheerpWasmStandalone();
bool useUtilityThread = !LowerAtomics && !isWasmStandalone;
FunctionType* Ty = FunctionType::get(Type::getVoidTy(M.getContext()), false);
Function* StartFunction = cast<Function>(M.getOrInsertFunction("_start", Ty).getCallee());
if (!StartFunction->empty())
Expand Down Expand Up @@ -76,7 +77,7 @@ PreservedAnalyses CallConstructorsPass::run(llvm::Module &M, llvm::ModuleAnalysi
}

Function* Main = getMainFunction(M);
if (Wasi || (Main && Main->getSection() == "asmjs"))
if (isWasmStandalone || (Main && Main->getSection() == "asmjs"))
{
StartFunction->setSection("asmjs");
if (useUtilityThread)
Expand Down Expand Up @@ -138,9 +139,9 @@ PreservedAnalyses CallConstructorsPass::run(llvm::Module &M, llvm::ModuleAnalysi
{
ExitCode = Builder.CreateCall(Main->getFunctionType(), Main);
}
if (!LowerAtomics || Wasi)
if (!LowerAtomics || isWasmStandalone)
{
// In WASI mode, or if -pthread has been passed, we call exit after main, which will run global destructors
// In standalone mode, or if -pthread has been passed, we call exit after main, which will run global destructors
Function* Exit = M.getFunction("exit");
assert(Exit != nullptr);
if (ExitCode->getType() != Builder.getInt32Ty())
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/WebAssembly/CheerpWritePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ PreservedAnalyses cheerp::CheerpWritePassImpl::run(Module& M, ModuleAnalysisMana
}

Triple TargetTriple(M.getTargetTriple());
bool WasmOnly = TargetTriple.getOS() == Triple::WASI;
bool WasmOnly = TargetTriple.isCheerpWasmStandalone();
std::error_code ErrorCode;
llvm::ToolOutputFile secondaryFile(SecondaryOutputFile, ErrorCode, sys::fs::OF_None);
std::unique_ptr<llvm::formatted_raw_ostream> secondaryOut;
Expand Down
Loading