forked from OSchip/llvm-project
[clang] [Driver] Disable default configs via envvar during testing
Add support for a CLANG_NO_DEFAULT_CONFIG envvar that works like the --no-default-config option when set to a non-empty value. Use it to disable loading system configuration files during the test suite runs. Configuration files can change the driver behavior in extensive ways, and it is neither really possible nor feasible to account for or undo the effects of even the most common configuration uses. Therefore, the most reasonable option seems to be to ignore configuration files while running the majority of tests (with the notable exception of tests for configuration file support). Due to the diversity of ways that %clang is used in the test suite, including using it to copy or symlink the clang executable, as well to call -cc1 and -cc1as modes, it is not feasible to pass the explicit options to disable config loading either. Using an environment variable has the advantage of being easily applied across the test suite and easily unset for default configuration file loading tests. Differential Revision: https://reviews.llvm.org/D134905
This commit is contained in:
parent
81fc5f7909
commit
924996e0a0
|
@ -94,6 +94,7 @@
|
|||
#include "llvm/Support/StringSaver.h"
|
||||
#include "llvm/Support/VirtualFileSystem.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <cstdlib> // ::getenv
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
@ -1066,6 +1067,12 @@ bool Driver::loadConfigFiles() {
|
|||
}
|
||||
|
||||
bool Driver::loadDefaultConfigFiles(ArrayRef<StringRef> CfgFileSearchDirs) {
|
||||
// Disable default config if CLANG_NO_DEFAULT_CONFIG is set to a non-empty
|
||||
// value.
|
||||
if (const char *NoConfigEnv = ::getenv("CLANG_NO_DEFAULT_CONFIG")) {
|
||||
if (*NoConfigEnv)
|
||||
return false;
|
||||
}
|
||||
if (CLOptions && CLOptions->hasArg(options::OPT_no_default_config))
|
||||
return false;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// REQUIRES: shell
|
||||
// REQUIRES: x86-registered-target
|
||||
|
||||
// RUN: unset CLANG_NO_DEFAULT_CONFIG
|
||||
// RUN: rm -rf %t && mkdir %t
|
||||
|
||||
//--- If config file is specified by relative path (workdir/cfg-s2), it is searched for by that path.
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
//
|
||||
// REQUIRES: shell
|
||||
// The PATH variable is heavily used when trying to find a linker.
|
||||
// RUN: env -i LC_ALL=C LD_LIBRARY_PATH="$LD_LIBRARY_PATH" \
|
||||
// RUN: env -i LC_ALL=C LD_LIBRARY_PATH="$LD_LIBRARY_PATH" CLANG_NO_DEFAULT_CONFIG=1 \
|
||||
// RUN: %clang %s -### -o %t.o --target=i386-unknown-linux \
|
||||
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
|
||||
// RUN: --rtlib=platform -no-pie \
|
||||
// RUN: --gcc-toolchain="" 2>&1 | FileCheck --check-prefix=CHECK-LD-32 %s
|
||||
//
|
||||
// RUN: env -i LC_ALL=C PATH="" LD_LIBRARY_PATH="$LD_LIBRARY_PATH" \
|
||||
// RUN: env -i LC_ALL=C PATH="" LD_LIBRARY_PATH="$LD_LIBRARY_PATH" CLANG_NO_DEFAULT_CONFIG=1 \
|
||||
// RUN: %clang %s -### -o %t.o --target=i386-unknown-linux \
|
||||
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
|
||||
// RUN: --rtlib=platform -no-pie \
|
||||
|
|
|
@ -71,3 +71,8 @@ for shlibpath_var in find_shlibpath_var():
|
|||
else:
|
||||
lit_config.warning("unable to inject shared library path on '{}'"
|
||||
.format(platform.system()))
|
||||
|
||||
# It is not realistically possible to account for all options that could
|
||||
# possibly be present in system and user configuration files, so disable
|
||||
# default configs for the test runs.
|
||||
config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
|
||||
|
|
|
@ -284,3 +284,8 @@ elif platform.system() == 'AIX':
|
|||
|
||||
if 'system-aix' in config.available_features:
|
||||
config.substitutions.append(('llvm-nm', 'env OBJECT_MODE=any llvm-nm'))
|
||||
|
||||
# It is not realistically possible to account for all options that could
|
||||
# possibly be present in system and user configuration files, so disable
|
||||
# default configs for the test runs.
|
||||
config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
|
||||
|
|
Loading…
Reference in New Issue