Add a CMake option COMPILER_RT_DEBUG for building runtimes with full debug info.

Differential Revision: http://llvm-reviews.chandlerc.com/D1984

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@193449 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 123b60e..2d968be 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -124,6 +124,11 @@
   set(${out_var} ${archs} PARENT_SCOPE)
 endfunction()
 
+option(COMPILER_RT_DEBUG "Build runtimes with full debug info" OFF)
+
+# COMPILER_RT_DEBUG_PYBOOL is used by lit.common.configured.in.
+pythonize_bool(COMPILER_RT_DEBUG)
+
 # Provide some common commmandline flags for Sanitizer runtimes.
 if (NOT MSVC)
   set(SANITIZER_COMMON_CFLAGS
@@ -134,9 +139,11 @@
     -funwind-tables
     -fno-stack-protector
     -Wno-gnu  # Variadic macros with 0 arguments for ...
-    -O3
     -fvisibility=hidden
     )
+  if (NOT COMPILER_RT_DEBUG)
+    list(APPEND SANITIZER_COMMON_CFLAGS -O3)
+  endif()
 else()
   set(SANITIZER_COMMON_CFLAGS
     /MT
@@ -149,7 +156,7 @@
 # Build sanitizer runtimes with debug info. (MSVC gets /Zi above)
 if (NOT MSVC)
   check_cxx_compiler_flag(-gline-tables-only SUPPORTS_GLINE_TABLES_ONLY_FLAG)
-  if(SUPPORTS_GLINE_TABLES_ONLY_FLAG)
+  if(SUPPORTS_GLINE_TABLES_ONLY_FLAG AND NOT COMPILER_RT_DEBUG)
     list(APPEND SANITIZER_COMMON_CFLAGS -gline-tables-only)
   else()
     list(APPEND SANITIZER_COMMON_CFLAGS -g)