[Cmake-commits] CMake branch, next, updated. v2.8.12.2-7428-g0efeabc

Nils Gladitz nilsgladitz at gmail.com
Wed Feb 5 03:13:56 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  0efeabcbbf7707c267f544a14ec306e619dc0632 (commit)
       via  bc37c2d860827f5ffbf55686dcedafc1854c1a00 (commit)
      from  d5b3a2843b4222e26579c46c8d064107cbdabe9e (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=0efeabcbbf7707c267f544a14ec306e619dc0632
commit 0efeabcbbf7707c267f544a14ec306e619dc0632
Merge: d5b3a28 bc37c2d
Author:     Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Wed Feb 5 03:13:55 2014 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Feb 5 03:13:55 2014 -0500

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


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bc37c2d860827f5ffbf55686dcedafc1854c1a00
commit bc37c2d860827f5ffbf55686dcedafc1854c1a00
Author:     Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Fri Jan 31 23:56:40 2014 +0100
Commit:     Nils Gladitz <nilsgladitz at gmail.com>
CommitDate: Wed Feb 5 09:13:39 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..2208a06 100644
--- a/Modules/Compiler/GNU.cmake
+++ b/Modules/Compiler/GNU.cmake
@@ -55,4 +55,67 @@ 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)
+    if(NOT DEFINED CMAKE_${lang}_HAS_COLLECT_LTO_WRAPPER)
+      execute_process(
+        COMMAND ${CMAKE_${lang}_COMPILER} ${CMAKE_${lang}_VERBOSE_FLAG}
+        RESULT_VARIABLE __result
+        ERROR_VARIABLE __output
+        OUTPUT_QUIET
+      )
+
+      set(__lto_found FALSE)
+      if("${__result}" STREQUAL "0" AND
+        "${__output}" MATCHES "COLLECT_LTO_WRAPPER")
+
+        set(__lto_found TRUE)
+      endif()
+
+      set(CMAKE_${lang}_HAS_COLLECT_LTO_WRAPPER
+        ${__lto_found} CACHE INTERNAL
+        "If the output of gcc -v contains COLLECT_LTO_WRAPPER")
+    endif()
+
+    if(CMAKE_${lang}_HAS_COLLECT_LTO_WRAPPER)
+      set(__lto_flags -flto)
+
+      if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.7)
+        list(APPEND __lto_flags -fno-fat-lto-objects)
+      endif()
+
+      set(CMAKE_${lang}_COMPILE_OPTIONS_IPO ${__lto_flags})
+
+      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()
+  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..b979be1 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);
@@ -478,6 +489,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
   std::string flags = (targetType == cmTarget::EXECUTABLE
                                ? vars["FLAGS"]
                                : vars["ARCH_FLAGS"]);
+
+  this->AddFeatureFlags(flags, this->TargetLinkLanguage);
+
   this->GetLocalGenerator()->AddArchitectureFlags(flags,
                              this->GetGeneratorTarget(),
                              this->TargetLinkLanguage,
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:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list