[dsymutil] Try to find lipo first besides dsymutil before looking up the PATH.
[oota-llvm.git] / tools / dsymutil / MachOUtils.cpp
index b643878946574c1c19444fbbd640410bce7d4809..44cc528ed8f2b2cc4becf40ec9c4d6b81030b856 100644 (file)
@@ -32,8 +32,10 @@ std::string getArchName(StringRef Arch) {
   return Arch;
 }
 
-static bool runLipo(SmallVectorImpl<const char *> &Args) {
-  auto Path = sys::findProgramByName("lipo");
+static bool runLipo(StringRef SDKPath, SmallVectorImpl<const char *> &Args) {
+  auto Path = sys::findProgramByName("lipo", makeArrayRef(SDKPath));
+  if (!Path)
+    Path = sys::findProgramByName("lipo");
 
   if (!Path) {
     errs() << "error: lipo: " << Path.getError().message() << "\n";
@@ -53,7 +55,7 @@ static bool runLipo(SmallVectorImpl<const char *> &Args) {
 
 bool generateUniversalBinary(SmallVectorImpl<ArchAndFilename> &ArchFiles,
                              StringRef OutputFileName,
-                             const LinkOptions &Options) {
+                             const LinkOptions &Options, StringRef SDKPath) {
   // No need to merge one file into a universal fat binary. First, try
   // to move it (rename) to the final location. If that fails because
   // of cross-device link issues then copy and delete.
@@ -95,7 +97,7 @@ bool generateUniversalBinary(SmallVectorImpl<ArchAndFilename> &ArchFiles,
       outs() << ' ' << ((Arg == nullptr) ? "\n" : Arg);
   }
 
-  return Options.NoOutput ? true : runLipo(Args);
+  return Options.NoOutput ? true : runLipo(SDKPath, Args);
 }
 
 // Return a MachO::segment_command_64 that holds the same values as