[cfe-commits] [patch] profiling support for OpenBSD
Eli Friedman
eli.friedman at gmail.com
Wed Dec 14 18:19:23 PST 2011
On Mon, Dec 12, 2011 at 11:06 AM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Sat, Dec 10, 2011 at 3:14 PM, Jonathan Gray <jsg at openbsd.org> wrote:
>> The following lets profiling work on OpenBSD. While here
>> fix the symbol prefix to be empty rather than an underscore.
>>
>> Index: lib/Basic/Targets.cpp
>> ===================================================================
>> --- lib/Basic/Targets.cpp (revision 146203)
>> +++ lib/Basic/Targets.cpp (working copy)
>> @@ -371,7 +371,26 @@
>> }
>> public:
>> OpenBSDTargetInfo(const std::string &triple)
>> - : OSTargetInfo<Target>(triple) {}
>> + : OSTargetInfo<Target>(triple) {
>> + this->UserLabelPrefix = "";
>> +
>> + llvm::Triple Triple(triple);
>> + switch (Triple.getArch()) {
>> + default:
>> + case llvm::Triple::x86:
>> + case llvm::Triple::x86_64:
>> + case llvm::Triple::arm:
>> + case llvm::Triple::sparc:
>> + this->MCountName = "__mcount";
>> + break;
>> + case llvm::Triple::mips64:
>> + case llvm::Triple::mips64el:
>> + case llvm::Triple::ppc:
>> + case llvm::Triple::sparcv9:
>> + this->MCountName = "_mcount";
>> + break;
>> + }
>> + }
>> };
>>
>> // PSP Target
>> Index: lib/Driver/Tools.cpp
>> ===================================================================
>> --- lib/Driver/Tools.cpp (revision 146203)
>> +++ lib/Driver/Tools.cpp (working copy)
>> @@ -3890,9 +3890,13 @@
>> if (!Args.hasArg(options::OPT_nostdlib) &&
>> !Args.hasArg(options::OPT_nostartfiles)) {
>> if (!Args.hasArg(options::OPT_shared)) {
>> + if (Args.hasArg(options::OPT_pg))
>> + CmdArgs.push_back(Args.MakeArgString(
>> + getToolChain().GetFilePath("gcrt0.o")));
>> + else
>> + CmdArgs.push_back(Args.MakeArgString(
>> + getToolChain().GetFilePath("crt0.o")));
>> CmdArgs.push_back(Args.MakeArgString(
>> - getToolChain().GetFilePath("crt0.o")));
>> - CmdArgs.push_back(Args.MakeArgString(
>> getToolChain().GetFilePath("crtbegin.o")));
>> } else {
>> CmdArgs.push_back(Args.MakeArgString(
>> @@ -3916,7 +3920,10 @@
>> !Args.hasArg(options::OPT_nodefaultlibs)) {
>> if (D.CCCIsCXX) {
>> getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
>> - CmdArgs.push_back("-lm");
>> + if (Args.hasArg(options::OPT_pg))
>> + CmdArgs.push_back("-lm_p");
>> + else
>> + CmdArgs.push_back("-lm");
>> }
>>
>> // FIXME: For some reason GCC passes -lgcc before adding
>> @@ -3926,7 +3933,10 @@
>> if (Args.hasArg(options::OPT_pthread))
>> CmdArgs.push_back("-lpthread");
>> if (!Args.hasArg(options::OPT_shared))
>> - CmdArgs.push_back("-lc");
>> + if (Args.hasArg(options::OPT_pg))
>> + CmdArgs.push_back("-lc_p");
>> + else
>> + CmdArgs.push_back("-lc");
>> CmdArgs.push_back("-lgcc");
>> }
>>
>
> Patch looks fine.
>
> If you want me to commit, please attach the patch rather than putting it inline.
r146631.
-Eli
More information about the cfe-commits
mailing list