[PATCH] D70780: [WebAssembly] Find wasm-opt with GetProgramPath

sunfishcode via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 2 11:49:25 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rG8f1e2151b8e9: [WebAssembly] Find wasm-opt with GetProgramPath (authored by sunfishcode).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70780/new/

https://reviews.llvm.org/D70780

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===================================================================
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -92,10 +92,10 @@
 
   C.addCommand(std::make_unique<Command>(JA, *this, Linker, CmdArgs, Inputs));
 
-  // When optimizing, if wasm-opt is in the PATH, run wasm-opt.
+  // When optimizing, if wasm-opt is available, run it.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
-    if (llvm::ErrorOr<std::string> WasmOptPath =
-           llvm::sys::findProgramByName("wasm-opt")) {
+    auto WasmOptPath = getToolChain().GetProgramPath("wasm-opt");
+    if (WasmOptPath != "wasm-opt") {
       StringRef OOpt = "s";
       if (A->getOption().matches(options::OPT_O4) ||
           A->getOption().matches(options::OPT_Ofast))
@@ -106,7 +106,7 @@
         OOpt = A->getValue();
 
       if (OOpt != "0") {
-        const char *WasmOpt = Args.MakeArgString(*WasmOptPath);
+        const char *WasmOpt = Args.MakeArgString(WasmOptPath);
         ArgStringList CmdArgs;
         CmdArgs.push_back(Output.getFilename());
         CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70780.231746.patch
Type: text/x-patch
Size: 1211 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191202/0585aa5f/attachment.bin>


More information about the cfe-commits mailing list