[clang] 6b45e1b - Revert "[clang] Report sanitizer blacklist as a dependency in cc1"
Jeremy Morse via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 8 04:09:04 PST 2019
Author: Jeremy Morse
Date: 2019-11-08T12:07:42Z
New Revision: 6b45e1bc11e91ea7b57a6ab1c19461a86dba33f8
URL: https://github.com/llvm/llvm-project/commit/6b45e1bc11e91ea7b57a6ab1c19461a86dba33f8
DIFF: https://github.com/llvm/llvm-project/commit/6b45e1bc11e91ea7b57a6ab1c19461a86dba33f8.diff
LOG: Revert "[clang] Report sanitizer blacklist as a dependency in cc1"
This reverts commit 03b84e4f6d0e1c04f22d69cc445f36e1f713beb4.
This breaks dfsan tests with a linking failure, in for example this build:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/24312
Reverting this patch locally makes those tests succeed.
Added:
Modified:
clang/include/clang/Driver/Options.td
clang/include/clang/Driver/SanitizerArgs.h
clang/lib/Driver/SanitizerArgs.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/fsanitize-blacklist.c
clang/test/Frontend/dependency-gen.c
Removed:
################################################################################
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index c2e30a16b8da..dcd2976a97f2 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -979,9 +979,6 @@ def fno_sanitize_EQ : CommaJoined<["-"], "fno-sanitize=">, Group<f_clang_Group>,
def fsanitize_blacklist : Joined<["-"], "fsanitize-blacklist=">,
Group<f_clang_Group>,
HelpText<"Path to blacklist file for sanitizers">;
-def fsanitize_system_blacklist : Joined<["-"], "fsanitize-system-blacklist=">,
- HelpText<"Path to system blacklist file for sanitizers">,
- Flags<[CC1Option]>;
def fno_sanitize_blacklist : Flag<["-"], "fno-sanitize-blacklist">,
Group<f_clang_Group>,
HelpText<"Don't use blacklist file for sanitizers">;
diff --git a/clang/include/clang/Driver/SanitizerArgs.h b/clang/include/clang/Driver/SanitizerArgs.h
index 0aebf8cb225d..c37499e0f201 100644
--- a/clang/include/clang/Driver/SanitizerArgs.h
+++ b/clang/include/clang/Driver/SanitizerArgs.h
@@ -25,8 +25,8 @@ class SanitizerArgs {
SanitizerSet RecoverableSanitizers;
SanitizerSet TrapSanitizers;
- std::vector<std::string> UserBlacklistFiles;
- std::vector<std::string> SystemBlacklistFiles;
+ std::vector<std::string> BlacklistFiles;
+ std::vector<std::string> ExtraDeps;
int CoverageFeatures = 0;
int MsanTrackOrigins = 0;
bool MsanUseAfterDtor = true;
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index 8937197c253c..cc6c5e6ef438 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -557,35 +557,29 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
// Setup blacklist files.
// Add default blacklist from resource directory.
- addDefaultBlacklists(D, Kinds, SystemBlacklistFiles);
+ addDefaultBlacklists(D, Kinds, BlacklistFiles);
// Parse -f(no-)sanitize-blacklist options.
for (const auto *Arg : Args) {
if (Arg->getOption().matches(options::OPT_fsanitize_blacklist)) {
Arg->claim();
std::string BLPath = Arg->getValue();
if (llvm::sys::fs::exists(BLPath)) {
- UserBlacklistFiles.push_back(BLPath);
+ BlacklistFiles.push_back(BLPath);
+ ExtraDeps.push_back(BLPath);
} else {
D.Diag(clang::diag::err_drv_no_such_file) << BLPath;
}
} else if (Arg->getOption().matches(options::OPT_fno_sanitize_blacklist)) {
Arg->claim();
- UserBlacklistFiles.clear();
- SystemBlacklistFiles.clear();
+ BlacklistFiles.clear();
+ ExtraDeps.clear();
}
}
// Validate blacklists format.
{
std::string BLError;
std::unique_ptr<llvm::SpecialCaseList> SCL(
- llvm::SpecialCaseList::create(UserBlacklistFiles, BLError));
- if (!SCL.get())
- D.Diag(clang::diag::err_drv_malformed_sanitizer_blacklist) << BLError;
- }
- {
- std::string BLError;
- std::unique_ptr<llvm::SpecialCaseList> SCL(
- llvm::SpecialCaseList::create(SystemBlacklistFiles, BLError));
+ llvm::SpecialCaseList::create(BlacklistFiles, BLError));
if (!SCL.get())
D.Diag(clang::diag::err_drv_malformed_sanitizer_blacklist) << BLError;
}
@@ -958,15 +952,15 @@ void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
CmdArgs.push_back(
Args.MakeArgString("-fsanitize-trap=" + toString(TrapSanitizers)));
- for (const auto &BLPath : UserBlacklistFiles) {
+ for (const auto &BLPath : BlacklistFiles) {
SmallString<64> BlacklistOpt("-fsanitize-blacklist=");
BlacklistOpt += BLPath;
CmdArgs.push_back(Args.MakeArgString(BlacklistOpt));
}
- for (const auto &BLPath : SystemBlacklistFiles) {
- SmallString<64> BlacklistOpt("-fsanitize-system-blacklist=");
- BlacklistOpt += BLPath;
- CmdArgs.push_back(Args.MakeArgString(BlacklistOpt));
+ for (const auto &Dep : ExtraDeps) {
+ SmallString<64> ExtraDepOpt("-fdepfile-entry=");
+ ExtraDepOpt += Dep;
+ CmdArgs.push_back(Args.MakeArgString(ExtraDepOpt));
}
if (MsanTrackOrigins)
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 17fd4ce7752b..195a29d71187 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1447,26 +1447,7 @@ static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
// Add sanitizer blacklists as extra dependencies.
// They won't be discovered by the regular preprocessor, so
// we let make / ninja to know about this implicit dependency.
- if (!Args.hasArg(OPT_fno_sanitize_blacklist)) {
- for (const auto *A : Args.filtered(OPT_fsanitize_blacklist)) {
- StringRef Val = A->getValue();
- if (Val.find('=') == StringRef::npos)
- Opts.ExtraDeps.push_back(Val);
- }
- if (Opts.IncludeSystemHeaders) {
- for (const auto *A : Args.filtered(OPT_fsanitize_system_blacklist)) {
- StringRef Val = A->getValue();
- if (Val.find('=') == StringRef::npos)
- Opts.ExtraDeps.push_back(Val);
- }
- }
- }
-
- // Propagate the extra dependencies.
- for (const auto *A : Args.filtered(OPT_fdepfile_entry)) {
- Opts.ExtraDeps.push_back(A->getValue());
- }
-
+ Opts.ExtraDeps = Args.getAllArgValues(OPT_fdepfile_entry);
// Only the -fmodule-file=<file> form.
for (const auto *A : Args.filtered(OPT_fmodule_file)) {
StringRef Val = A->getValue();
diff --git a/clang/test/Driver/fsanitize-blacklist.c b/clang/test/Driver/fsanitize-blacklist.c
index 6878298e6752..e08905c94eda 100644
--- a/clang/test/Driver/fsanitize-blacklist.c
+++ b/clang/test/Driver/fsanitize-blacklist.c
@@ -16,18 +16,22 @@
// RUN: %clang -target aarch64-linux-gnu -fsanitize=hwaddress -fsanitize-blacklist=%t.good -fsanitize-blacklist=%t.second %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-BLACKLIST
// CHECK-BLACKLIST: -fsanitize-blacklist={{.*}}.good" "-fsanitize-blacklist={{.*}}.second
+// Now, check for -fdepfile-entry flags.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-blacklist=%t.good -fsanitize-blacklist=%t.second %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-BLACKLIST2
+// CHECK-BLACKLIST2: -fdepfile-entry={{.*}}.good" "-fdepfile-entry={{.*}}.second
+
// Check that the default blacklist is not added as an extra dependency.
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-BLACKLIST-ASAN --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist=
-// CHECK-DEFAULT-BLACKLIST-ASAN: -fsanitize-system-blacklist={{.*[^w]}}asan_blacklist.txt
+// CHECK-DEFAULT-BLACKLIST-ASAN: -fsanitize-blacklist={{.*[^w]}}asan_blacklist.txt
// RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-BLACKLIST-HWASAN --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist=
-// CHECK-DEFAULT-BLACKLIST-HWASAN: -fsanitize-system-blacklist={{.*}}hwasan_blacklist.txt
+// CHECK-DEFAULT-BLACKLIST-HWASAN: -fsanitize-blacklist={{.*}}hwasan_blacklist.txt
// RUN: %clang -target x86_64-linux-gnu -fsanitize=integer -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-UBSAN-BLACKLIST --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist=
// RUN: %clang -target x86_64-linux-gnu -fsanitize=nullability -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-UBSAN-BLACKLIST --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist=
// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-UBSAN-BLACKLIST --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist=
// RUN: %clang -target x86_64-linux-gnu -fsanitize=alignment -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-UBSAN-BLACKLIST --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist=
// RUN: %clang -target %itanium_abi_triple -fsanitize=float-divide-by-zero -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-UBSAN-BLACKLIST --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist=
-// CHECK-DEFAULT-UBSAN-BLACKLIST: -fsanitize-system-blacklist={{.*}}ubsan_blacklist.txt
+// CHECK-DEFAULT-UBSAN-BLACKLIST: -fsanitize-blacklist={{.*}}ubsan_blacklist.txt
// Check that combining ubsan and another sanitizer results in both blacklists being used.
// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined,address -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-UBSAN-BLACKLIST --check-prefix=CHECK-DEFAULT-ASAN-BLACKLIST --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist=
diff --git a/clang/test/Frontend/dependency-gen.c b/clang/test/Frontend/dependency-gen.c
index 1db9b04c1d9f..963419cb1188 100644
--- a/clang/test/Frontend/dependency-gen.c
+++ b/clang/test/Frontend/dependency-gen.c
@@ -27,20 +27,3 @@
#ifndef INCLUDE_FLAG_TEST
#include <x.h>
#endif
-
-// RUN: echo "fun:foo" > %t.blacklist1
-// RUN: echo "fun:foo" > %t.blacklist2
-// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist1 -fsanitize-blacklist=%t.blacklist2 -I ./ | FileCheck -check-prefix=TWO-BLACK-LISTS %s
-// TWO-BLACK-LISTS: dependency-gen.o:
-// TWO-BLACK-LISTS-DAG: blacklist1
-// TWO-BLACK-LISTS-DAG: blacklist2
-// TWO-BLACK-LISTS-DAG: x.h
-// TWO-BLACK-LISTS-DAG: dependency-gen.c
-
-// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -I ./ | FileCheck -check-prefix=USER-AND-SYS-DEPS %s
-// USER-AND-SYS-DEPS: dependency-gen.o:
-// USER-AND-SYS-DEPS-DAG: cfi_blacklist.txt
-
-// RUN: %clang -MMD -MF - %s -fsyntax-only -resource-dir=%S/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -I ./ | FileCheck -check-prefix=ONLY-USER-DEPS %s
-// ONLY-USER-DEPS: dependency-gen.o:
-// NOT-ONLY-USER-DEPS: cfi_blacklist.txt
\ No newline at end of file
More information about the cfe-commits
mailing list