[libc] change ASAN condition to generator expression
authorMichael Jones <michaelrj@google.com>
Mon, 14 Feb 2022 23:15:22 +0000 (15:15 -0800)
committerMichael Jones <michaelrj@google.com>
Wed, 16 Feb 2022 00:12:12 +0000 (16:12 -0800)
Previously, building LLVM-libc with GWP ASAN was conditioned on the flag
COMPILER_RT_BUILD_GWP_ASAN, which caused issues do to the default value
of the flag being set in the compiler-rt cmake, which is seperate. Now
GWP ASAN is included based on if it exists as a target, which is more
consistent.

Reviewed By: sivachandra

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

libc/cmake/modules/LLVMLibCLibraryRules.cmake
libc/src/stdlib/CMakeLists.txt

index 14a2bc5..5d7c654 100644 (file)
@@ -82,7 +82,7 @@ function(add_entrypoint_library target_name)
   list(REMOVE_DUPLICATES all_deps)
   set(objects "")
   foreach(dep IN LISTS all_deps)
-    list(APPEND objects $<TARGET_OBJECTS:${dep}>)
+    list(APPEND objects $<$<STREQUAL:$<TARGET_NAME_IF_EXISTS:${dep}>,${dep}>:$<TARGET_OBJECTS:${dep}>>)
   endforeach(dep)
 
   add_library(
index d27d86f..d679b06 100644 (file)
@@ -210,17 +210,16 @@ if(LLVM_LIBC_INCLUDE_SCUDO)
     message(FATAL_ERROR "Architecture ${LIBC_TARGET_ARCHITECTURE} is not supported by SCUDO. 
       Either disable LLVM_LIBC_INCLUDE_SCUDO or change your target architecture.")
   endif()
-  list(APPEND SCUDO_DEPS RTScudoStandalone.${LIBC_TARGET_ARCHITECTURE} 
-       RTScudoStandaloneCWrappers.${LIBC_TARGET_ARCHITECTURE})
-  if((LIBC_TARGET_ARCHITECTURE IN_LIST ALL_GWP_ASAN_SUPPORTED_ARCH) 
-      AND COMPILER_RT_BUILD_GWP_ASAN)
-    list(APPEND SCUDO_DEPS RTGwpAsan.${LIBC_TARGET_ARCHITECTURE} 
-                            RTGwpAsanBacktraceLibc.${LIBC_TARGET_ARCHITECTURE} 
-                            RTGwpAsanSegvHandler.${LIBC_TARGET_ARCHITECTURE})
-  elseif(COMPILER_RT_BUILD_GWP_ASAN)
-    message(WARNING "Architecture ${LIBC_TARGET_ARCHITECTURE} is not supported by GWP-ASan. Skipping.")
-  endif()
 
+  list(APPEND SCUDO_DEPS RTScudoStandalone.${LIBC_TARGET_ARCHITECTURE}
+      RTScudoStandaloneCWrappers.${LIBC_TARGET_ARCHITECTURE})
+
+  list(APPEND SCUDO_DEPS
+    RTGwpAsan.${LIBC_TARGET_ARCHITECTURE}
+    RTGwpAsanBacktraceLibc.${LIBC_TARGET_ARCHITECTURE}
+    RTGwpAsanSegvHandler.${LIBC_TARGET_ARCHITECTURE}
+    )
+  
   add_entrypoint_external(
     malloc
     DEPENDS