forked from OSchip/llvm-project
Get rid of obsolete addProfileRT(), generalize the relevant addProfileRTLinux() to all OS
llvm-svn: 201789
This commit is contained in:
parent
8690a6860a
commit
7811d19515
|
@ -225,26 +225,6 @@ static bool isObjCRuntimeLinked(const ArgList &Args) {
|
|||
return Args.hasArg(options::OPT_fobjc_link_runtime);
|
||||
}
|
||||
|
||||
static void addProfileRT(const ToolChain &TC, const ArgList &Args,
|
||||
ArgStringList &CmdArgs,
|
||||
llvm::Triple Triple) {
|
||||
if (!(Args.hasArg(options::OPT_fprofile_arcs) ||
|
||||
Args.hasArg(options::OPT_fprofile_generate) ||
|
||||
Args.hasArg(options::OPT_fprofile_instr_generate) ||
|
||||
Args.hasArg(options::OPT_fcreate_profile) ||
|
||||
Args.hasArg(options::OPT_coverage)))
|
||||
return;
|
||||
|
||||
// GCC links libgcov.a by adding -L<inst>/gcc/lib/gcc/<triple>/<ver> -lgcov to
|
||||
// the link line. We cannot do the same thing because unlike gcov there is a
|
||||
// libprofile_rt.so. We used to use the -l:libprofile_rt.a syntax, but that is
|
||||
// not supported by old linkers.
|
||||
std::string ProfileRT =
|
||||
std::string(TC.getDriver().Dir) + "/../lib/libprofile_rt.a";
|
||||
|
||||
CmdArgs.push_back(Args.MakeArgString(ProfileRT));
|
||||
}
|
||||
|
||||
static bool forwardToGCC(const Option &O) {
|
||||
// Don't forward inputs from the original command line. They are added from
|
||||
// InputInfoList.
|
||||
|
@ -1779,6 +1759,10 @@ static StringRef getArchNameForCompilerRTLib(const ToolChain &TC) {
|
|||
return TC.getArchName();
|
||||
}
|
||||
|
||||
static StringRef getOSNameForCompilerRTLib(const ToolChain &TC) {
|
||||
return TC.getOS();
|
||||
}
|
||||
|
||||
// This adds the static libclang_rt.arch.a directly to the command line
|
||||
// FIXME: Make sure we can also emit shared objects if they're requested
|
||||
// and available, check for possible errors, etc.
|
||||
|
@ -1797,7 +1781,7 @@ static void addClangRTLinux(
|
|||
CmdArgs.push_back("-lgcc_eh");
|
||||
}
|
||||
|
||||
static void addProfileRTLinux(
|
||||
static void addProfileRT(
|
||||
const ToolChain &TC, const ArgList &Args, ArgStringList &CmdArgs) {
|
||||
if (!(Args.hasArg(options::OPT_fprofile_arcs) ||
|
||||
Args.hasArg(options::OPT_fprofile_generate) ||
|
||||
|
@ -1806,11 +1790,11 @@ static void addProfileRTLinux(
|
|||
Args.hasArg(options::OPT_coverage)))
|
||||
return;
|
||||
|
||||
// The profile runtime is located in the Linux library directory and has name
|
||||
// "libclang_rt.profile-<ArchName>.a".
|
||||
// The profile runtime is located in the OS-specific resource directory and
|
||||
// has name "libclang_rt.profile-<ArchName>.a".
|
||||
SmallString<128> LibProfile(TC.getDriver().ResourceDir);
|
||||
llvm::sys::path::append(
|
||||
LibProfile, "lib", "linux",
|
||||
LibProfile, "lib", getOSNameForCompilerRTLib(TC),
|
||||
Twine("libclang_rt.profile-") + getArchNameForCompilerRTLib(TC) + ".a");
|
||||
|
||||
CmdArgs.push_back(Args.MakeArgString(LibProfile));
|
||||
|
@ -5440,7 +5424,7 @@ void solaris::Link::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
}
|
||||
CmdArgs.push_back(Args.MakeArgString(LibPath + "crtn.o"));
|
||||
|
||||
addProfileRT(getToolChain(), Args, CmdArgs, getToolChain().getTriple());
|
||||
addProfileRT(getToolChain(), Args, CmdArgs);
|
||||
|
||||
const char *Exec =
|
||||
Args.MakeArgString(getToolChain().GetProgramPath("ld"));
|
||||
|
@ -5552,7 +5536,7 @@ void auroraux::Link::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
getToolChain().GetFilePath("crtend.o")));
|
||||
}
|
||||
|
||||
addProfileRT(getToolChain(), Args, CmdArgs, getToolChain().getTriple());
|
||||
addProfileRT(getToolChain(), Args, CmdArgs);
|
||||
|
||||
const char *Exec =
|
||||
Args.MakeArgString(getToolChain().GetProgramPath("ld"));
|
||||
|
@ -6129,7 +6113,7 @@ void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
|
||||
}
|
||||
|
||||
addProfileRT(ToolChain, Args, CmdArgs, ToolChain.getTriple());
|
||||
addProfileRT(ToolChain, Args, CmdArgs);
|
||||
|
||||
const char *Exec =
|
||||
Args.MakeArgString(ToolChain.GetProgramPath("ld"));
|
||||
|
@ -6378,7 +6362,7 @@ void netbsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
"crtn.o")));
|
||||
}
|
||||
|
||||
addProfileRT(getToolChain(), Args, CmdArgs, getToolChain().getTriple());
|
||||
addProfileRT(getToolChain(), Args, CmdArgs);
|
||||
|
||||
const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("ld"));
|
||||
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
|
||||
|
@ -6777,7 +6761,7 @@ void gnutools::Link::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
addDfsanRTLinux(getToolChain(), Args, CmdArgs);
|
||||
|
||||
// The profile runtime also needs access to system libraries.
|
||||
addProfileRTLinux(getToolChain(), Args, CmdArgs);
|
||||
addProfileRT(getToolChain(), Args, CmdArgs);
|
||||
|
||||
if (D.CCCIsCXX() &&
|
||||
!Args.hasArg(options::OPT_nostdlib) &&
|
||||
|
@ -6891,7 +6875,7 @@ void minix::Link::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
|
||||
AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
|
||||
|
||||
addProfileRT(getToolChain(), Args, CmdArgs, getToolChain().getTriple());
|
||||
addProfileRT(getToolChain(), Args, CmdArgs);
|
||||
|
||||
if (!Args.hasArg(options::OPT_nostdlib) &&
|
||||
!Args.hasArg(options::OPT_nodefaultlibs)) {
|
||||
|
@ -7093,7 +7077,7 @@ void dragonfly::Link::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
getToolChain().GetFilePath("crtn.o")));
|
||||
}
|
||||
|
||||
addProfileRT(getToolChain(), Args, CmdArgs, getToolChain().getTriple());
|
||||
addProfileRT(getToolChain(), Args, CmdArgs);
|
||||
|
||||
const char *Exec =
|
||||
Args.MakeArgString(getToolChain().GetProgramPath("ld"));
|
||||
|
|
|
@ -17,3 +17,12 @@
|
|||
//
|
||||
// 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 --coverage \
|
||||
// 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"
|
||||
|
|
Loading…
Reference in New Issue