diff options
-rw-r--r-- | lib/Driver/Tools.cpp | 14 | ||||
-rw-r--r-- | test/Driver/darwin-ld.c | 6 |
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 70daaf5a62..bbf7c9e1a6 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1446,13 +1446,23 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA, 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()); diff --git a/test/Driver/darwin-ld.c b/test/Driver/darwin-ld.c index e5ccb17959..bcef4d3388 100644 --- a/test/Driver/darwin-ld.c +++ b/test/Driver/darwin-ld.c @@ -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 |