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";
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.
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
};
bool generateUniversalBinary(SmallVectorImpl<ArchAndFilename> &ArchFiles,
- StringRef OutputFileName, const LinkOptions &);
+ StringRef OutputFileName, const LinkOptions &,
+ StringRef SDKPath);
bool generateDsymCompanion(const DebugMap &DM, MCStreamer &MS,
raw_fd_ostream &OutFile);
llvm::PrettyStackTraceProgram StackPrinter(argc, argv);
llvm::llvm_shutdown_obj Shutdown;
LinkOptions Options;
+ void *MainAddr = reinterpret_cast<void *>(&exitDsymutil);
+ std::string SDKPath = llvm::sys::fs::getMainExecutable(argv[0], MainAddr);
+ SDKPath = llvm::sys::path::parent_path(SDKPath);
HideUnrelatedOptions(DsymCategory);
llvm::cl::ParseCommandLineOptions(
if (NeedsTempFiles &&
!MachOUtils::generateUniversalBinary(
- TempFiles, getOutputFileName(InputFile), Options))
+ TempFiles, getOutputFileName(InputFile), Options, SDKPath))
exitDsymutil(1);
}