[cfe-commits] r133543 - in /cfe/trunk: lib/Driver/Tools.cpp test/Driver/darwin-ld.c

Daniel Dunbar daniel at zuster.org
Tue Jun 21 13:55:11 PDT 2011


Author: ddunbar
Date: Tue Jun 21 15:55:11 2011
New Revision: 133543

URL: http://llvm.org/viewvc/llvm-project?rev=133543&view=rev
Log:
Driver/Darwin: When invoking the linker, automatically pass -object_path_lto so
that the linker has a place to put the temporary object file and can leave it
around (for the driver to clean up). This is important so that the object file
references in the debug info are preserved for possible use by dsymutil.
 - <rdar://problem/8294279> executable has no debug symbols when compiled with LTO

Modified:
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/test/Driver/darwin-ld.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=133543&r1=133542&r2=133543&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Jun 21 15:55:11 2011
@@ -2907,6 +2907,17 @@
       CmdArgs.push_back("-demangle");
   }
 
+  // If we are using LTO, then automatically create a temporary file path for
+  // the linker to use, so that it's lifetime will extend past a possible
+  // dsymutil step.
+  if (Version[0] >= 100 && D.IsUsingLTO(Args)) {
+    const char *TmpPath = C.getArgs().MakeArgString(
+      D.GetTemporaryPath(types::getTypeTempSuffix(types::TY_Object)));
+    C.addTempFile(TmpPath);
+    CmdArgs.push_back("-object_path_lto");
+    CmdArgs.push_back(TmpPath);
+  }
+
   // Derived from the "link" spec.
   Args.AddAllArgs(CmdArgs, options::OPT_static);
   if (!Args.hasArg(options::OPT_static))

Modified: cfe/trunk/test/Driver/darwin-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld.c?rev=133543&r1=133542&r2=133543&view=diff
==============================================================================
--- cfe/trunk/test/Driver/darwin-ld.c (original)
+++ cfe/trunk/test/Driver/darwin-ld.c Tue Jun 21 15:55:11 2011
@@ -92,3 +92,11 @@
 // LINK_OLDER_NODEMANGLE: {{ld(.exe)?"}}
 // LINK_OLDER_NODEMANGLE-NOT: "-demangle"
 // LINK_OLDER_NODEMANGLE: "-lSystem"
+
+// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### %t.o \
+// RUN:   -mlinker-version=101 -flto 2> %t.log
+// RUN: cat %t.log
+// RUN: FileCheck -check-prefix=LINK_OBJECT_LTO_PATH %s < %t.log
+//
+// LINK_OBJECT_LTO_PATH: {{ld(.exe)?"}}
+// LINK_OBJECT_LTO_PATH: "-object_path_lto"





More information about the cfe-commits mailing list