forked from OSchip/llvm-project
[LLD][ELF] Add FORCE_LLD_DIAGNOSTICS_CRASH to force LLD to crash
Add FORCE_LLD_DIAGNOSTICS_CRASH inspired by the existing FORCE_CLANG_DIAGNOSTICS_CRASH. This is particularly useful for people customizing LLD as they may want to modify the crash reporting behavior. Differential Revision: https://reviews.llvm.org/D128195
This commit is contained in:
parent
774fc63490
commit
dfb77f2e99
|
@ -29,6 +29,8 @@ ELF Improvements
|
|||
* ``-z pack-relative-relocs`` is now available to support ``DT_RELR`` for glibc 2.36+.
|
||||
(`D120701 <https://reviews.llvm.org/D120701>`_)
|
||||
* ``--no-fortran-common`` (pre 12.0.0 behavior) is now the default.
|
||||
* ``FORCE_LLD_DIAGNOSTICS_CRASH`` environment variable is now available to force LLD to crash.
|
||||
(`D128195 <https://reviews.llvm.org/D128195>`_)
|
||||
|
||||
Breaking changes
|
||||
----------------
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
# REQUIRES: backtrace
|
||||
|
||||
## Test the diagnostics produced when LLD crashes.
|
||||
|
||||
# RUN: env FORCE_LLD_DIAGNOSTICS_CRASH=1 not --crash ld.lld -o /dev/null 2>&1 | FileCheck %s
|
||||
|
||||
## Check the crash text has the correct structure.
|
||||
# CHECK: crashing due to environment variable FORCE_LLD_DIAGNOSTICS_CRASH
|
||||
# CHECK: PLEASE submit a bug report to {{.*}} and include the crash backtrace
|
||||
# CHECK: Stack dump:
|
|
@ -104,6 +104,9 @@ if (lit.util.which('cvtres', config.environment['PATH']) or
|
|||
config.have_libxml2):
|
||||
config.available_features.add('manifest_tool')
|
||||
|
||||
if config.enable_backtrace:
|
||||
config.available_features.add('backtrace')
|
||||
|
||||
if config.have_libxar:
|
||||
config.available_features.add('xar')
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@")
|
|||
config.llvm_shlib_dir = "@SHLIBDIR@"
|
||||
config.llvm_shlib_ext = "@SHLIBEXT@"
|
||||
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
|
||||
config.enable_backtrace = @ENABLE_BACKTRACES@
|
||||
config.errc_messages = "@LLVM_LIT_ERRC_MESSAGES@"
|
||||
config.lld_obj_root = "@LLD_BINARY_DIR@"
|
||||
config.lld_libs_dir = lit_config.substitute("@CURRENT_LIBS_DIR@")
|
||||
|
|
|
@ -214,6 +214,12 @@ int main(int argc, const char **argv) {
|
|||
InitLLVM x(argc, argv);
|
||||
sys::Process::UseANSIEscapeCodes(true);
|
||||
|
||||
if (::getenv("FORCE_LLD_DIAGNOSTICS_CRASH")) {
|
||||
llvm::errs()
|
||||
<< "crashing due to environment variable FORCE_LLD_DIAGNOSTICS_CRASH\n";
|
||||
LLVM_BUILTIN_TRAP;
|
||||
}
|
||||
|
||||
// Not running in lit tests, just take the shortest codepath with global
|
||||
// exception handling and no memory cleanup on exit.
|
||||
if (!inTestVerbosity())
|
||||
|
|
Loading…
Reference in New Issue