[llvm] b098407 - [gn build] build libclang_rt.ubsan_osx_dynamic.dylib on mac
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 17 12:36:59 PDT 2022
Author: Nico Weber
Date: 2022-08-17T15:35:41-04:00
New Revision: b098407280292009180507751f9ad256b19d95a0
URL: https://github.com/llvm/llvm-project/commit/b098407280292009180507751f9ad256b19d95a0
DIFF: https://github.com/llvm/llvm-project/commit/b098407280292009180507751f9ad256b19d95a0.diff
LOG: [gn build] build libclang_rt.ubsan_osx_dynamic.dylib on mac
For now, this only builds the dylib, so using `-fsanitize=undefined`
with `-static-libsan` or `fsanitize-minimal-runtime` still won't
work -- but the common case does work.
Differential Revision: https://reviews.llvm.org/D131969
Added:
Modified:
llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
llvm/utils/gn/secondary/compiler-rt/lib/ubsan/BUILD.gn
Removed:
################################################################################
diff --git a/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
index 324ec38be812a..acbe616b19b4e 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
@@ -6,11 +6,11 @@ group("lib") {
if (current_os == "linux") {
deps += [ "//compiler-rt/lib/msan" ]
}
- if (current_os == "linux" || current_os == "android") {
- deps += [
- "//compiler-rt/lib/ubsan",
- "//compiler-rt/lib/ubsan_minimal",
- ]
+ if (current_os == "android" || current_os == "linux" || current_os == "mac") {
+ deps += [ "//compiler-rt/lib/ubsan" ]
+ }
+ if (current_os == "android" || current_os == "linux") {
+ deps += [ "//compiler-rt/lib/ubsan_minimal" ]
}
if (current_os != "win" && current_os != "baremetal") {
deps += [ "//compiler-rt/lib/asan" ]
diff --git a/llvm/utils/gn/secondary/compiler-rt/lib/ubsan/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/ubsan/BUILD.gn
index 957c67909724f..fb7cb827060f3 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/ubsan/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/ubsan/BUILD.gn
@@ -1,10 +1,14 @@
import("//compiler-rt/target.gni")
group("ubsan") {
- deps = [
- ":ubsan_standalone",
- ":ubsan_standalone_cxx",
- ]
+ if (current_os == "mac") {
+ deps = [ ":ubsan_shared_library" ]
+ } else {
+ deps = [
+ ":ubsan_standalone",
+ ":ubsan_standalone_cxx",
+ ]
+ }
}
source_set("sources") {
@@ -86,8 +90,43 @@ source_set("cxx_sources") {
]
}
-# FIXME: Make ubsan_standalone work on mac.
-if (current_os != "mac") {
+if (current_os == "mac") {
+ shared_library("ubsan_shared_library") {
+ output_dir = crt_current_out_dir
+ output_name = "clang_rt.ubsan_osx_dynamic"
+ deps = [
+ ":cxx_sources",
+ ":sources",
+ ":standalone_sources",
+ "//compiler-rt/lib/interception:sources",
+ "//compiler-rt/lib/sanitizer_common:sources",
+ ]
+ # The -U flags below correspond to the add_weak_symbols() calls in CMake.
+ ldflags = [
+ "-lc++",
+ "-lc++abi",
+
+ # ubsan
+ "-Wl,-U,___ubsan_default_options",
+
+ # sanitizer_common
+ "-Wl,-U,___sanitizer_free_hook",
+ "-Wl,-U,___sanitizer_malloc_hook",
+ "-Wl,-U,___sanitizer_report_error_summary",
+ "-Wl,-U,___sanitizer_sandbox_on_notify",
+ "-Wl,-U,___sanitizer_symbolize_code",
+ "-Wl,-U,___sanitizer_symbolize_data",
+ "-Wl,-U,___sanitizer_symbolize_demangle",
+ "-Wl,-U,___sanitizer_symbolize_flush",
+ "-Wl,-U,___sanitizer_symbolize_set_demangle",
+ "-Wl,-U,___sanitizer_symbolize_set_inline_frames",
+
+ # FIXME: better
+ "-Wl,-install_name, at rpath/libclang_rt.ubsan_osx_dynamic.dylib",
+ ]
+ # FIXME: -Wl,-rpath
+ }
+} else {
static_library("ubsan_standalone") {
output_dir = crt_current_out_dir
output_name = "clang_rt.ubsan_standalone$crt_current_target_suffix"
More information about the llvm-commits
mailing list