[PATCH] [CMake/PPC64]: Add -mminimal-toc to CFLAGS if compiler is gcc < 4.6 on powerpc64

Kai Nacke kai.nacke at redstar.de
Sat Jun 1 12:17:53 PDT 2013


Hi!

To compile LLVM with gcc < 4.6 on a powerpc64 platform you have to add 
-mminimal-toc to CFLAGS / CXXFLAGS. Otherwise you get strange linker errors.

The attached patch adds a check for these conditions and adds the 
compiler flag if required.

Please review.

Regards
Kai
-------------- next part --------------
diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake
index 2939fa2..c3f3d35 100644
--- a/cmake/modules/HandleLLVMOptions.cmake
+++ b/cmake/modules/HandleLLVMOptions.cmake
@@ -231,6 +231,13 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
   if (LLVM_ENABLE_WERROR)
     add_llvm_definitions( -Werror )
   endif (LLVM_ENABLE_WERROR)
+
+  # Append -mminimal-toc for gcc 4.0.x - 4.5.x on ppc64
+  if( CMAKE_COMPILER_IS_GNUCXX
+      AND CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64|powerpc64"
+      AND CMAKE_C_COMPILER_VERSION MATCHES ".*4\\.[0-5].*" )
+    append("-mminimal-toc" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+  endif()
 endif( MSVC )
 
 macro(append_common_sanitizer_flags)


More information about the llvm-commits mailing list