From 61f0868f1920f80814e6d0195a1bc5b0f0bfc1b1 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Fri, 7 Jun 2013 23:25:01 +0000 Subject: [PATCH] When we're compiling with -pg make sure to link with gcrt1.o on linux. Be 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 | 4 +++- test/Driver/linux-ld.c | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 8e670dbf0a..c407a3bb80 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -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"; diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c index ebac718b33..78223bb06b 100644 --- a/test/Driver/linux-ld.c +++ b/test/Driver/linux-ld.c @@ -667,3 +667,9 @@ // 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 -- 2.40.0