[PATCH] D131916: [gn build] Add ubsan libraries

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 15 13:05:01 PDT 2022


aeubanks created this revision.
aeubanks added a reviewer: thakis.
Herald added a subscriber: Enna1.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

clang -fsanitize=undefined works with this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131916

Files:
  llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
  llvm/utils/gn/secondary/compiler-rt/lib/ubsan/BUILD.gn


Index: llvm/utils/gn/secondary/compiler-rt/lib/ubsan/BUILD.gn
===================================================================
--- llvm/utils/gn/secondary/compiler-rt/lib/ubsan/BUILD.gn
+++ llvm/utils/gn/secondary/compiler-rt/lib/ubsan/BUILD.gn
@@ -1,3 +1,12 @@
+import("//compiler-rt/target.gni")
+
+group("ubsan") {
+  deps = [
+    ":ubsan_standalone",
+    ":ubsan_standalone_cxx",
+  ]
+}
+
 source_set("sources") {
   configs -= [ "//llvm/utils/gn/build:llvm_code" ]
   configs += [ "//llvm/utils/gn/build:crt_code" ]
@@ -46,7 +55,6 @@
   sources = [ "ubsan_win_dynamic_runtime_thunk.cpp" ]
 }
 
-# Unreferenced; at the moment exists to make sync_source_lists_from_cmake happy.
 source_set("standalone_sources") {
   configs -= [ "//llvm/utils/gn/build:llvm_code" ]
   configs -= [ "//llvm/utils/gn/build:no_rtti" ]
@@ -57,6 +65,11 @@
     "ubsan_init_standalone.cpp",
     "ubsan_signals_standalone.cpp",
   ]
+  deps = [
+    ":sources",
+    "//compiler-rt/lib/interception:sources",
+    "//compiler-rt/lib/sanitizer_common:sources",
+  ]
 }
 
 source_set("cxx_sources") {
@@ -72,3 +85,31 @@
     "ubsan_type_hash_win.cpp",
   ]
 }
+
+static_library("ubsan_standalone") {
+  output_dir = crt_current_out_dir
+  output_name = "clang_rt.ubsan_standalone$crt_current_target_suffix"
+  complete_static_lib = true
+  configs -= [
+    "//llvm/utils/gn/build:llvm_code",
+    "//llvm/utils/gn/build:thin_archive",
+  ]
+  deps = [
+    ":sources",
+    ":standalone_sources",
+  ]
+  configs += [ "//llvm/utils/gn/build:crt_code" ]
+  sources = [ "ubsan_init_standalone_preinit.cpp" ]
+}
+
+static_library("ubsan_standalone_cxx") {
+  output_dir = crt_current_out_dir
+  output_name = "clang_rt.ubsan_standalone_cxx$crt_current_target_suffix"
+  complete_static_lib = true
+  configs -= [
+    "//llvm/utils/gn/build:llvm_code",
+    "//llvm/utils/gn/build:thin_archive",
+  ]
+  deps = [ ":cxx_sources" ]
+  configs += [ "//llvm/utils/gn/build:crt_code" ]
+}
Index: llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
===================================================================
--- llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
+++ llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
@@ -7,7 +7,10 @@
     deps += [ "//compiler-rt/lib/msan" ]
   }
   if (current_os == "linux" || current_os == "android") {
-    deps += [ "//compiler-rt/lib/ubsan_minimal" ]
+    deps += [
+      "//compiler-rt/lib/ubsan",
+      "//compiler-rt/lib/ubsan_minimal",
+    ]
   }
   if (current_os != "win" && current_os != "baremetal") {
     deps += [ "//compiler-rt/lib/asan" ]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131916.452787.patch
Type: text/x-patch
Size: 2575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220815/752ec391/attachment.bin>


More information about the llvm-commits mailing list