aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/ToolChains/WebAssembly.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Driver/ToolChains/WebAssembly.cpp')
-rw-r--r--clang/lib/Driver/ToolChains/WebAssembly.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 10168736400f..6b654886e774 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -114,8 +114,9 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-o");
CmdArgs.push_back(Output.getFilename());
- C.addCommand(std::make_unique<Command>(
- JA, *this, ResponseFileSupport::AtFileCurCP(), Linker, CmdArgs, Inputs));
+ C.addCommand(std::make_unique<Command>(JA, *this,
+ ResponseFileSupport::AtFileCurCP(),
+ Linker, CmdArgs, Inputs, Output));
// When optimizing, if wasm-opt is available, run it.
if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
@@ -139,7 +140,7 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Output.getFilename());
C.addCommand(std::make_unique<Command>(
JA, *this, ResponseFileSupport::AtFileCurCP(), WasmOpt, CmdArgs,
- Inputs));
+ Inputs, Output));
}
}
}
@@ -243,6 +244,27 @@ void WebAssembly::addClangTargetOptions(const ArgList &DriverArgs,
CC1Args.push_back("+sign-ext");
}
+ if (!DriverArgs.hasFlag(options::OPT_mmutable_globals,
+ options::OPT_mno_mutable_globals, false)) {
+ // -fPIC implies +mutable-globals because the PIC ABI used by the linker
+ // depends on importing and exporting mutable globals.
+ llvm::Reloc::Model RelocationModel;
+ unsigned PICLevel;
+ bool IsPIE;
+ std::tie(RelocationModel, PICLevel, IsPIE) =
+ ParsePICArgs(*this, DriverArgs);
+ if (RelocationModel == llvm::Reloc::PIC_) {
+ if (DriverArgs.hasFlag(options::OPT_mno_mutable_globals,
+ options::OPT_mmutable_globals, false)) {
+ getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+ << "-fPIC"
+ << "-mno-mutable-globals";
+ }
+ CC1Args.push_back("-target-feature");
+ CC1Args.push_back("+mutable-globals");
+ }
+ }
+
if (DriverArgs.getLastArg(options::OPT_fwasm_exceptions)) {
// '-fwasm-exceptions' is not compatible with '-mno-exception-handling'
if (DriverArgs.hasFlag(options::OPT_mno_exception_handing,