Index: lld/ELF/Driver.cpp =================================================================== --- lld/ELF/Driver.cpp +++ lld/ELF/Driver.cpp @@ -510,6 +510,13 @@ ELFOptTable parser; opt::InputArgList args = parser.parse(argsArr.slice(1)); + // SCE: Force a crash to test the diagnostics. + if (::getenv("FORCE_LLD_DIAGNOSTICS_CRASH")) { + message("crashing due to environment variable FORCE_LLD_DIAGNOSTICS_CRASH"); + LLVM_BUILTIN_TRAP; + } + // SCE: end + // Interpret these flags early because error()/warn() depend on them. errorHandler().errorLimit = args::getInteger(args, OPT_error_limit, 20); errorHandler().fatalWarnings = Index: lld/docs/ReleaseNotes.rst =================================================================== --- lld/docs/ReleaseNotes.rst +++ lld/docs/ReleaseNotes.rst @@ -29,6 +29,7 @@ * ``-z pack-relative-relocs`` is now available to support ``DT_RELR`` for glibc 2.36+. (`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. Breaking changes ---------------- Index: lld/test/ELF/crash-report.test =================================================================== --- /dev/null +++ lld/test/ELF/crash-report.test @@ -0,0 +1,9 @@ +## Test the diagnostics produced when LLD crashes. + +## Unset LLD_IN_TEST as its engages a crash recovery context. +# RUN: env -u LLD_IN_TEST 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 https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. +# CHECK: Stack dump: