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

Daniel Dunbar daniel at zuster.org
Fri Apr 3 17:55:30 PDT 2009


Author: ddunbar
Date: Fri Apr  3 19:55:30 2009
New Revision: 68417

URL: http://llvm.org/viewvc/llvm-project?rev=68417&view=rev
Log:
Driver: Handle properly calling dsymutil when source input is
preceeded by a linker input flag.
 - <rdar://problem/6757236> clang should make a dSYM when going
   straight from source to binary

 - This still matches gcc, but the right way to solve this would be to
   detect the situation we care about (we are compiling from source
   and linking in one step), instead of looking at the suffix of the
   input file. The Tool doesn't quite have enough information to do
   this yet, however.

 - Also, find the suffix correctly.

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=68417&r1=68416&r2=68417&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Apr  3 19:55:30 2009
@@ -1446,13 +1446,23 @@
     Args.MakeArgString(getToolChain().GetProgramPath(C, "collect2").c_str());
   Dest.addCommand(new Command(Exec, CmdArgs));  
 
+  // Find the first non-empty base input (we want to ignore linker
+  // inputs).
+  const char *BaseInput = "";
+  for (unsigned i = 0, e = Inputs.size(); i != e; ++i) {
+    if (Inputs[i].getBaseInput()[0] != '\0') {
+      BaseInput = Inputs[i].getBaseInput();
+      break;
+    }
+  }
+  
   if (Args.getLastArg(options::OPT_g_Group) &&
       !Args.getLastArg(options::OPT_gstabs) &&
       !Args.getLastArg(options::OPT_g0)) {
     // FIXME: This is gross, but matches gcc. The test only considers
     // the suffix (not the -x type), and then only of the first
-    // input. Awesome.
-    const char *Suffix = strchr(Inputs[0].getBaseInput(), '.');
+    // source input. Awesome.
+    const char *Suffix = strrchr(BaseInput, '.');
     if (Suffix && isSourceSuffix(Suffix + 1)) {
       const char *Exec = 
        Args.MakeArgString(getToolChain().GetProgramPath(C, "dsymutil").c_str());

Modified: cfe/trunk/test/Driver/darwin-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld.c?rev=68417&r1=68416&r2=68417&view=diff

==============================================================================
--- cfe/trunk/test/Driver/darwin-ld.c (original)
+++ cfe/trunk/test/Driver/darwin-ld.c Fri Apr  3 19:55:30 2009
@@ -17,6 +17,12 @@
 // RUN: grep '"-lcrt1.10.6.o" .*"-lSystem" "-lgcc"' %t.log &&
 // RUN: grep '"-lgcc_s"' %t.log | count 0 &&
 
+// Make sure we run dsymutil on source input files.
+// RUN: clang -ccc-host-triple i386-apple-darwin9 -### -g %s -o BAR 2> %t.log &&
+// RUN: grep '".*dsymutil" "BAR"' %t.log &&
+// RUN: clang -ccc-host-triple i386-apple-darwin9 -### -g -filelist FOO %s -o BAR 2> %t.log &&
+// RUN: grep '".*dsymutil" "BAR"' %t.log &&
+
 // Splatter test case. This is gross, but it works for now. For the
 // driver, just getting coverage of the tool code and checking the
 // output options is nearly good enough. The main thing we are





More information about the cfe-commits mailing list