[llvm] r249762 - [dsymutil] Try to find lipo first besides dsymutil before looking up the PATH.
Aaron Ballman via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 9 06:38:35 PDT 2015
On Thu, Oct 8, 2015 at 6:35 PM, Frederic Riss via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: friss
> Date: Thu Oct 8 17:35:53 2015
> New Revision: 249762
>
> URL: http://llvm.org/viewvc/llvm-project?rev=249762&view=rev
> Log:
> [dsymutil] Try to find lipo first besides dsymutil before looking up the PATH.
>
> Even if we don't have it in PATH, lipo should usually exist in the same directory
> as dsymutil. Keep the fallback looking up the PATH, it's very useful when
> testing a non-installed executable.
>
> Modified:
> llvm/trunk/tools/dsymutil/MachOUtils.cpp
> llvm/trunk/tools/dsymutil/MachOUtils.h
> llvm/trunk/tools/dsymutil/dsymutil.cpp
>
> Modified: llvm/trunk/tools/dsymutil/MachOUtils.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/MachOUtils.cpp?rev=249762&r1=249761&r2=249762&view=diff
> ==============================================================================
> --- llvm/trunk/tools/dsymutil/MachOUtils.cpp (original)
> +++ llvm/trunk/tools/dsymutil/MachOUtils.cpp Thu Oct 8 17:35:53 2015
> @@ -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<cons
>
> 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(SmallVector
> 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
>
> Modified: llvm/trunk/tools/dsymutil/MachOUtils.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/MachOUtils.h?rev=249762&r1=249761&r2=249762&view=diff
> ==============================================================================
> --- llvm/trunk/tools/dsymutil/MachOUtils.h (original)
> +++ llvm/trunk/tools/dsymutil/MachOUtils.h Thu Oct 8 17:35:53 2015
> @@ -26,7 +26,8 @@ struct ArchAndFilename {
> };
>
> 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);
>
> Modified: llvm/trunk/tools/dsymutil/dsymutil.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/dsymutil.cpp?rev=249762&r1=249761&r2=249762&view=diff
> ==============================================================================
> --- llvm/trunk/tools/dsymutil/dsymutil.cpp (original)
> +++ llvm/trunk/tools/dsymutil/dsymutil.cpp Thu Oct 8 17:35:53 2015
> @@ -237,6 +237,9 @@ int main(int argc, char **argv) {
> llvm::PrettyStackTraceProgram StackPrinter(argc, argv);
> llvm::llvm_shutdown_obj Shutdown;
> LinkOptions Options;
> + void *MainAddr = reinterpret_cast<void *>(&exitDsymutil);
This change is triggering the following diagnostic:
/opt/llvm/build-llvm/src/llvm/tools/dsymutil/dsymutil.cpp: In function
‘int main(int, char**)’:
/opt/llvm/build-llvm/src/llvm/tools/dsymutil/dsymutil.cpp:240:58:
warning: ISO C++ forbids casting between pointer-to-function and
pointer-to-object [enabled by default]
~Aaron
> + std::string SDKPath = llvm::sys::fs::getMainExecutable(argv[0], MainAddr);
> + SDKPath = llvm::sys::path::parent_path(SDKPath);
>
> HideUnrelatedOptions(DsymCategory);
> llvm::cl::ParseCommandLineOptions(
> @@ -330,7 +333,7 @@ int main(int argc, char **argv) {
>
> if (NeedsTempFiles &&
> !MachOUtils::generateUniversalBinary(
> - TempFiles, getOutputFileName(InputFile), Options))
> + TempFiles, getOutputFileName(InputFile), Options, SDKPath))
> exitDsymutil(1);
> }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list