forked from OSchip/llvm-project
[Profile] Always build profile runtime library with -fPIC.
This change removes libclang_rt.profile-pic-<arch>.a version of profile runtime. Instead, it's sufficient to always build libclang_rt.profile-<arch>.a with -fPIC, as it can be linked into both executables and shared objects. llvm-svn: 221952
This commit is contained in:
parent
77349e7aaf
commit
cbbd2fd8d6
|
@ -2181,16 +2181,10 @@ 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(Lib) + getArchNameForCompilerRTLib(TC) + ".a");
|
||||
llvm::sys::path::append(LibProfile, Twine("libclang_rt.profile-") +
|
||||
getArchNameForCompilerRTLib(TC) +
|
||||
".a");
|
||||
|
||||
CmdArgs.push_back(Args.MakeArgString(LibProfile));
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
// 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"
|
||||
// CHECK-LINUX-I386-SHARED: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.profile-i386.a" {{.*}} "-lc"
|
||||
//
|
||||
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
// RUN: -shared \
|
||||
|
@ -45,7 +45,7 @@
|
|||
// 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"
|
||||
// CHECK-LINUX-X86-64-SHARED: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.profile-x86_64.a" {{.*}} "-lc"
|
||||
//
|
||||
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
// RUN: -shared \
|
||||
|
@ -55,4 +55,4 @@
|
|||
// 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"
|
||||
// CHECK-FREEBSD-X86-64-SHARED: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}freebsd{{/|\\\\}}libclang_rt.profile-x86_64.a"
|
||||
|
|
|
@ -17,13 +17,9 @@ if(APPLE)
|
|||
else()
|
||||
foreach(arch ${PROFILE_SUPPORTED_ARCH})
|
||||
add_compiler_rt_runtime(clang_rt.profile-${arch} ${arch} STATIC
|
||||
SOURCES ${PROFILE_SOURCES})
|
||||
add_dependencies(profile clang_rt.profile-${arch})
|
||||
|
||||
add_compiler_rt_runtime(clang_rt.profile-pic-${arch} ${arch} STATIC
|
||||
CFLAGS -fPIC
|
||||
SOURCES ${PROFILE_SOURCES})
|
||||
add_dependencies(profile clang_rt.profile-pic-${arch})
|
||||
add_dependencies(profile clang_rt.profile-${arch})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
|
|
Loading…
Reference in New Issue