[PATCH] D94882: [MC] Upgrade DWARF version to 5 upon .file 0

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 27 10:49:26 PST 2021


MaskRay added a comment.

In D94882#2524708 <https://reviews.llvm.org/D94882#2524708>, @jhenderson wrote:

> I'm a little lost as to what you're referring to requiring a new command line option. If I understand it correctly, the issue is when an assembly file was produced with a specific version which doesn't match what is used when it gets assembled.
>
> Let me try and reframe so to help clear things up. We have the following cases:
>
> 1. No option is passed to the assembler - in this case, the assembler should be able to infer the DWARF version from the presence (or lack thereof) of `.file 0`, no diagnostic needed.

Yes, GNU as behavior.

> 2. The DWARF version is passed to the assembler via an option. In this case, in my opinion should warn if it encounters `.file 0` but the requested version doesn't support `.file 0`. Potentially, the inverse should also warn too (i.e. `.file 0` is not present, but other `.file` directives are, and version 5 is requested), but I am not familiar enough with the related assembly to know whether that is supported or not.

I agree that a warning would be nice.

> Does clang need to pass `dwarf-version` to cc1as at all when the version is not explicitly specified/debug data is not specifically requested? If it could avoid specifying that option, we'd be able to hit case 1) for most cases, I think, whilst still getting the warning for case 2 when there's a mismatch.

The default DWARF version is decided by clang driver. Different toolchains have different defaults. The version option does not require `-g`.

  clang -target x86_64-linux -c a.s '-###' # "-dwarf-version=4"
  clang -target x86_64-freebsd12 -c a.s '-###' # "-dwarf-version=2"

If we want a diagnostic, we will need additional information whether `-dwarf-version` is implicitly or explicitly specified. GNU as currently does not have a diagnostic.
I have put reason why I think the diagnostic is not very useful in my initial summary.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94882/new/

https://reviews.llvm.org/D94882



More information about the llvm-commits mailing list