Emit an error if -Zdwarf-version=1 is requested

DWARF 1 is very different than DWARF 2+ (see the commentary in
https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#index-gdwarf)
and LLVM does not really seem to support DWARF 1 as Clang does not offer
a `-gdwarf-1` flag and `llc` will just generate DWARF 2 with the version
set to 1: https://godbolt.org/z/s85d87n3a.

Since this isn't actually supported (and it's not clear it would be
useful anyway), report that DWARF 1 is not supported if it is requested.

Also add a help message to the error saying which versions are supported.
This commit is contained in:
Wesley Wiser
2025-02-08 13:11:49 -06:00
parent 8ad2c9724d
commit eea8ce5be4
7 changed files with 61 additions and 2 deletions

View File

@@ -1251,7 +1251,8 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
}
if let Some(dwarf_version) = sess.opts.unstable_opts.dwarf_version {
if dwarf_version > 5 {
// DWARF 1 is not supported by LLVM and DWARF 6 is not yet finalized.
if dwarf_version < 2 || dwarf_version > 5 {
sess.dcx().emit_err(errors::UnsupportedDwarfVersion { dwarf_version });
}
}