Bug 31110 - [2.42 Regression] d21 (D frontend from GCC 13) fails to link with binutils trunk on riscv64-linux-gnu
Summary: [2.42 Regression] d21 (D frontend from GCC 13) fails to link with binutils tr...
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.42
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-03 08:32 UTC by Matthias Klose
Modified: 2023-12-07 09:51 UTC (History)
2 users (show)

See Also:
Host:
Target: riscv64-linux-gnu
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Klose 2023-12-03 08:32:05 UTC
d21 (D frontend from GCC 13) fails to link with binutils trunk on riscv64-linux-gnu, while this works with binutils from the 2.41 branch:

[...]

Linking d21 |====>>--    | 33%
riscv64-linux-gnu-gdc-12 -no-pie -lstdc++   -g -fno-stack-protector -DIN_GCC     -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings   -DHAVE_CONFIG_H -static-libstdc++ -static-libgcc  -static-libphobos -o d21 \
	d/access.o d/aggregate.o d/aliasthis.o d/apply.o d/arrayop.o d/arraytypes.o d/attrib.o d/ast_node.o d/astcodegen.o d/astenums.o d/blockexit.o d/builtin.o d/canthrow.o d/chkformat.o d/clone.o d/common-bitfields.o d/common-file.o d/common-outbuffer.o d/common-string.o d/compiler.o d/cond.o d/constfold.o d/cparse.o d/cppmangle.o d/ctfeexpr.o d/ctorflow.o d/dcast.o d/dclass.o d/declaration.o d/delegatize.o d/denum.o d/dimport.o d/dinterpret.o d/dmacro.o d/dmangle.o d/dmodule.o d/doc.o d/dscope.o d/dstruct.o d/dsymbol.o d/dsymbolsem.o d/dtemplate.o d/dtoh.o d/dversion.o d/entity.o d/errors.o d/errorsink.o d/escape.o d/expression.o d/expressionsem.o d/file_manager.o d/foreachvar.o d/func.o d/globals.o d/gluelayer.o d/hdrgen.o d/iasm.o d/iasmgcc.o d/id.o d/identifier.o d/impcnvtab.o d/imphint.o d/importc.o d/init.o d/initsem.o d/inline.o d/intrange.o d/json.o d/lambdacomp.o d/lexer.o d/location.o d/mtype.o d/mustuse.o d/nogc.o d/nspace.o d/ob.o d/objc.o d/opover.o d/optimize.o d/parse.o d/parsetimevisitor.o d/permissivevisitor.o d/printast.o d/root-aav.o d/root-array.o d/root-bitarray.o d/root-complex.o d/root-ctfloat.o d/root-file.o d/root-filename.o d/root-hash.o d/root-longdouble.o d/root-optional.o d/root-port.o d/root-region.o d/root-rmem.o d/root-rootobject.o d/root-speller.o d/root-string.o d/root-stringtable.o d/root-utf.o d/safe.o d/sapply.o d/semantic2.o d/semantic3.o d/sideeffect.o d/statement.o d/statement_rewrite_walker.o d/statementsem.o d/staticassert.o d/staticcond.o d/stmtstate.o d/target.o d/templateparamsem.o d/tokens.o d/traits.o d/transitivevisitor.o d/typesem.o d/typinf.o d/utils.o d/visitor.o d/d-attribs.o d/d-builtins.o d/d-codegen.o d/d-compiler.o d/d-convert.o d/d-ctfloat.o d/d-diagnostic.o d/d-frontend.o d/d-gimplify.o d/d-incpath.o d/d-lang.o d/d-longdouble.o d/d-port.o d/d-target.o d/decl.o d/expr.o d/imports.o d/intrinsics.o d/modules.o d/runtime.o d/toir.o d/typeinfo.o d/types.o riscv-d.o linux-d.o attribs.o libbackend.a main.o libcommon-target.a libcommon.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a libcommon.a ../libcpp/libcpp.a   ../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a  -lisl -lmpc -lmpfr -lgmp -rdynamic  -lz -lzstd 
/usr/bin/ld: final size of uleb128 value at offset 0x1491 in .debug_loclists from /usr/lib/gcc/riscv64-linux-gnu/12/libgphobos.a(aaA.o) exceeds available space
/usr/lib/gcc/riscv64-linux-gnu/12/libgphobos.a(aaA.o): in function `.LLST1':
aaA.d:(.debug_loclists+0x1491): dangerous relocation: dangerous relocation error
/usr/bin/ld: final size of uleb128 value at offset 0xe92 in .debug_loclists from /usr/lib/gcc/riscv64-linux-gnu/12/libgphobos.a(deh.o) exceeds available space
/usr/lib/gcc/riscv64-linux-gnu/12/libgphobos.a(deh.o): in function `.LLST1':
deh.d:(.debug_loclists+0xe92): dangerous relocation: dangerous relocation error
collect2: error: ld returned 1 exit status
make[5]: *** [../../src/gcc/d/Make-lang.in:236: d21] Error 1

GCC 12.3 is used as a bootstrap compiler.

Complete build log at
https://launchpad.net/ubuntu/+source/gcc-13/13.2.0-8ubuntu1/+build/27039537
Comment 1 Matthias Klose 2023-12-03 08:35:38 UTC
that error message was introduced:

2021-06-22  Nelson Chu  <nelson.chu@sifive.com>

        * elfnn-riscv.c (riscv_pcrel_hi_reloc): Added field to store
        the original relocation type, in case the type is converted to
        R_RISCV_HI20.
        (riscv_pcrel_lo_reloc): Removed unused name field.
        (riscv_pcrel_relocs): Added comments.
        (riscv_zero_pcrel_hi_reloc): Removed unused input_bfd.
        (riscv_record_pcrel_hi_reloc): Updated.
        (riscv_record_pcrel_lo_reloc): Likewise.
        (riscv_resolve_pcrel_lo_relocs): Likewise.  Check the original
        type of auipc, to make sure the %pcrel_lo without any addends.
        Otherwise, report dangerous relocation error.
        (riscv_elf_relocate_section): Updated above functions are changed.
        For R_RISCV_GOT_HI20, report dangerous relocation error when addend
        isn't zero.
Comment 2 Andreas Schwab 2023-12-03 14:11:33 UTC
That very much looks like the bootstrap compiler was built with a defective assembler.  Try rebuilding it with current binutils.
Comment 3 Matthias Klose 2023-12-07 09:51:07 UTC
rebuilding did "fix" it.  However you have to rebuild gdc-11 first (the last gdc not requiring gdc to build) to build newer gdc versions.  Is it worth fixing this on older binutils branches?