[compiler-rt] r255735 - [cfi] Exclude ubsan runtime library from non-diag CFI builds.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 15 16:38:41 PST 2015


Author: eugenis
Date: Tue Dec 15 18:38:41 2015
New Revision: 255735

URL: http://llvm.org/viewvc/llvm-project?rev=255735&view=rev
Log:
[cfi] Exclude ubsan runtime library from non-diag CFI builds.

Split the CFI runtime in two: cfi and cfi_diag. The latter includes
UBSan runtime to allow printing diagnostics.

Modified:
    compiler-rt/trunk/lib/cfi/CMakeLists.txt
    compiler-rt/trunk/lib/cfi/cfi.cc

Modified: compiler-rt/trunk/lib/cfi/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/cfi/CMakeLists.txt?rev=255735&r1=255734&r2=255735&view=diff
==============================================================================
--- compiler-rt/trunk/lib/cfi/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/cfi/CMakeLists.txt Tue Dec 15 18:38:41 2015
@@ -8,6 +8,10 @@ set(CFI_CFLAGS
   ${SANITIZER_COMMON_CFLAGS}
 )
 
+set(CFI_DIAG_CFLAGS
+  -DCFI_ENABLE_DIAG=1
+)
+
 foreach(arch ${CFI_SUPPORTED_ARCH})
   add_compiler_rt_runtime(clang_rt.cfi
     STATIC
@@ -16,9 +20,18 @@ foreach(arch ${CFI_SUPPORTED_ARCH})
     OBJECT_LIBS RTInterception
                 RTSanitizerCommon
                 RTSanitizerCommonLibc
+    CFLAGS ${CFI_CFLAGS}
+    PARENT_TARGET cfi)
+  add_compiler_rt_runtime(clang_rt.cfi_diag
+    STATIC
+    ARCHS ${arch}
+    SOURCES ${CFI_SOURCES}
+    OBJECT_LIBS RTInterception
+                RTSanitizerCommon
+                RTSanitizerCommonLibc
 		RTUbsan
 		RTUbsan_cxx
-    CFLAGS ${CFI_CFLAGS}
+    CFLAGS ${CFI_CFLAGS} ${CFI_DIAG_CFLAGS}
     PARENT_TARGET cfi)
 endforeach()
 

Modified: compiler-rt/trunk/lib/cfi/cfi.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/cfi/cfi.cc?rev=255735&r1=255734&r2=255735&view=diff
==============================================================================
--- compiler-rt/trunk/lib/cfi/cfi.cc (original)
+++ compiler-rt/trunk/lib/cfi/cfi.cc Tue Dec 15 18:38:41 2015
@@ -208,21 +208,24 @@ void __cfi_slowpath(uptr CallSiteTypeId,
 
 static void InitializeFlags() {
   SetCommonFlagsDefaults();
+#ifdef CFI_ENABLE_DIAG
   __ubsan::Flags *uf = __ubsan::flags();
   uf->SetDefaults();
+#endif
 
   FlagParser cfi_parser;
   RegisterCommonFlags(&cfi_parser);
+  cfi_parser.ParseString(GetEnv("CFI_OPTIONS"));
 
+#ifdef CFI_ENABLE_DIAG
   FlagParser ubsan_parser;
   __ubsan::RegisterUbsanFlags(&ubsan_parser, uf);
   RegisterCommonFlags(&ubsan_parser);
 
   const char *ubsan_default_options = __ubsan::MaybeCallUbsanDefaultOptions();
   ubsan_parser.ParseString(ubsan_default_options);
-
-  cfi_parser.ParseString(GetEnv("CFI_OPTIONS"));
   ubsan_parser.ParseString(GetEnv("UBSAN_OPTIONS"));
+#endif
 
   SetVerbosity(common_flags()->verbosity);
 
@@ -252,7 +255,9 @@ void __cfi_init() {
   __cfi_shadow = (uptr)shadow;
   init_shadow();
 
+#ifdef CFI_ENABLE_DIAG
   __ubsan::InitAsPlugin();
+#endif
 }
 
 #if SANITIZER_CAN_USE_PREINIT_ARRAY




More information about the llvm-commits mailing list