[llvm-commits] [llvm] r123028 - in /llvm/trunk: CMakeLists.txt cmake/modules/LLVMProcessSources.cmake

Oscar Fuentes ofv at wanadoo.es
Fri Jan 7 12:31:03 PST 2011


Author: ofv
Date: Fri Jan  7 14:31:03 2011
New Revision: 123028

URL: http://llvm.org/viewvc/llvm-project?rev=123028&view=rev
Log:
Don't use -O3 on Mingw, as people report it as unreliable. Use -O2
instead.

Modified:
    llvm/trunk/CMakeLists.txt
    llvm/trunk/cmake/modules/LLVMProcessSources.cmake

Modified: llvm/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=123028&r1=123027&r2=123028&view=diff
==============================================================================
--- llvm/trunk/CMakeLists.txt (original)
+++ llvm/trunk/CMakeLists.txt Fri Jan  7 14:31:03 2011
@@ -317,6 +317,12 @@
   set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES}${LLVM_SYSTEM_LIBS}")
 endif()
 
+if( MINGW )
+  # People report that -O3 is unreliable on MinGW. The traditional
+  # build also uses -O2 for that reason:
+  llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
+endif()
+
 add_subdirectory(lib/Support)
 
 # Everything else depends on Support:

Modified: llvm/trunk/cmake/modules/LLVMProcessSources.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMProcessSources.cmake?rev=123028&r1=123027&r2=123028&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/LLVMProcessSources.cmake (original)
+++ llvm/trunk/cmake/modules/LLVMProcessSources.cmake Fri Jan  7 14:31:03 2011
@@ -1,5 +1,15 @@
 include(AddFileDependencies)
 
+macro(llvm_replace_compiler_option var old new)
+  # Replaces a compiler option or switch `old' in `var' by `new'.
+  # If `old' is not in `var', appends `new' to `var'.
+  # Example: llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
+  if( "${${var}}" MATCHES "(^| )${old}($| )" )
+    string( REGEX REPLACE "(^| )${old}($| )" " ${new}  " ${var} "${${var}}" )
+  else()
+    set( ${var} "${${var}} ${new}" )
+  endif()
+endmacro(llvm_replace_compiler_option)
 
 macro(add_td_sources srcs)
   file(GLOB tds *.td)





More information about the llvm-commits mailing list