]> granicus.if.org Git - clang/commitdiff
When we're compiling with -pg make sure to link with gcrt1.o on linux. Be
authorEric Christopher <echristo@gmail.com>
Fri, 7 Jun 2013 23:25:01 +0000 (23:25 +0000)
committerEric Christopher <echristo@gmail.com>
Fri, 7 Jun 2013 23:25:01 +0000 (23:25 +0000)
sure to do this always, this matches the behavior for the gcc driver.

Fixes PR16251.

Based on a patch by Qiao Yang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183591 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
test/Driver/linux-ld.c

index 8e670dbf0a3d67c4e013c61797f8a5eebf81be17..c407a3bb805c0867dd98bb30ded9d60e56738500 100644 (file)
@@ -6076,7 +6076,9 @@ void gnutools::Link::ConstructJob(Compilation &C, const JobAction &JA,
     if (!isAndroid) {
       const char *crt1 = NULL;
       if (!Args.hasArg(options::OPT_shared)){
-        if (IsPIE)
+        if (Args.hasArg(options::OPT_pg))
+          crt1 = "gcrt1.o";
+        else if (IsPIE)
           crt1 = "Scrt1.o";
         else
           crt1 = "crt1.o";
index ebac718b33b87cd6becb02d04c2c4a7c66d2dd0c..78223bb06bc36d2c51ba9db4fea6a2cd142fc6ac 100644 (file)
 // RUN:   | FileCheck --check-prefix=CHECK-NOCRTFASTMATH %s
 // CHECK-CRTFASTMATH: usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtfastmath.o
 // CHECK-NOCRTFASTMATH-NOT: crtfastmath.o
+
+// Check that we link in gcrt1.o when compiling with -pg
+// RUN: %clang -pg -target x86_64-unknown-linux -### %s \
+// RUN:        --sysroot=%S/Inputs/basic_linux_tree 2>& 1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG %s
+// CHECK-PG: gcrt1.o