[Cmake-commits] CMake branch, next, updated. v2.8.12.2-7402-g5df5eab

Nils Gladitz nilsgladitz at gmail.com
Mon Feb 3 11:59:18 EST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  5df5eab6706dd849a5ea10f5b447691eeaca74ec (commit)
       via  f899722c0461e8711edf442eb8b0f1fe06ab3774 (commit)
      from  53c411c4c51dbcdfca9c7072c473c6f2a99679d2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5df5eab6706dd849a5ea10f5b447691eeaca74ec
commit 5df5eab6706dd849a5ea10f5b447691eeaca74ec
Merge: 53c411c f899722
Author:     Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Mon Feb 3 11:59:17 2014 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Feb 3 11:59:17 2014 -0500

    Merge topic 'gcc-ipo' into next
    
    f899722c IPO: implemented INTERPROCEDURAL_OPTIMIZATION for gcc (-flto)


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f899722c0461e8711edf442eb8b0f1fe06ab3774
commit f899722c0461e8711edf442eb8b0f1fe06ab3774
Author:     Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Fri Jan 31 23:56:40 2014 +0100
Commit:     Nils Gladitz <nilsgladitz at gmail.com>
CommitDate: Fri Jan 31 23:56:40 2014 +0100

    IPO: implemented INTERPROCEDURAL_OPTIMIZATION for gcc (-flto)
    
    Using the IPO specific rule variables in the Ninja generator should
    fix intel IPO as well.

diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake
index f01255c..59909c1 100644
--- a/Modules/Compiler/GNU.cmake
+++ b/Modules/Compiler/GNU.cmake
@@ -55,4 +55,39 @@ macro(__compiler_gnu lang)
   if(NOT APPLE)
     set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
   endif()
+
+  # LTO/IPO
+  if(NOT CMAKE_GCC_AR OR NOT CMAKE_GCC_RANLIB)
+    if(IS_ABSOLUTE "${CMAKE_${lang}_COMPILER}")
+      string(REGEX MATCH "^([0-9]+.[0-9]+)" _version
+        "${CMAKE_${lang}_COMPILER_VERSION}")
+      get_filename_component(_dir "${CMAKE_${lang}_COMPILER}" DIRECTORY)
+
+      find_program(CMAKE_GCC_AR NAMES
+        "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar"
+        "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${_version}"
+      )
+
+      find_program(CMAKE_GCC_RANLIB NAMES
+        "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib"
+        "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${_version}"
+      )
+    endif()
+  endif()
+
+  if(CMAKE_GCC_AR AND CMAKE_GCC_RANLIB)
+    set(CMAKE_${lang}_COMPILE_OPTIONS_IPO -flto -fno-fat-lto-objects)
+
+    set(CMAKE_${lang}_ARCHIVE_CREATE_IPO
+      "${CMAKE_GCC_AR} cr <TARGET> <LINK_FLAGS> <OBJECTS>"
+    )
+
+    set(CMAKE_${lang}_ARCHIVE_APPEND_IPO
+      "${CMAKE_GCC_AR} r <TARGET> <LINK_FLAGS> <OBJECTS>"
+    )
+
+    set(CMAKE_${lang}_ARCHIVE_FINISH_IPO
+      "${CMAKE_GCC_RANLIB} <TARGET>"
+    )
+  endif()
 endmacro()
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index d6a0cd4..38d3c3c 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -140,11 +140,7 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
     }
   linkRuleVar += "_CREATE_STATIC_LIBRARY";
 
-  if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION") &&
-     this->Makefile->GetDefinition((linkRuleVar+"_IPO").c_str()))
-    {
-    linkRuleVar += "_IPO";
-    }
+  linkRuleVar = this->GetFeatureSpecificLinkRuleVariable(linkRuleVar);
 
   std::string extraFlags;
   this->LocalGenerator->GetStaticLibraryFlags(extraFlags,
@@ -494,6 +490,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
     std::string arCreateVar = "CMAKE_";
     arCreateVar += linkLanguage;
     arCreateVar += "_ARCHIVE_CREATE";
+    arCreateVar = this->GetFeatureSpecificLinkRuleVariable(arCreateVar);
     if(const char* rule = this->Makefile->GetDefinition(arCreateVar.c_str()))
       {
       cmSystemTools::ExpandListArgument(rule, archiveCreateCommands);
@@ -501,6 +498,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
     std::string arAppendVar = "CMAKE_";
     arAppendVar += linkLanguage;
     arAppendVar += "_ARCHIVE_APPEND";
+    arAppendVar = this->GetFeatureSpecificLinkRuleVariable(arAppendVar);
     if(const char* rule = this->Makefile->GetDefinition(arAppendVar.c_str()))
       {
       cmSystemTools::ExpandListArgument(rule, archiveAppendCommands);
@@ -508,6 +506,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
     std::string arFinishVar = "CMAKE_";
     arFinishVar += linkLanguage;
     arFinishVar += "_ARCHIVE_FINISH";
+    arFinishVar = this->GetFeatureSpecificLinkRuleVariable(arFinishVar);
     if(const char* rule = this->Makefile->GetDefinition(arFinishVar.c_str()))
       {
       cmSystemTools::ExpandListArgument(rule, archiveFinishCommands);
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 7f90078..14dd6ab 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1664,6 +1664,20 @@ void cmMakefileTargetGenerator
 }
 
 //----------------------------------------------------------------------------
+std::string cmMakefileTargetGenerator::GetFeatureSpecificLinkRuleVariable(
+  std::string const& var) const
+{
+  std::string ipoVar = var + "_IPO";
+  if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION") &&
+     this->Makefile->GetDefinition(ipoVar.c_str()))
+    {
+    return ipoVar;
+    }
+
+  return var;
+}
+
+//----------------------------------------------------------------------------
 std::string cmMakefileTargetGenerator::GetLinkRule(const char* linkRuleVar)
 {
   std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
@@ -2041,13 +2055,13 @@ void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
 }
 
 //----------------------------------------------------------------------------
-const char* cmMakefileTargetGenerator::GetFeature(const char* feature)
+const char* cmMakefileTargetGenerator::GetFeature(const char* feature) const
 {
   return this->Target->GetFeature(feature, this->ConfigName);
 }
 
 //----------------------------------------------------------------------------
-bool cmMakefileTargetGenerator::GetFeatureAsBool(const char* feature)
+bool cmMakefileTargetGenerator::GetFeatureAsBool(const char* feature) const
 {
   return cmSystemTools::IsOn(this->GetFeature(feature));
 }
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index 4f8fafa..16524c3 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -137,6 +137,9 @@ protected:
   // Append link rule dependencies (objects, etc.).
   void AppendLinkDepends(std::vector<std::string>& depends);
 
+  // Get feature specific link rule variable (e.g. <var>_IPO)
+  std::string GetFeatureSpecificLinkRuleVariable(std::string const& var) const;
+
   // Lookup the link rule for this target.
   std::string GetLinkRule(const char* linkRuleVar);
 
@@ -258,8 +261,8 @@ protected:
   void AddFeatureFlags(std::string& flags, const char* lang);
 
   // Feature query methods.
-  const char* GetFeature(const char* feature);
-  bool GetFeatureAsBool(const char* feature);
+  const char* GetFeature(const char* feature) const;
+  bool GetFeatureAsBool(const char* feature) const;
 
   //==================================================================
   // Convenience routines that do nothing more than forward to
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 73ba815..56c8e1b 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -140,10 +140,17 @@ std::string
 cmNinjaNormalTargetGenerator
 ::LanguageLinkerRule() const
 {
-  return std::string(this->TargetLinkLanguage)
+  std::string var = std::string(this->TargetLinkLanguage)
     + "_"
     + cmTarget::GetTargetTypeName(this->GetTarget()->GetType())
     + "_LINKER";
+
+  if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION"))
+    {
+    var += "_IPO";
+    }
+
+  return var;
 }
 
 void
@@ -152,6 +159,7 @@ cmNinjaNormalTargetGenerator
 {
   cmTarget::TargetType targetType = this->GetTarget()->GetType();
   std::string ruleName = this->LanguageLinkerRule();
+
   if (useResponseFile)
     ruleName += "_RSP_FILE";
 
@@ -320,6 +328,7 @@ cmNinjaNormalTargetGenerator
       std::string linkCmdVar = "CMAKE_";
       linkCmdVar += this->TargetLinkLanguage;
       linkCmdVar += "_CREATE_STATIC_LIBRARY";
+      linkCmdVar = this->GetFeatureSpecificLinkRuleVariable(linkCmdVar);
       if (const char *linkCmd =
             this->GetMakefile()->GetDefinition(linkCmdVar.c_str()))
         {
@@ -340,6 +349,7 @@ cmNinjaNormalTargetGenerator
       std::string linkCmdVar = "CMAKE_";
       linkCmdVar += this->TargetLinkLanguage;
       linkCmdVar += "_ARCHIVE_CREATE";
+      linkCmdVar = this->GetFeatureSpecificLinkRuleVariable(linkCmdVar);
       const char *linkCmd =
         this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str());
       cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
@@ -348,6 +358,7 @@ cmNinjaNormalTargetGenerator
       std::string linkCmdVar = "CMAKE_";
       linkCmdVar += this->TargetLinkLanguage;
       linkCmdVar += "_ARCHIVE_FINISH";
+      linkCmdVar = this->GetFeatureSpecificLinkRuleVariable(linkCmdVar);
       const char *linkCmd =
         this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str());
       cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 82f8d1b..2af7bf11 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -97,18 +97,33 @@ const char* cmNinjaTargetGenerator::GetConfigName() const
 }
 
 // TODO: Picked up from cmMakefileTargetGenerator.  Refactor it.
-const char* cmNinjaTargetGenerator::GetFeature(const char* feature)
+const char* cmNinjaTargetGenerator::GetFeature(const char* feature) const
 {
   return this->Target->GetFeature(feature, this->GetConfigName());
 }
 
 // TODO: Picked up from cmMakefileTargetGenerator.  Refactor it.
-bool cmNinjaTargetGenerator::GetFeatureAsBool(const char* feature)
+bool cmNinjaTargetGenerator::GetFeatureAsBool(const char* feature) const
 {
   return cmSystemTools::IsOn(this->GetFeature(feature));
 }
 
 // TODO: Picked up from cmMakefileTargetGenerator.  Refactor it.
+std::string cmNinjaTargetGenerator::GetFeatureSpecificLinkRuleVariable(
+  std::string const& var) const
+{
+  std::string ipoVar = var + "_IPO";
+  if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION") &&
+     this->Makefile->GetDefinition(ipoVar.c_str()))
+    {
+    return ipoVar;
+    }
+
+  return var;
+}
+
+
+// TODO: Picked up from cmMakefileTargetGenerator.  Refactor it.
 void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags,
                                              const char* lang)
 {
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index 2ce1ed7..bce3647 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -70,8 +70,9 @@ protected:
   std::string LanguageCompilerRule(const std::string& lang) const
   { return lang + "_COMPILER"; }
 
-  const char* GetFeature(const char* feature);
-  bool GetFeatureAsBool(const char* feature);
+  const char* GetFeature(const char* feature) const;
+  bool GetFeatureAsBool(const char* feature) const;
+  std::string GetFeatureSpecificLinkRuleVariable(std::string const& var) const;
   void AddFeatureFlags(std::string& flags, const char* lang);
 
   /**

-----------------------------------------------------------------------

Summary of changes:
 Modules/Compiler/GNU.cmake                  |   35 +++++++++++++++++++++++++++
 Source/cmMakefileLibraryTargetGenerator.cxx |    9 +++----
 Source/cmMakefileTargetGenerator.cxx        |   18 ++++++++++++--
 Source/cmMakefileTargetGenerator.h          |    7 ++++--
 Source/cmNinjaNormalTargetGenerator.cxx     |   13 +++++++++-
 Source/cmNinjaTargetGenerator.cxx           |   19 +++++++++++++--
 Source/cmNinjaTargetGenerator.h             |    5 ++--
 7 files changed, 92 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list