This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Default to DWARF 4 on Linux/sparc64
AbandonedPublic

Authored by ro on Jul 26 2022, 6:51 AM.

Details

Summary

During a build on Debian 11/sparc64, several binaries fail to link with

/usr/bin/ld: /usr/bin/ld: DWARF error: invalid or unhandled FORM value: 0x23

/usr/bin/ld is GNU ld (GNU Binutils for Debian) 2.38.50.20220707. 0x23 is DW_FORM_rnglistx` which isn't handled even by GNU binutils master. Building with -gdwarf-4 avoids this.

Tested on sparc64-unknown-linux-gnu.

For comparison's sake, I've tried a build on Ubuntu 20.04/x86_64 with GNU ld 2.38.90, which isn't affected.

Diff Detail

Event Timeline

ro created this revision.Jul 26 2022, 6:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 26 2022, 6:51 AM
ro requested review of this revision.Jul 26 2022, 6:51 AM

Interesting and thanks for catching this! How did you discover this issue? Is there any particular program that fails to build due to this issue?

ro added a comment.Jul 26 2022, 7:04 AM

Interesting and thanks for catching this! How did you discover this issue? Is there any particular program that fails to build due to this issue?

Sure: many programs fail to link during ninja check-all for this problem.

glaubitz accepted this revision.Jul 26 2022, 7:06 AM
This revision is now accepted and ready to land.Jul 26 2022, 7:06 AM
MaskRay accepted this revision.Jul 26 2022, 9:38 AM

Consider creating a minimum reproduce and filing a bug on https://sourceware.org/bugzilla/buglist.cgi

During a build on Debian 11/sparc64, several binaries fail to link with

/usr/bin/ld: /usr/bin/ld: DWARF error: invalid or unhandled FORM value: 0x23

What's the linker doing parsing DWARF? Any idea what feature this is? And why is it SPARC-specific? Or is it true of other targets on the same Debian version?

ro added a comment.Jul 27 2022, 3:50 AM

During a build on Debian 11/sparc64, several binaries fail to link with

/usr/bin/ld: /usr/bin/ld: DWARF error: invalid or unhandled FORM value: 0x23

What's the linker doing parsing DWARF? Any idea what feature this is? And why is it SPARC-specific? Or is it true of other targets on the same Debian version?

I have no idea, actually. The code in question is bfd/dwarf2.c (read_attribute_value), who's comment states:

/* Read and fill in the value of attribute ATTR as described by FORM.
   Read data starting from INFO_PTR, but never at or beyond INFO_PTR_END.
   Returns an updated INFO_PTR taking into account the amount of data read.  */

So far, I had only seen it with the GNU ld 2.38.50 bundled with Debian 11/sparc64, but couldn't reproduce on Ubuntu 20.04/x86_64 (neither bundled GNU ld 2.34, nor self-compiled 2.38.90). Things got even weirder when I tried to create a minimal testcase for a binutils bug report: I'd initially seen the error when linking Sanitizer-sparc-Test. However, at that time the link also failed due to D130571. I got the unhandled FORM value error several times, probably for several different input objects. However, when adding -latomic to the link, the link did succeed without issues.

I've since ran a full build with all pending patches, just without this one, and didn't see the DWARF error again. This is all extremely weird, but until the error shows up again, I'll put this patch on hold (not yet abandoning since there seems to be no way to unabandon if necessary).

This is all extremely weird, but until the error shows up again, I'll put this patch on hold (not yet abandoning since there seems to be no way to unabandon if necessary).

You can abandon and then "reclaim" the revision to reopen it and continue work.

MaskRay added a comment.EditedJul 27 2022, 12:32 PM

I accepted this because this seems a major showstopper and we want to resolve it for the upcoming major release
But I just recall that clang 14.0.0 has defaulted to DWARF v5 for most ELF operating systems on all architectures, including Sparc.
I think we need more justification to downgrade the DWARV version.

So far, I had only seen it with the GNU ld 2.38.50 bundled with Debian 11/sparc64, but couldn't reproduce on Ubuntu 20.04/x86_64 (neither bundled GNU ld 2.34, nor self-compiled 2.38.90)

Thanks for the additional note. Seems worth investigating whether it is an issue which should be addressed on GNU ld side.
binutils 2.39 will be released on 2022-08-06 (https://sourceware.org/pipermail/binutils/2022-July/121656.html) and such a regression style issue should be worked on quickly.
The binutils code does suggest it doesn't handle the DWARF v5 features, but I am curious why older releases don't have the problem.

dblaikie requested changes to this revision.Jul 27 2022, 12:46 PM

I'll flag this as "request changes" so we're clear the issue isn't fully understood nor fully reproducible - so once there's some more data on the scope/impact/cause/timeline for linker fixes/etc we can access what sort of solution is suitable.

This revision now requires changes to proceed.Jul 27 2022, 12:46 PM
MaskRay requested changes to this revision.Jul 27 2022, 12:51 PM
ro added a comment.Jul 28 2022, 6:47 AM

This is all extremely weird, but until the error shows up again, I'll put this patch on hold (not yet abandoning since there seems to be no way to unabandon if necessary).

You can abandon and then "reclaim" the revision to reopen it and continue work.

Ah, I missed that: the reclaim action is only offered for abandoned patches, I assume. Thanks.

I accepted this because this seems a major showstopper and we want to resolve it for the upcoming major release
But I just recall that clang 14.0.0 has defaulted to DWARF v5 for most ELF operating systems on all architectures, including Sparc.
I think we need more justification to downgrade the DWARV version.

Fully agreed. However, clang 14.0.0 was in a way worse shape on Debian/sparc64 (wouldn't even build), so we wouldn't have noticed. Solaris/sparcv9 wouldn't notice either since it uses the native linker, not GNU ld.

So far, I had only seen it with the GNU ld 2.38.50 bundled with Debian 11/sparc64, but couldn't reproduce on Ubuntu 20.04/x86_64 (neither bundled GNU ld 2.34, nor self-compiled 2.38.90)

Thanks for the additional note. Seems worth investigating whether it is an issue which should be addressed on GNU ld side.
binutils 2.39 will be released on 2022-08-06 (https://sourceware.org/pipermail/binutils/2022-July/121656.html) and such a regression style issue should be worked on quickly.

Indeed. However, I won't be able to spend much time on this: Linux/sparc64 is only tangential to my work (as a vehicle to test SPARC patches where I want to make sure they don't break that target). I've got enough to do testing binutils 2.39 on Solaris ;-)

That said, I've now filed binutils PR binutils PR ld/29424. The binutils maintainers can now decide what the want to do about this, if anything.

The binutils code does suggest it doesn't handle the DWARF v5 features, but I am curious why older releases don't have the problem.

They might if one tried. However, the bundled GNU ld is already 2.38.50.

ro abandoned this revision.Jul 29 2022, 5:02 AM

Nick Clifton just commited a fix both to the binutils 2.39 branch and master. So the workaround certainly isn't necessary.