about summary refs log tree commit diff
path: root/compiler/rustc_session/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-02-09 19:44:53 +0100
committerGitHub <noreply@github.com>2025-02-09 19:44:53 +0100
commit4b319bcadaba37a0a3fc08cb88c87eeb6eac6f57 (patch)
treec3af864a654296b3069f55d54460224b22077926 /compiler/rustc_session/src
parentd64bd3beddfcbed43b208189a0a00ec6c1037b44 (diff)
parenteea8ce5be4ca75e67d3b88d55f718e315c3d9d8b (diff)
downloadrust-4b319bcadaba37a0a3fc08cb88c87eeb6eac6f57.tar.gz
rust-4b319bcadaba37a0a3fc08cb88c87eeb6eac6f57.zip
Rollup merge of #136746 - wesleywiser:err_dwarf1, r=Urgau
Emit an error if `-Zdwarf-version=1` is requested

DWARF 1 is very different than DWARF 2+[^1] and LLVM does not really seem to support DWARF 1 as Clang does not offer a `-gdwarf-1` flag[^2] and `llc` will just generate DWARF 2 with the version set to 1[^3].

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.

cc #103057

[^1]: https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#index-gdwarf
[^2]: https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gdwarf
[^3]: https://godbolt.org/z/s85d87n3a
Diffstat (limited to 'compiler/rustc_session/src')
-rw-r--r--compiler/rustc_session/src/errors.rs1
-rw-r--r--compiler/rustc_session/src/session.rs3
2 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs
index 6c26a781487..75c3b2c7a85 100644
--- a/compiler/rustc_session/src/errors.rs
+++ b/compiler/rustc_session/src/errors.rs
@@ -161,6 +161,7 @@ pub(crate) struct UnstableVirtualFunctionElimination;
 
 #[derive(Diagnostic)]
 #[diag(session_unsupported_dwarf_version)]
+#[help(session_unsupported_dwarf_version_help)]
 pub(crate) struct UnsupportedDwarfVersion {
     pub(crate) dwarf_version: u32,
 }
diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs
index 0851e859a0f..f795ad1ee17 100644
--- a/compiler/rustc_session/src/session.rs
+++ b/compiler/rustc_session/src/session.rs
@@ -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 });
         }
     }