diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp index d1d6809d2474..085dc51b9182 100644 --- a/clang/lib/Driver/ToolChains/WebAssembly.cpp +++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp @@ -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"); @@ -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 @@ -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); @@ -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()); @@ -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); diff --git a/debian/rules b/debian/rules index 054c2df48f59..d46d347c1331 100755 --- a/debian/rules +++ b/debian/rules @@ -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 diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h index 50ecc1d96177..acb240d19135 100644 --- a/llvm/include/llvm/ADT/Triple.h +++ b/llvm/include/llvm/ADT/Triple.h @@ -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; diff --git a/llvm/lib/CheerpUtils/CallConstructors.cpp b/llvm/lib/CheerpUtils/CallConstructors.cpp index 5653a100d8ae..393310717aa0 100644 --- a/llvm/lib/CheerpUtils/CallConstructors.cpp +++ b/llvm/lib/CheerpUtils/CallConstructors.cpp @@ -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(M.getOrInsertFunction("_start", Ty).getCallee()); if (!StartFunction->empty()) @@ -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) @@ -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()) diff --git a/llvm/lib/Target/WebAssembly/CheerpWritePass.cpp b/llvm/lib/Target/WebAssembly/CheerpWritePass.cpp index f5120a1869a5..fd81c4182e7c 100644 --- a/llvm/lib/Target/WebAssembly/CheerpWritePass.cpp +++ b/llvm/lib/Target/WebAssembly/CheerpWritePass.cpp @@ -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 secondaryOut;