mkdir gdb
(
cd gdb
#--------------
echo "Configuring gdb (for details see build/gdb-configure.log)"
../../source/${GDB}/configure \
--build=x86_64-pc-cygwin \
--host=x86_64-pc-cygwin \
--target=${TARGET} \
--prefix=${DSTDIR} \
--disable-nls \
--with-gmp=/usr/local \
--with-mpfr=/usr/local \
--with-expat \
> ../gdb-configure.log 2>&1
#--------------
echo "Building gdb (for details see build/gdb-make.log)"
make > ../gdb-make.log 2>&1
#--------------
echo "Installing gdb (for details see build/gdb-install.log)"
make install > ../gdb-install.log 2>&1
#--------------
echo "done"
)
I cannot build AVR (and also ARM) GDB 9.1 under CygWin64 (using the above piece of code, part of my full GNU toolchain builder) because of this error:
CXXLD gdb.exe
cp-support.o: in function `gdb_demangle(char const*, int)':
/home/mario/Gcc101_maker/build/gdb/gdb/../../../source/gdb-9.1/gdb/cp-support.c:1552:(.text+0x1d14): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `TLS init function for thread_local_segv_handler'
/home/mario/Gcc101_maker/build/gdb/gdb/../../../source/gdb-9.1/gdb/cp-support.c:1552:(.text+0x1d2d): 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
make[2]: *** [Makefile:1908: gdb.exe] Error 1
make[2]: Leaving directory '/home/mario/Gcc101_maker/build/gdb/gdb'
make[1]: *** [Makefile:9567: all-gdb] Error 2
make[1]: Leaving directory '/home/mario/Gcc101_maker/build/gdb'
make: *** [Makefile:855: all] Error 2
In the same environment I can compile GDB 8.1.3 (and any previous version). What can I do to build GDB 9.1? Thanks.
This fixed up gdb build for me, maybe it will help you as well:
Thanks to Yuri Phonin @ MIPT for the patch.
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index c1d62f17..30195f79 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1539,21 +1539,40 @@ report_failed_demangle (const char *name, bool core_dump_allowed,
#endif
-/* A wrapper for bfd_demangle. */
+#ifdef __CYGWIN__
+extern void set_segv_handler(void* hdl);
+#endif
+/* A wrapper for bfd_demangle. */
char *
gdb_demangle (const char *name, int options)
{
char *result = NULL;
int crash_signal = 0;
-
+
#ifdef HAVE_WORKING_FORK
+#ifdef __CYGWIN__
+ thread_local void (*thread_local_segv_handler_l) (int);
+ thread_local_segv_handler_l = NULL;
+
scoped_restore restore_segv
+ = make_scoped_restore (&thread_local_segv_handler_l,
+ catch_demangler_crashes
+ ? gdb_demangle_signal_handler
+ : nullptr);
+ set_segv_handler((void*)thread_local_segv_handler_l);
+
+#else
+
+ scoped_restore restore_segv
= make_scoped_restore (&thread_local_segv_handler,
catch_demangler_crashes
? gdb_demangle_signal_handler
: nullptr);
-
+#endif
+
bool core_dump_allowed = gdb_demangle_attempt_core_dump;
SIGJMP_BUF jmp_buf;
scoped_restore restore_jmp_buf
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 8ac6965f..982ab284 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -846,12 +846,20 @@ gdb_readline_no_editing_callback (gdb_client_data client_data)
result = buffer_finish (&line_buffer);
ui->input_handler (gdb::unique_xmalloc_ptr<char> (result));
}
-
/* See event-top.h. */
thread_local void (*thread_local_segv_handler) (int);
+#ifdef __CYGWIN__
+void set_segv_handler(void* hdl)
+{
+ thread_local_segv_handler = (void (*)(int))hdl;
+}
+#endif
+
static void handle_sigsegv (int sig);
/* Install the SIGSEGV handler. */
@@ -879,9 +887,12 @@ static void
handle_sigsegv (int sig)
{
install_handle_sigsegv ();
if (thread_local_segv_handler == nullptr)
+ {
abort ();
+ }
thread_local_segv_handler (sig);
}