Index: lib/Driver/SanitizerArgs.cpp =================================================================== --- lib/Driver/SanitizerArgs.cpp +++ lib/Driver/SanitizerArgs.cpp @@ -45,7 +45,7 @@ Nullability | LocalBounds | CFI, TrappingDefault = CFI, CFIClasses = CFIVCall | CFINVCall | CFIDerivedCast | CFIUnrelatedCast, - CompatibleWithMinimalRuntime = TrappingSupported, + CompatibleWithMinimalRuntime = TrappingSupported | Scudo, }; enum CoverageFeature { @@ -179,7 +179,8 @@ bool SanitizerArgs::needsUbsanRt() const { // All of these include ubsan. if (needsAsanRt() || needsMsanRt() || needsHwasanRt() || needsTsanRt() || - needsDfsanRt() || needsLsanRt() || needsCfiDiagRt() || needsScudoRt()) + needsDfsanRt() || needsLsanRt() || needsCfiDiagRt() || + (needsScudoRt() && !requiresMinimalRuntime())) return false; return (Sanitizers.Mask & NeedsUbsanRt & ~TrapSanitizers.Mask) || Index: lib/Driver/ToolChains/CommonArgs.cpp =================================================================== --- lib/Driver/ToolChains/CommonArgs.cpp +++ lib/Driver/ToolChains/CommonArgs.cpp @@ -593,14 +593,17 @@ HelperStaticRuntimes.push_back("asan-preinit"); } if (SanArgs.needsUbsanRt()) { - if (SanArgs.requiresMinimalRuntime()) { + if (SanArgs.requiresMinimalRuntime()) SharedRuntimes.push_back("ubsan_minimal"); - } else { + else SharedRuntimes.push_back("ubsan_standalone"); - } } - if (SanArgs.needsScudoRt()) - SharedRuntimes.push_back("scudo"); + if (SanArgs.needsScudoRt()) { + if (SanArgs.requiresMinimalRuntime()) + SharedRuntimes.push_back("scudo_minimal"); + else + SharedRuntimes.push_back("scudo"); + } if (SanArgs.needsHwasanRt()) SharedRuntimes.push_back("hwasan"); } @@ -666,9 +669,15 @@ if (SanArgs.needsEsanRt()) StaticRuntimes.push_back("esan"); if (SanArgs.needsScudoRt()) { - StaticRuntimes.push_back("scudo"); - if (SanArgs.linkCXXRuntimes()) - StaticRuntimes.push_back("scudo_cxx"); + if (SanArgs.requiresMinimalRuntime()) { + StaticRuntimes.push_back("scudo_minimal"); + if (SanArgs.linkCXXRuntimes()) + StaticRuntimes.push_back("scudo_cxx_minimal"); + } else { + StaticRuntimes.push_back("scudo"); + if (SanArgs.linkCXXRuntimes()) + StaticRuntimes.push_back("scudo_cxx"); + } } } Index: test/Driver/fsanitize.c =================================================================== --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -674,6 +674,14 @@ // RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo,undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO-UBSAN // CHECK-SCUDO-UBSAN: "-fsanitize={{.*}}scudo" +// RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo -fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO-MINIMAL +// CHECK-SCUDO-MINIMAL: "-fsanitize=scudo" +// CHECK-SCUDO-MINIMAL: "-fsanitize-minimal-runtime" + +// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined,scudo -fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO-UBSAN-MINIMAL +// CHECK-SCUDO-UBSAN-MINIMAL: "-fsanitize={{.*}}scudo" +// CHECK-SCUDO-UBSAN-MINIMAL: "-fsanitize-minimal-runtime" + // RUN: %clang -target powerpc-unknown-linux -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-SCUDO // CHECK-NO-SCUDO: unsupported option Index: test/Driver/sanitizer-ld.c =================================================================== --- test/Driver/sanitizer-ld.c +++ test/Driver/sanitizer-ld.c @@ -689,6 +689,15 @@ // CHECK-SCUDO-LINUX: "-lpthread" // CHECK-SCUDO-LINUX: "-ldl" +// RUN: %clang -fsanitize=scudo -fsanitize-minimal-runtime %s -### -o %t.o 2>&1 \ +// RUN: -target i386-unknown-linux -fuse-ld=ld \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-SCUDO-MINIMAL-LINUX %s +// CHECK-SCUDO-MINIMAL-LINUX: "{{.*}}ld{{(.exe)?}}" +// CHECK-SCUDO-MINIMAL-LINUX: "-pie" +// CHECK-SCUDO-MINIMAL-LINUX: "--whole-archive" "{{.*}}libclang_rt.scudo_minimal-i386.a" "--no-whole-archive" +// CHECK-SCUDO-MINIMAL-LINUX: "-lpthread" + // RUN: %clang -no-canonical-prefixes %s -### -o %t.so -shared 2>&1 \ // RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=scudo -shared-libsan \ // RUN: -resource-dir=%S/Inputs/resource_dir \