forked from OSchip/llvm-project
Driver: Accept multiple --config options if filenames are the same
Summary: We're trying to use the --config options to pass distro specific options for Fedora via the CFLAGS variable. However, some projects end up using the CFLAGS variable multiple times in their command line, which leads to an error when --config is used. This patch resolves this issue by allowing more than one --config option on the command line as long as the file names are the same. Reviewers: sepavloff, hfinkel Reviewed By: sepavloff Subscribers: cfe-commits, llvm-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D81424
This commit is contained in:
parent
b4bc72afb7
commit
d970ab63e2
|
@ -833,8 +833,12 @@ bool Driver::loadConfigFile() {
|
||||||
std::vector<std::string> ConfigFiles =
|
std::vector<std::string> ConfigFiles =
|
||||||
CLOptions->getAllArgValues(options::OPT_config);
|
CLOptions->getAllArgValues(options::OPT_config);
|
||||||
if (ConfigFiles.size() > 1) {
|
if (ConfigFiles.size() > 1) {
|
||||||
Diag(diag::err_drv_duplicate_config);
|
if (!std::all_of(
|
||||||
return true;
|
ConfigFiles.begin(), ConfigFiles.end(),
|
||||||
|
[ConfigFiles](std::string s) { return s == ConfigFiles[0]; })) {
|
||||||
|
Diag(diag::err_drv_duplicate_config);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ConfigFiles.empty()) {
|
if (!ConfigFiles.empty()) {
|
||||||
|
|
|
@ -71,3 +71,8 @@
|
||||||
// RUN: %clang --config-system-dir=%S/Inputs/config --config-user-dir=%S/Inputs/config2 --config config-4 -S %s -o /dev/null -v 2>&1 | FileCheck %s -check-prefix CHECK-PRECEDENCE
|
// RUN: %clang --config-system-dir=%S/Inputs/config --config-user-dir=%S/Inputs/config2 --config config-4 -S %s -o /dev/null -v 2>&1 | FileCheck %s -check-prefix CHECK-PRECEDENCE
|
||||||
// CHECK-PRECEDENCE: Configuration file: {{.*}}Inputs{{.}}config2{{.}}config-4.cfg
|
// CHECK-PRECEDENCE: Configuration file: {{.*}}Inputs{{.}}config2{{.}}config-4.cfg
|
||||||
// CHECK-PRECEDENCE: -Wall
|
// CHECK-PRECEDENCE: -Wall
|
||||||
|
|
||||||
|
|
||||||
|
//--- Duplicate --config options are allowed if the value is the same
|
||||||
|
// RUN: %clang --config-system-dir=%S/Inputs/config --config-user-dir=%S/Inputs/config2 --config config-4 --config config-4 -S %s -o /dev/null -v 2>&1 | FileCheck %s -check-prefix CHECK-SAME-CONFIG
|
||||||
|
// CHECK-SAME-CONFIG: Configuration file: {{.*}}Inputs{{.}}config2{{.}}config-4.cfg
|
||||||
|
|
Loading…
Reference in New Issue