Skip to content
This repository has been archived by the owner on May 21, 2019. It is now read-only.

Commit

Permalink
Add a CMake option COMPILER_RT_DEBUG for building runtimes with full …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
pcc committed Oct 25, 2013
1 parent c1a1ed6 commit 7e8db74
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 2 deletions.
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ function(filter_available_targets out_var)
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
Expand All @@ -134,9 +139,11 @@ if (NOT MSVC)
-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
Expand All @@ -149,7 +156,7 @@ endif()
# 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)
Expand Down
10 changes: 10 additions & 0 deletions cmake/Modules/CompilerRTUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@ function(find_flag_in_string flag_string flag out_var)
set(${out_var} FALSE PARENT_SCOPE)
endif()
endfunction()

# Set the variable var_PYBOOL to True if var holds a true-ish string,
# otherwise set it to False.
macro(pythonize_bool var)
if (${var})
set(${var}_PYBOOL True)
else()
set(${var}_PYBOOL False)
endif()
endmacro()
2 changes: 2 additions & 0 deletions lib/asan/lit_tests/TestCases/Linux/malloc-in-qsort.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 2 additions & 0 deletions lib/asan/lit_tests/TestCases/memcmp_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 2 additions & 0 deletions lib/asan/lit_tests/TestCases/strncpy-overflow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions lib/lit.common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ compiler_rt_arch = getattr(config, 'compiler_rt_arch', None)
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')
1 change: 1 addition & 0 deletions lib/lit.common.configured.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
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_PYBOOL@

# LLVM tools dir can be passed in lit parameters, so try to
# apply substitution.
Expand Down

0 comments on commit 7e8db74

Please sign in to comment.