phosek created this revision.
phosek added reviewers: beanz, smeenai.
Herald added subscribers: llvm-commits, cfe-commits, mgorny.
Herald added projects: clang, LLVM.
phosek updated this revision to Diff 195934.

This is a more generic solution; while the sanitizer support can be used
only for sanitizer instrumented builds, the multilib support can be used
to build other variants such as noexcept which is what we would like to use
in Fuchsia.

The name CMake target name uses the target name, same as for the regular
runtimes build and the name of the multilib, concatenated with '+'. The
libraries are installed in a subdirectory named after the multilib.


https://reviews.llvm.org/D60926

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  llvm/runtimes/CMakeLists.txt

Index: llvm/runtimes/CMakeLists.txt
===================================================================
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -70,7 +70,7 @@
   get_compiler_rt_path(compiler_rt_path)
   if(compiler_rt_path)
     list(REMOVE_ITEM runtimes ${compiler_rt_path})
-    if(NOT LLVM_BUILD_COMPILER_RT)
+    if(NOT DEFINED LLVM_BUILD_COMPILER_RT OR LLVM_BUILD_COMPILER_RT)
       list(INSERT runtimes 0 ${compiler_rt_path})
     endif()
   endif()
@@ -242,7 +242,8 @@
 
     get_cmake_property(variableNames VARIABLES)
     foreach(variableName ${variableNames})
-      if(variableName MATCHES "^BUILTINS_${target}")
+      string(FIND "${variableName}" "BUILTINS_${target}" out)
+      if("${out}" EQUAL 0)
         string(REPLACE "BUILTINS_${target}_" "" new_name ${variableName})
         list(APPEND ${target}_extra_args "-D${new_name}=${${variableName}}")
       endif()
@@ -425,10 +426,13 @@
 
     get_cmake_property(variableNames VARIABLES)
     foreach(variableName ${variableNames})
-      if(variableName MATCHES "^RUNTIMES_${name}")
+      string(FIND "${variableName}" "RUNTIMES_${name}" out)
+      if("${out}" EQUAL 0)
         string(REPLACE "RUNTIMES_${name}_" "" new_name ${variableName})
         list(APPEND ${name}_extra_args "-D${new_name}=${${variableName}}")
-      elseif(variableName MATCHES "^RUNTIMES_${target}")
+      endif()
+      string(FIND "${variableName}" "RUNTIMES_${target}" out)
+      if("${out}" EQUAL 0)
         string(REPLACE "RUNTIMES_${target}_" "" new_name ${variableName})
         list(APPEND ${name}_extra_args "-D${new_name}=${${variableName}}")
       endif()
@@ -510,28 +514,16 @@
         endif()
       endforeach()
 
-      foreach(sanitizer ${LLVM_RUNTIME_SANITIZERS})
-        if (sanitizer STREQUAL "Address")
-          set(sanitizer_name "asan")
-        elseif (sanitizer STREQUAL "Memory")
-          set(sanitizer_name "msan")
-        elseif (sanitizer STREQUAL "Thread")
-          set(sanitizer_name "tsan")
-        elseif (sanitizer STREQUAL "Undefined")
-          set(sanitizer_name "ubsan")
-        else()
-          message(FATAL_ERROR "Unsupported value of LLVM_RUNTIME_TARGET_SANITIZERS: ${sanitizers}")
-        endif()
-        foreach(name ${LLVM_RUNTIME_SANITIZER_${sanitizer}_TARGETS})
-          runtime_register_target(${name}-${sanitizer_name} ${name}
+      foreach(multilib ${LLVM_RUNTIME_MULTILIBS})
+        foreach(name ${LLVM_RUNTIME_MULTILIB_${multilib}_TARGETS})
+          runtime_register_target(${name}+${multilib} ${name}
             DEPENDS runtimes-${name}
-            CMAKE_ARGS -DLLVM_USE_SANITIZER=${sanitizer}
-                       -DLLVM_RUNTIMES_PREFIX=${name}/
-                       -DLLVM_RUNTIMES_LIBDIR_SUFFIX=/${sanitizer_name})
-          add_dependencies(runtimes runtimes-${name}-${sanitizer_name})
-          add_dependencies(runtimes-configure runtimes-${name}-${sanitizer_name}-configure)
-          add_dependencies(install-runtimes install-runtimes-${name}-${sanitizer_name})
-          add_dependencies(install-runtimes-stripped install-runtimes-${name}-${sanitizer_name}-stripped)
+            CMAKE_ARGS -DLLVM_RUNTIMES_PREFIX=${name}/
+                       -DLLVM_RUNTIMES_LIBDIR_SUFFIX=/${multilib})
+          add_dependencies(runtimes runtimes-${name}+${multilib})
+          add_dependencies(runtimes-configure runtimes-${name}+${multilib}-configure)
+          add_dependencies(install-runtimes install-runtimes-${name}+${multilib})
+          add_dependencies(install-runtimes-stripped install-runtimes-${name}+${multilib}-stripped)
         endforeach()
       endforeach()
     endif()
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===================================================================
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -142,12 +142,22 @@
     set(RUNTIMES_${target}-fuchsia_LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY OFF CACHE BOOL "")
     set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "")
 
+    set(RUNTIMES_${target}-fuchsia+asan_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
+    set(RUNTIMES_${target}-fuchsia+asan_LLVM_USE_SANITIZER "Address" CACHE STRING "")
+    set(RUNTIMES_${target}-fuchsia+asan_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
+    set(RUNTIMES_${target}-fuchsia+asan_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
+
+    set(RUNTIMES_${target}-fuchsia+noexcept_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
+    set(RUNTIMES_${target}-fuchsia+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
+    set(RUNTIMES_${target}-fuchsia+noexcept_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
+
     # Use .build-id link.
     list(APPEND RUNTIME_BUILD_ID_LINK "${target}-fuchsia")
   endforeach()
 
-  set(LLVM_RUNTIME_SANITIZERS "Address" CACHE STRING "")
-  set(LLVM_RUNTIME_SANITIZER_Address_TARGETS "x86_64-fuchsia;aarch64-fuchsia" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIBS "asan;noexcept" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIB_asan_TARGETS "x86_64-fuchsia;aarch64-fuchsia" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS "x86_64-fuchsia;aarch64-fuchsia" CACHE STRING "")
 endif()
 
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to