[gdb/build] Fix gdbserver build with -fsanitize=address
authorTom de Vries <tdevries@suse.de>
Thu, 7 Jan 2021 09:37:51 +0000 (10:37 +0100)
committerTom de Vries <tdevries@suse.de>
Thu, 7 Jan 2021 09:37:51 +0000 (10:37 +0100)
commit78e49486944c515dfed6a437edff4c2c15dd1d4e
treedb3a1596978393a781df04f97d552bd9ab524305
parentaa881ecde48c7a0224b92e2cfa43b37ee9ec9fa2
[gdb/build] Fix gdbserver build with -fsanitize=address

When doing a gdbserver build with CFLAGS/CXXFLAGS/LDFLAGS=-fsanitize=address
we run into:
...
ld: ../libiberty/libiberty.a(safe-ctype.o):
relocation R_X86_64_32 against `.data' can not be used when making a
shared object; recompile with -fPIC
collect2: error: ld returned 1 exit status
make[1]: *** [libinproctrace.so] Error 1
...

This started with commit 96648494173 "gdbsupport: make use of safe-ctype
functions from libiberty", which introduced a dependency of libinproctrace.so
on libiberty.

Fix this in gdbserver/Makefile.in by using a setup similar to what is done in
gcc-repo/src/libcc1/Makefile.am, such that ../libiberty/noasan/libiberty.a is
used instead.

Build on x86_64-linux, both with and without -fsanitize=address.

gdbserver/ChangeLog:

2021-01-07  Tom de Vries  <tdevries@suse.de>

* Makefile.in (LIBIBERTY_NORMAL, LIBIBERTY_NOASAN, LIBIBERTY_PIC):
(LIBIBERTY_FOR_SHLIB): New var.
(LIBIBERTY): Set using $(LIBIBERTY_NORMAL).
(IPA_LIB): Use LIBIBERTY_FOR_SHLIB instead of LIBIBERTY in target rule.
gdbserver/ChangeLog
gdbserver/Makefile.in