[llvm] 8140f6b - scudo: Create a public include directory. NFCI.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 23 18:23:55 PDT 2020


Author: Peter Collingbourne
Date: 2020-03-23T18:23:29-07:00
New Revision: 8140f6bcde4256b06ce8bfc85d99db6e13f435e3

URL: https://github.com/llvm/llvm-project/commit/8140f6bcde4256b06ce8bfc85d99db6e13f435e3
DIFF: https://github.com/llvm/llvm-project/commit/8140f6bcde4256b06ce8bfc85d99db6e13f435e3.diff

LOG: scudo: Create a public include directory. NFCI.

For MTE error reporting we will need to expose interfaces for crash handlers
to use to interpret scudo headers and metadata. The intent is that these
interfaces will live in scudo/interface.h.

Move the existing interface.h into an include/scudo directory and make it
independent of the internal headers, so that we will be able to add the
interfaces there.

Differential Revision: https://reviews.llvm.org/D76648

Added: 
    compiler-rt/lib/scudo/standalone/include/scudo/interface.h

Modified: 
    compiler-rt/lib/scudo/standalone/CMakeLists.txt
    compiler-rt/lib/scudo/standalone/combined.h
    compiler-rt/lib/scudo/standalone/flags.cpp
    compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
    llvm/utils/gn/secondary/compiler-rt/lib/scudo/standalone/BUILD.gn

Removed: 
    compiler-rt/lib/scudo/standalone/interface.h


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/CMakeLists.txt b/compiler-rt/lib/scudo/standalone/CMakeLists.txt
index 91b48b7064d3..bdaeb569efdd 100644
--- a/compiler-rt/lib/scudo/standalone/CMakeLists.txt
+++ b/compiler-rt/lib/scudo/standalone/CMakeLists.txt
@@ -3,7 +3,7 @@ if (COMPILER_RT_HAS_GWP_ASAN)
   add_dependencies(scudo_standalone gwp_asan)
 endif()
 
-include_directories(../..)
+include_directories(../.. include)
 
 set(SCUDO_CFLAGS)
 
@@ -56,7 +56,6 @@ set(SCUDO_HEADERS
   flags.h
   flags_parser.h
   fuchsia.h
-  interface.h
   internal_defs.h
   linux.h
   list.h
@@ -78,6 +77,8 @@ set(SCUDO_HEADERS
   vector.h
   wrappers_c_checks.h
   wrappers_c.h
+
+  include/scudo/interface.h
   )
 
 set(SCUDO_SOURCES

diff  --git a/compiler-rt/lib/scudo/standalone/combined.h b/compiler-rt/lib/scudo/standalone/combined.h
index 1aa93510d22a..1fffea4dc5c2 100644
--- a/compiler-rt/lib/scudo/standalone/combined.h
+++ b/compiler-rt/lib/scudo/standalone/combined.h
@@ -13,7 +13,6 @@
 #include "common.h"
 #include "flags.h"
 #include "flags_parser.h"
-#include "interface.h"
 #include "local_cache.h"
 #include "memtag.h"
 #include "quarantine.h"
@@ -22,6 +21,8 @@
 #include "string_utils.h"
 #include "tsd.h"
 
+#include "scudo/interface.h"
+
 #ifdef GWP_ASAN_HOOKS
 #include "gwp_asan/guarded_pool_allocator.h"
 #include "gwp_asan/optional/backtrace.h"

diff  --git a/compiler-rt/lib/scudo/standalone/flags.cpp b/compiler-rt/lib/scudo/standalone/flags.cpp
index dd9f050a2d20..de5153b288b1 100644
--- a/compiler-rt/lib/scudo/standalone/flags.cpp
+++ b/compiler-rt/lib/scudo/standalone/flags.cpp
@@ -9,7 +9,8 @@
 #include "flags.h"
 #include "common.h"
 #include "flags_parser.h"
-#include "interface.h"
+
+#include "scudo/interface.h"
 
 namespace scudo {
 

diff  --git a/compiler-rt/lib/scudo/standalone/interface.h b/compiler-rt/lib/scudo/standalone/include/scudo/interface.h
similarity index 65%
rename from compiler-rt/lib/scudo/standalone/interface.h
rename to compiler-rt/lib/scudo/standalone/include/scudo/interface.h
index e2639823f426..e527d0a5d304 100644
--- a/compiler-rt/lib/scudo/standalone/interface.h
+++ b/compiler-rt/lib/scudo/standalone/include/scudo/interface.h
@@ -1,4 +1,4 @@
-//===-- interface.h ---------------------------------------------*- C++ -*-===//
+//===-- scudo/interface.h ---------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -9,18 +9,16 @@
 #ifndef SCUDO_INTERFACE_H_
 #define SCUDO_INTERFACE_H_
 
-#include "internal_defs.h"
-
 extern "C" {
 
-WEAK INTERFACE const char *__scudo_default_options();
+__attribute__((weak)) const char *__scudo_default_options();
 
 // Post-allocation & pre-deallocation hooks.
 // They must be thread-safe and not use heap related functions.
-WEAK INTERFACE void __scudo_allocate_hook(void *ptr, size_t size);
-WEAK INTERFACE void __scudo_deallocate_hook(void *ptr);
+__attribute__((weak)) void __scudo_allocate_hook(void *ptr, size_t size);
+__attribute__((weak)) void __scudo_deallocate_hook(void *ptr);
 
-WEAK INTERFACE void __scudo_print_stats(void);
+void __scudo_print_stats(void);
 
 typedef void (*iterate_callback)(uintptr_t base, size_t size, void *arg);
 

diff  --git a/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt b/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
index e29f158d61f8..78c297ae7e80 100644
--- a/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
+++ b/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
@@ -10,6 +10,7 @@ set(SCUDO_UNITTEST_CFLAGS
   -I${COMPILER_RT_SOURCE_DIR}/include
   -I${COMPILER_RT_SOURCE_DIR}/lib
   -I${COMPILER_RT_SOURCE_DIR}/lib/scudo/standalone
+  -I${COMPILER_RT_SOURCE_DIR}/lib/scudo/standalone/include
   -DGTEST_HAS_RTTI=0
   -DSCUDO_DEBUG=1
   # Extra flags for the C++ tests

diff  --git a/llvm/utils/gn/secondary/compiler-rt/lib/scudo/standalone/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/scudo/standalone/BUILD.gn
index 88b820ad03ed..2cb5613810cc 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/scudo/standalone/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/scudo/standalone/BUILD.gn
@@ -88,7 +88,10 @@ source_set("cxx_wrapper_sources") {
 }
 
 config("scudo_config") {
-  include_dirs = [ "//compiler-rt/lib/scudo/standalone" ]
+  include_dirs = [
+    "//compiler-rt/lib/scudo/standalone",
+    "//compiler-rt/lib/scudo/standalone/include",
+  ]
   if (current_os == "android") {
     cflags = [ "-fno-emulated-tls" ]
   }


        


More information about the llvm-commits mailing list