Relocate the external headers provided by ASan and the common sanitizer

library.

These headers are intended to be available to user code when built with
AddressSanitizer (or one of the other sanitizer's in the future) to
interface with the runtime library. As such, they form stable external
C interfaces, and the headers shouldn't be located within the
implementation.

I've pulled them out into what seem like fairly obvious locations and
names, but I'm wide open to further bikeshedding of these names and
locations.

I've updated the code and the build system to cope with the new
locations, both CMake and Makefile. Please let me know if this breaks
anyone's build.

The eventual goal is to install these headers along side the Clang
builtin headers when we build the ASan runtime and install it. My
current thinking is to locate them at:

  <prefix>/lib/clang/X.Y/include/sanitizer/common_interface_defs.h
  <prefix>/lib/clang/X.Y/include/sanitizer/asan_interface.h
  <prefix>/lib/clang/X.Y/include/sanitizer/...

But maybe others have different suggestions?

Fixing the style of the #include between these headers at least unblocks
experimentation with installing them as they now should work when
installed in these locations.

llvm-svn: 162822
This commit is contained in:
Chandler Carruth 2012-08-29 02:27:54 +00:00
parent bd0073ddd7
commit 1aa4fef601
18 changed files with 30 additions and 24 deletions

View File

@ -100,6 +100,9 @@ function(set_target_compile_flags target)
set_property(TARGET ${target} PROPERTY COMPILE_FLAGS "${argstring}")
endfunction()
# Add the public header's directory to the includes for all of compiler-rt.
include_directories(include)
add_subdirectory(lib)
if(LLVM_INCLUDE_TESTS)

View File

@ -1,4 +1,4 @@
//===-- asan_interface.h ----------------------------------------*- C++ -*-===//
//===-- sanitizer/asan_interface.h ------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -12,10 +12,11 @@
// This header can be included by the instrumented program to fetch
// data (mostly allocator statistics) from ASan runtime library.
//===----------------------------------------------------------------------===//
#ifndef ASAN_INTERFACE_H
#define ASAN_INTERFACE_H
#ifndef SANITIZER_ASAN_INTERFACE_H
#define SANITIZER_ASAN_INTERFACE_H
#include <sanitizer/common_interface_defs.h>
#include "sanitizer_common/sanitizer_interface_defs.h"
// ----------- ATTENTION -------------
// This header should NOT include any other headers from ASan runtime.
// All functions in this header are extern "C" and start with __asan_.
@ -198,4 +199,4 @@ extern "C" {
SANITIZER_WEAK_ATTRIBUTE SANITIZER_INTERFACE_ATTRIBUTE;
} // extern "C"
#endif // ASAN_INTERFACE_H
#endif // SANITIZER_ASAN_INTERFACE_H

View File

@ -1,4 +1,4 @@
//===-- sanitizer_interface_defs.h -----------------------------*- C++ -*-===//
//===-- sanitizer/common_interface_defs.h -----------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -12,8 +12,8 @@
// NOTE: This file may be included into user code.
//===----------------------------------------------------------------------===//
#ifndef SANITIZER_INTERFACE_DEFS_H
#define SANITIZER_INTERFACE_DEFS_H
#ifndef SANITIZER_COMMON_INTERFACE_DEFS_H
#define SANITIZER_COMMON_INTERFACE_DEFS_H
// ----------- ATTENTION -------------
// This header should NOT include any other headers to avoid portability issues.
@ -53,4 +53,4 @@ typedef signed long long s64; // NOLINT
} // namespace __sanitizer
#endif // SANITIZER_INTERFACE_DEFS_H
#endif // SANITIZER_COMMON_INTERFACE_DEFS_H

View File

@ -27,7 +27,6 @@
#include "asan_allocator.h"
#include "asan_interceptors.h"
#include "asan_interface.h"
#include "asan_internal.h"
#include "asan_lock.h"
#include "asan_mapping.h"
@ -35,6 +34,7 @@
#include "asan_report.h"
#include "asan_thread.h"
#include "asan_thread_registry.h"
#include "sanitizer/asan_interface.h"
#include "sanitizer_common/sanitizer_atomic.h"
#if defined(_WIN32) && !defined(__clang__)

View File

@ -15,7 +15,7 @@
#ifndef ASAN_FLAGS_H
#define ASAN_FLAGS_H
#include "sanitizer_common/sanitizer_interface_defs.h"
#include "sanitizer/common_interface_defs.h"
// ASan flag values can be defined in three ways:
// 1) initialized with default values at startup.

View File

@ -12,7 +12,6 @@
// Handle globals.
//===----------------------------------------------------------------------===//
#include "asan_interceptors.h"
#include "asan_interface.h"
#include "asan_internal.h"
#include "asan_lock.h"
#include "asan_mapping.h"
@ -20,6 +19,7 @@
#include "asan_stack.h"
#include "asan_stats.h"
#include "asan_thread.h"
#include "sanitizer/asan_interface.h"
namespace __asan {

View File

@ -15,7 +15,6 @@
#include "asan_allocator.h"
#include "asan_intercepted_functions.h"
#include "asan_interface.h"
#include "asan_internal.h"
#include "asan_mapping.h"
#include "asan_report.h"
@ -23,6 +22,7 @@
#include "asan_stats.h"
#include "asan_thread_registry.h"
#include "interception/interception.h"
#include "sanitizer/asan_interface.h"
#include "sanitizer_common/sanitizer_libc.h"
namespace __asan {

View File

@ -13,9 +13,9 @@
//===----------------------------------------------------------------------===//
#include "asan_interceptors.h"
#include "asan_interface.h"
#include "asan_internal.h"
#include "asan_mapping.h"
#include "sanitizer/asan_interface.h"
namespace __asan {

View File

@ -12,8 +12,8 @@
// ASan-private header for error reporting functions.
//===----------------------------------------------------------------------===//
#include "asan_interface.h"
#include "asan_internal.h"
#include "sanitizer/asan_interface.h"
namespace __asan {

View File

@ -13,7 +13,6 @@
//===----------------------------------------------------------------------===//
#include "asan_allocator.h"
#include "asan_interceptors.h"
#include "asan_interface.h"
#include "asan_internal.h"
#include "asan_lock.h"
#include "asan_mapping.h"
@ -22,6 +21,7 @@
#include "asan_stats.h"
#include "asan_thread.h"
#include "asan_thread_registry.h"
#include "sanitizer/asan_interface.h"
#include "sanitizer_common/sanitizer_atomic.h"
#include "sanitizer_common/sanitizer_flags.h"
#include "sanitizer_common/sanitizer_libc.h"

View File

@ -12,8 +12,8 @@
// Code for ASan stack trace.
//===----------------------------------------------------------------------===//
#include "asan_flags.h"
#include "asan_interface.h"
#include "asan_stack.h"
#include "sanitizer/asan_interface.h"
namespace __asan {

View File

@ -12,11 +12,11 @@
// Code related to statistics collected by AddressSanitizer.
//===----------------------------------------------------------------------===//
#include "asan_interceptors.h"
#include "asan_interface.h"
#include "asan_internal.h"
#include "asan_lock.h"
#include "asan_stats.h"
#include "asan_thread_registry.h"
#include "sanitizer/asan_interface.h"
namespace __asan {

View File

@ -3,7 +3,8 @@
// RUN: %clang -faddress-sanitizer -dead_strip -O2 %s -o %t.exe
// RUN: nm %t.exe | egrep " [TW] " | sed "s/.* T //" | sed "s/.* W //" \
// RUN: | grep "__asan_" | sed "s/___asan_/__asan_/" > %t.symbols
// RUN: cat %p/../asan_interface.h | sed "s/\/\/.*//" | sed "s/typedef.*//" \
// RUN: cat %p/../../../include/sanitizer/asan_interface.h \
// RUN: | sed "s/\/\/.*//" | sed "s/typedef.*//" \
// RUN: | grep "__asan_.*(" | sed "s/.* __asan_/__asan_/;s/(.*//" \
// RUN: > %t.interface
// RUN: echo __asan_report_load1 >> %t.interface

View File

@ -8,7 +8,7 @@ CC=$2
FILE_CHECK=$3
CXXFLAGS="-mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -g"
SYMBOLIZER=../scripts/asan_symbolize.py
ASAN_INTERFACE_H=../asan_interface.h
ASAN_INTERFACE_H=../../../include/sanitizer/asan_interface.h
TMP_ASAN_REPORT=asan_report.tmp
run_program() {

View File

@ -11,13 +11,14 @@
//
// This test file should be compiled w/o asan instrumentation.
//===----------------------------------------------------------------------===//
#include "asan_allocator.h"
#include "asan_interface.h"
#include "asan_internal.h"
#include "asan_mapping.h"
#include "asan_stack.h"
#include "asan_test_utils.h"
#include "asan_test_config.h"
#include "sanitizer/asan_interface.h"
#include <assert.h>
#include <stdio.h>

View File

@ -13,7 +13,7 @@
#ifndef SANITIZER_DEFS_H
#define SANITIZER_DEFS_H
#include "sanitizer_interface_defs.h"
#include "sanitizer/common_interface_defs.h"
using namespace __sanitizer; // NOLINT
// ----------- ATTENTION -------------
// This header should NOT include any other headers to avoid portability issues.

View File

@ -18,7 +18,7 @@
// ----------- ATTENTION -------------
// This header should NOT include any other headers from sanitizer runtime.
#include "sanitizer_interface_defs.h"
#include "sanitizer/common_interface_defs.h"
namespace __sanitizer {

View File

@ -42,5 +42,5 @@ endif
###
# Common compiler options
COMMON_CXXFLAGS=-fno-exceptions -fPIC -funwind-tables -I${ProjSrcRoot}/lib
COMMON_CXXFLAGS=-fno-exceptions -fPIC -funwind-tables -I${ProjSrcRoot}/lib -I${ProjSrcRoot}/include
COMMON_CFLAGS=-fPIC