#4523 closed defect (fixed)

gdb 9.1 no longer builds on Cygwin (thread local error)

Reported by: Joel Sherrill Owned by: Joel Sherrill <joel@…>
Priority: normal Milestone: 5.2
Component: admin Version: 5
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

The Cygwin link error is:

cp-support.o: in function `gdb_demangle(char const*, int)':
/home/Christian/binutils-gdb/obj/gdb/../../gdb/cp-support.c:1619:(.text+0x6472): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `TLS init function for thread_local_segv_handler'
/home/Christian/binutils-gdb/obj/gdb/../../gdb/cp-support.c:1619:(.text+0x648b): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `TLS init function for thread_local_segv_handler'
collect2: error: ld returned 1 exit status

The issue appears to be that Cygwin changed their base address for executables and there are multiple approaches to fixing this on the Internet. None of these applied cleanly to a vanilla gdb 9.1. I adapted the patch presented at https://stackoverflow.com/questions/61984974/failed-to-build-avr-and-arm-gdb-9-1-under-cygwin-relocation-truncated-to-fit

This patch avoids using a thread-local extern variable, which causes link errors on some platforms, notably Cygwin. The poster through this was a better pattern even outside of working around linker bugs because it encapsulates direct access to the variable inside the class, instead of having a global extern variable.

It should be noted that gdb 10.1 builds cleanly on Cygwin but discussions leaned against bumping the gdb on the 5 branch. Hence we end up with a Cygwin specific patch for gdb 9.1 on Cygwin.

Attachments (1)

gdb-9-1-thread-local.diff (1.5 KB) - added by Joel Sherrill on 10/06/21 at 15:53:24.
Patch to work around thread local linking error on Cygwin

Download all attachments as: .zip

Change History (2)

Changed on 10/06/21 at 15:53:24 by Joel Sherrill

Attachment: gdb-9-1-thread-local.diff added

Patch to work around thread local linking error on Cygwin

comment:1 Changed on 10/13/21 at 16:36:57 by Joel Sherrill <joel@…>

Owner: set to Joel Sherrill <joel@…>
Resolution: fixed
Status: newclosed

In 9be3668/rtems-source-builder:

rtems-gdb-9.1-1.cfg: Add patch for Cygwin

The patch is needed to address link failures introduced when
Cygwin apparently changed their base address for executables.
This is not an issue with gdb 10 and this is a minimalistic
approach to addressing this failure on the 5 branch.

Closes #4523.

Note: See TracTickets for help on using tickets.