r208948 - InstrProf: Look for the PIC-version of the profile runtime
Duncan P. N. Exon Smith
dexonsmith at apple.com
Thu May 15 21:09:41 PDT 2014
Author: dexonsmith
Date: Thu May 15 23:09:41 2014
New Revision: 208948
URL: http://llvm.org/viewvc/llvm-project?rev=208948&view=rev
Log:
InstrProf: Look for the PIC-version of the profile runtime
If `-shared` is specified, pull in a PIC-version of the profile runtime,
which was added to compiler-rt in r208947. I'm hoping this will get the
bots on my side.
Added:
cfe/trunk/test/Driver/instrprof-ld.c
Modified:
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=208948&r1=208947&r2=208948&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu May 15 23:09:41 2014
@@ -1913,9 +1913,16 @@ static void addProfileRT(
Args.hasArg(options::OPT_coverage)))
return;
+ // -fprofile-instr-generate requires position-independent code to build with
+ // shared objects. Link against the right archive.
+ const char *Lib = "libclang_rt.profile-";
+ if (Args.hasArg(options::OPT_fprofile_instr_generate) &&
+ Args.hasArg(options::OPT_shared))
+ Lib = "libclang_rt.profile-pic-";
+
SmallString<128> LibProfile = getCompilerRTLibDir(TC);
llvm::sys::path::append(LibProfile,
- Twine("libclang_rt.profile-") + getArchNameForCompilerRTLib(TC) + ".a");
+ Twine(Lib) + getArchNameForCompilerRTLib(TC) + ".a");
CmdArgs.push_back(Args.MakeArgString(LibProfile));
}
Added: cfe/trunk/test/Driver/instrprof-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/instrprof-ld.c?rev=208948&view=auto
==============================================================================
--- cfe/trunk/test/Driver/instrprof-ld.c (added)
+++ cfe/trunk/test/Driver/instrprof-ld.c Thu May 15 23:09:41 2014
@@ -0,0 +1,58 @@
+// Test instrumented profiling ld flags.
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -fprofile-instr-generate \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LINUX-I386 %s
+//
+// CHECK-LINUX-I386: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-LINUX-I386: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.profile-i386.a" {{.*}} "-lc"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -fprofile-instr-generate \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LINUX-X86-64 %s
+//
+// CHECK-LINUX-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-LINUX-X86-64: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.profile-x86_64.a" {{.*}} "-lc"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-freebsd -fprofile-instr-generate \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_freebsd64_tree \
+// RUN: | FileCheck --check-prefix=CHECK-FREEBSD-X86-64 %s
+//
+// CHECK-FREEBSD-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-FREEBSD-X86-64: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}freebsd{{/|\\\\}}libclang_rt.profile-x86_64.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -shared \
+// RUN: -target i386-unknown-linux -fprofile-instr-generate \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LINUX-I386-SHARED %s
+//
+// CHECK-LINUX-I386-SHARED: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-LINUX-I386-SHARED: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.profile-pic-i386.a" {{.*}} "-lc"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -shared \
+// RUN: -target x86_64-unknown-linux -fprofile-instr-generate \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LINUX-X86-64-SHARED %s
+//
+// CHECK-LINUX-X86-64-SHARED: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-LINUX-X86-64-SHARED: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.profile-pic-x86_64.a" {{.*}} "-lc"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -shared \
+// RUN: -target x86_64-unknown-freebsd -fprofile-instr-generate \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_freebsd64_tree \
+// RUN: | FileCheck --check-prefix=CHECK-FREEBSD-X86-64-SHARED %s
+//
+// CHECK-FREEBSD-X86-64-SHARED: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-FREEBSD-X86-64-SHARED: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}freebsd{{/|\\\\}}libclang_rt.profile-pic-x86_64.a"
More information about the cfe-commits
mailing list