[PATCH] D62039: [GWP-ASan] Add missing dependency on C++ headers

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 16 15:33:26 PDT 2019


phosek created this revision.
phosek added reviewers: morehouse, vitalybuka, smeenai, beanz.
Herald added subscribers: llvm-commits, Sanitizers, mgorny, kubamracek.
Herald added projects: LLVM, Sanitizers.

GWP-ASan implementation uses standard C++ headers. When C++ library
is being built as part of the toolchain rather than relying on the
host one, we need to make sure that headers are in place before we
start building GWP-ASan otherwise the build will fail. This is the
same solution that's already used by other runtimes: ASan, HWASan,
libFuzzer and XRay.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D62039

Files:
  compiler-rt/cmake/Modules/AddCompilerRT.cmake
  compiler-rt/lib/gwp_asan/CMakeLists.txt


Index: compiler-rt/lib/gwp_asan/CMakeLists.txt
===================================================================
--- compiler-rt/lib/gwp_asan/CMakeLists.txt
+++ compiler-rt/lib/gwp_asan/CMakeLists.txt
@@ -15,6 +15,10 @@
 # GwpAsan libraries using the Clang C compiler.
 set(GWP_ASAN_CFLAGS -fno-rtti -fno-exceptions)
 
+if (TARGET cxx-headers OR HAVE_LIBCXX)
+  set(GWP_ASAN_DEPS cxx-headers)
+endif()
+
 if (COMPILER_RT_HAS_GWP_ASAN)
   foreach(arch ${GWP_ASAN_SUPPORTED_ARCH})
     add_compiler_rt_runtime(
@@ -24,6 +28,7 @@
       SOURCES ${GWP_ASAN_SOURCES}
       ADDITIONAL_HEADERS ${GWP_ASAN_HEADERS}
       CFLAGS ${GWP_ASAN_CFLAGS}
+      DEPS ${GWP_ASAN_DEPS}
       PARENT_TARGET gwp_asan
     )
   endforeach()
@@ -32,5 +37,6 @@
       ARCHS ${GWP_ASAN_SUPPORTED_ARCH}
       SOURCES ${GWP_ASAN_SOURCES}
       ADDITIONAL_HEADERS ${GWP_ASAN_HEADERS}
-      CFLAGS ${GWP_ASAN_CFLAGS})
+      CFLAGS ${GWP_ASAN_CFLAGS}
+      DEPS ${GWP_ASAN_DEPS})
 endif()
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake
===================================================================
--- compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -139,6 +139,7 @@
 #                         CFLAGS <compile flags>
 #                         LINK_FLAGS <linker flags>
 #                         DEFS <compile definitions>
+#                         DEPS <dependencies>
 #                         LINK_LIBS <linked libraries> (only for shared library)
 #                         OBJECT_LIBS <object libraries to use as sources>
 #                         PARENT_TARGET <convenience parent target>
@@ -151,7 +152,7 @@
   cmake_parse_arguments(LIB
     ""
     "PARENT_TARGET"
-    "OS;ARCHS;SOURCES;CFLAGS;LINK_FLAGS;DEFS;LINK_LIBS;OBJECT_LIBS;ADDITIONAL_HEADERS"
+    "OS;ARCHS;SOURCES;CFLAGS;LINK_FLAGS;DEFS;DEPS;LINK_LIBS;OBJECT_LIBS;ADDITIONAL_HEADERS"
     ${ARGN})
   set(libnames)
   # Until we support this some other way, build compiler-rt runtime without LTO
@@ -293,6 +294,9 @@
         ${COMPONENT_OPTION})
     else()
       add_library(${libname} ${type} ${sources_${libname}})
+      if(LIB_DEPS)
+        add_dependencies(${libname} ${LIB_DEPS})
+      endif()
       set_target_compile_flags(${libname} ${extra_cflags_${libname}})
       set_target_link_flags(${libname} ${extra_link_flags_${libname}})
       set_property(TARGET ${libname} APPEND PROPERTY


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62039.199918.patch
Type: text/x-patch
Size: 2418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190516/eb7046e5/attachment.bin>


More information about the llvm-commits mailing list