]> granicus.if.org Git - clang/commitdiff
Driver/Darwin: Be bug compatible with GCC and ignore -pg on ARM.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 1 Mar 2011 18:49:30 +0000 (18:49 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 1 Mar 2011 18:49:30 +0000 (18:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126767 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/ToolChain.h
lib/Driver/ToolChains.cpp
lib/Driver/ToolChains.h
lib/Driver/Tools.cpp

index f0012bd851eb65a4ef77b2a74953752f2a5649d0..acf2e9c0517ede2479d420c10ac564882317a791 100644 (file)
@@ -151,6 +151,9 @@ public:
   /// particular PIC mode.
   virtual const char *GetForcedPicModel() const = 0;
 
+  /// SupportsProfiling - Does this tool chain support -pg.
+  virtual bool SupportsProfiling() const { return true; }
+
   /// Does this tool chain support Objective-C garbage collection.
   virtual bool SupportsObjCGC() const { return false; }
 
index 561476ecdf0d575652c4a0919661dd0a61df15e2..4a9be0ef76b18660edad786d31cb87bea9702505 100644 (file)
@@ -918,6 +918,11 @@ const char *Darwin::GetForcedPicModel() const {
   return 0;
 }
 
+bool Darwin::SupportsProfiling() const {
+  // Profiling instrumentation is only supported on x86.
+  return getArchName() == "i386" || getArchName() == "x86_64";
+}
+
 bool Darwin::SupportsObjCGC() const {
   // Garbage collection is supported everywhere except on iPhone OS.
   return !isTargetIPhoneOS();
index 0e3645cb8f7e043d586ef4094617c5fbbe8841ce..3c0def58b42ab087e697af9cfe8d767e58a4f703 100644 (file)
@@ -212,6 +212,8 @@ public:
   virtual const char *GetDefaultRelocationModel() const;
   virtual const char *GetForcedPicModel() const;
 
+  virtual bool SupportsProfiling() const;
+
   virtual bool SupportsObjCGC() const;
 
   virtual bool UseDwarfDebugFlags() const;
index 3e6f74817397904fc11c0f2aff4d07f811e301d1..8539752ac38194ca4b1a2f8bb3d82d9118be8e13 100644 (file)
@@ -1385,7 +1385,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls);
   Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions);
   Args.AddLastArg(CmdArgs, options::OPT_flimit_debug_info);
-  Args.AddLastArg(CmdArgs, options::OPT_pg);
+  if (getToolChain().SupportsProfiling())
+    Args.AddLastArg(CmdArgs, options::OPT_pg);
 
   // -flax-vector-conversions is default.
   if (!Args.hasFlag(options::OPT_flax_vector_conversions,
@@ -2184,7 +2185,8 @@ void darwin::CC1::AddCC1OptionsArgs(const ArgList &Args, ArgStringList &CmdArgs,
 
   if (Args.hasArg(options::OPT_v))
     CmdArgs.push_back("-version");
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) &&
+      getToolChain().SupportsProfiling())
     CmdArgs.push_back("-p");
   Args.AddLastArg(CmdArgs, options::OPT_p);
 
@@ -2817,7 +2819,8 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
           }
         }
       } else {
-        if (Args.hasArg(options::OPT_pg)) {
+        if (Args.hasArg(options::OPT_pg) &&
+            getToolChain().SupportsProfiling()) {
           if (Args.hasArg(options::OPT_static) ||
               Args.hasArg(options::OPT_object) ||
               Args.hasArg(options::OPT_preload)) {