Index: b/llvm/llvm-project/clang/include/clang/Basic/DiagnosticDriverKinds.td =================================================================== --- b/llvm/llvm-project/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/llvm/llvm-project/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -222,6 +222,10 @@ "malformed sanitizer metadata ignorelist: '%0'">; def err_drv_unsupported_static_ubsan_darwin : Error< "static UndefinedBehaviorSanitizer runtime is not supported on darwin">; +def err_drv_unsupported_static_tsan_darwin : Error< + "static ThreadSanitizer runtime is not supported on darwin">; +def err_drv_unsupported_static_asan_darwin : Error< + "static AddressSanitizer runtime is not supported on darwin">; def err_drv_duplicate_config : Error< "no more than one option '--config' is allowed">; def err_drv_cannot_open_config_file : Error< Index: b/llvm/llvm-project/clang/include/clang/Driver/Options.td =================================================================== --- b/llvm/llvm-project/clang/include/clang/Driver/Options.td +++ b/llvm/llvm-project/clang/include/clang/Driver/Options.td @@ -1215,7 +1215,7 @@ def shared_libsan : Flag<["-"], "shared-libsan">, HelpText<"Dynamically link the sanitizer runtime">; def static_libsan : Flag<["-"], "static-libsan">, - HelpText<"Statically link the sanitizer runtime">; + HelpText<"Statically link the sanitizer runtime (Not supported for asan, tsan or ubsan on Apple platforms)">; def : Flag<["-"], "shared-libasan">, Alias; def fasm : Flag<["-"], "fasm">, Group; Index: b/llvm/llvm-project/clang/lib/Driver/ToolChains/Darwin.cpp =================================================================== --- b/llvm/llvm-project/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/llvm/llvm-project/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1426,9 +1426,17 @@ const SanitizerArgs &Sanitize = getSanitizerArgs(Args); - if (!Sanitize.needsSharedRt() && Sanitize.needsUbsanRt()) { + if (!Sanitize.needsSharedRt()) { + if (Sanitize.needsUbsanRt()) { getDriver().Diag(diag::err_drv_unsupported_static_ubsan_darwin); return; + } else if (Sanitize.needsAsanRt()) { + getDriver().Diag(diag::err_drv_unsupported_static_asan_darwin); + return; + } else if (Sanitize.needsTsanRt()) { + getDriver().Diag(diag::err_drv_unsupported_static_tsan_darwin); + return; + } } if (Sanitize.linkRuntimes()) { Index: b/llvm/llvm-project/clang/test/Driver/sanitizer-ld.c =================================================================== --- b/llvm/llvm-project/clang/test/Driver/sanitizer-ld.c +++ b/llvm/llvm-project/clang/test/Driver/sanitizer-ld.c @@ -457,6 +457,18 @@ // RUN: | FileCheck --check-prefix=CHECK-UBSAN-STATIC-DARWIN %s // CHECK-UBSAN-STATIC-DARWIN: {{.*}}error: static UndefinedBehaviorSanitizer runtime is not supported on darwin +// RUN: %clang -fsanitize=address -### %s 2>&1 \ +// RUN: --target=x86_64-apple-darwin -fuse-ld=ld -static-libsan \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-ASAN-STATIC-DARWIN %s +// CHECK-ASAN-STATIC-DARWIN: {{.*}}error: static AddressSanitizer runtime is not supported on darwin + +// RUN: %clang -fsanitize=thread -### %s 2>&1 \ +// RUN: --target=x86_64-apple-darwin -fuse-ld=ld -static-libsan \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-TSAN-STATIC-DARWIN %s +// CHECK-TSAN-STATIC-DARWIN: {{.*}}error: static ThreadSanitizer runtime is not supported on darwin + // RUN: %clang -fsanitize=address,undefined -### %s 2>&1 \ // RUN: --target=i386-unknown-linux -fuse-ld=ld \ // RUN: -resource-dir=%S/Inputs/resource_dir \