[cfe-commits] r159683 - in /cfe/trunk: lib/Driver/Tools.cpp test/Driver/darwin-ld.c
Bob Wilson
bob.wilson at apple.com
Tue Jul 3 13:42:11 PDT 2012
Author: bwilson
Date: Tue Jul 3 15:42:10 2012
New Revision: 159683
URL: http://llvm.org/viewvc/llvm-project?rev=159683&view=rev
Log:
When using -pg targeting OS X 10.8, pass -no_new_main to the linker.
By default on OS X 10.8, we don't link with a crt1.o file and the linker
knows to use _main as the entry point. But, when compiling with -pg, we
need to link with the gcrt1.o file, and the linker needs to be told to use
the "start" symbol as the entry point. The -no_new_main linker option does
that last part. <rdar://problem/11491405>
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=159683&r1=159682&r2=159683&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Jul 3 15:42:10 2012
@@ -4341,6 +4341,9 @@
// darwin_crt2 spec is empty.
}
+ if (getDarwinToolChain().isTargetMacOS() &&
+ !getDarwinToolChain().isMacosxVersionLT(10, 8))
+ CmdArgs.push_back("-no_new_main");
} else {
if (Args.hasArg(options::OPT_static) ||
Args.hasArg(options::OPT_object) ||
Modified: cfe/trunk/test/Driver/darwin-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld.c?rev=159683&r1=159682&r2=159683&view=diff
==============================================================================
--- cfe/trunk/test/Driver/darwin-ld.c (original)
+++ cfe/trunk/test/Driver/darwin-ld.c Tue Jul 3 15:42:10 2012
@@ -121,3 +121,8 @@
// RUN: %clang -target x86_64-apple-darwin12 -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_NO_CRT1 %s < %t.log
// LINK_NO_CRT1-NOT: crt
+
+// RUN: %clang -target i386-apple-darwin12 -pg -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_PG %s < %t.log
+// LINK_PG: -lgcrt1.o
+// LINK_PG: -no_new_main
More information about the cfe-commits
mailing list