[PATCH] Add a CMake option COMPILER_RT_DEBUG for building runtimes with full debug info.
Peter Collingbourne
peter at pcc.me.uk
Sun Oct 20 19:48:07 PDT 2013
Hi kcc,
http://llvm-reviews.chandlerc.com/D1984
Files:
CMakeLists.txt
lib/CMakeLists.txt
lib/asan/lit_tests/TestCases/Linux/malloc-in-qsort.cc
lib/asan/lit_tests/TestCases/memcmp_test.cc
lib/asan/lit_tests/TestCases/strncpy-overflow.cc
lib/lit.common.cfg
lib/lit.common.configured.in
lib/sanitizer_common/sanitizer_linux.cc
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -124,6 +124,8 @@
set(${out_var} ${archs} PARENT_SCOPE)
endfunction()
+option(COMPILER_RT_DEBUG "Build runtimes with full debug info" OFF)
+
# Provide some common commmandline flags for Sanitizer runtimes.
if (NOT MSVC)
set(SANITIZER_COMMON_CFLAGS
@@ -134,9 +136,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 +153,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)
Index: lib/CMakeLists.txt
===================================================================
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -196,6 +196,16 @@
endforeach()
endif()
+macro(pythonize_bool var)
+ if (${var})
+ set(${var} True)
+ else()
+ set(${var} False)
+ endif()
+endmacro()
+
+pythonize_bool(COMPILER_RT_DEBUG)
+
# Generate configs for running lit and unit tests.
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.common.configured.in
Index: lib/asan/lit_tests/TestCases/Linux/malloc-in-qsort.cc
===================================================================
--- lib/asan/lit_tests/TestCases/Linux/malloc-in-qsort.cc
+++ lib/asan/lit_tests/TestCases/Linux/malloc-in-qsort.cc
@@ -9,6 +9,8 @@
// Fast unwinder is only avaliable on x86_64 and i386.
// REQUIRES: x86_64-supported-target
+// REQUIRES: compiler-rt-optimized
+
#include <stdlib.h>
#include <stdio.h>
Index: lib/asan/lit_tests/TestCases/memcmp_test.cc
===================================================================
--- lib/asan/lit_tests/TestCases/memcmp_test.cc
+++ lib/asan/lit_tests/TestCases/memcmp_test.cc
@@ -3,6 +3,8 @@
// RUN: %clangxx_asan -O2 %s -o %t && not %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O3 %s -o %t && not %t 2>&1 | FileCheck %s
+// REQUIRES: compiler-rt-optimized
+
#include <string.h>
int main(int argc, char **argv) {
char a1[] = {argc, 2, 3, 4};
Index: lib/asan/lit_tests/TestCases/strncpy-overflow.cc
===================================================================
--- lib/asan/lit_tests/TestCases/strncpy-overflow.cc
+++ lib/asan/lit_tests/TestCases/strncpy-overflow.cc
@@ -7,6 +7,8 @@
// RUN: %clangxx_asan -O3 %s -o %t && not %t 2>%t.out
// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-%os < %t.out
+// REQUIRES: compiler-rt-optimized
+
#include <string.h>
#include <stdlib.h>
int main(int argc, char **argv) {
Index: lib/lit.common.cfg
===================================================================
--- lib/lit.common.cfg
+++ lib/lit.common.cfg
@@ -56,3 +56,7 @@
if compiler_rt_arch:
for arch in compiler_rt_arch.split(";"):
config.available_features.add(arch + "-supported-target")
+
+compiler_rt_debug = getattr(config, 'compiler_rt_debug', False)
+if not compiler_rt_debug:
+ config.available_features.add('compiler-rt-optimized')
Index: lib/lit.common.configured.in
===================================================================
--- lib/lit.common.configured.in
+++ lib/lit.common.configured.in
@@ -13,6 +13,7 @@
config.clang = "@LLVM_BINARY_DIR@/bin/clang"
config.compiler_rt_arch = "@COMPILER_RT_SUPPORTED_ARCH@"
config.python_executable = "@PYTHON_EXECUTABLE@"
+config.compiler_rt_debug = @COMPILER_RT_DEBUG@
# LLVM tools dir can be passed in lit parameters, so try to
# apply substitution.
Index: lib/sanitizer_common/sanitizer_linux.cc
===================================================================
--- lib/sanitizer_common/sanitizer_linux.cc
+++ lib/sanitizer_common/sanitizer_linux.cc
@@ -218,7 +218,8 @@
}
u64 NanoTime() {
- kernel_timeval tv = {};
+ kernel_timeval tv;
+ internal_memset(&tv, 0, sizeof(tv));
internal_syscall(__NR_gettimeofday, &tv, 0);
return (u64)tv.tv_sec * 1000*1000*1000 + tv.tv_usec * 1000;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1984.1.patch
Type: text/x-patch
Size: 4364 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131020/e35eb52f/attachment.bin>
More information about the llvm-commits
mailing list