[PR,gdb/17984] Fix GDB build fail on Aarch64 when -fno-common is enabled.
Commit Message
Hi,
current trunk GDB (and gdb-7.8.1 too) fails to build on Aarch64 when
-fno-common is enabled with:
progspace.o skip.o probe.o common-utils.o buffer.o ptid.o gdb-dlfcn.o
common-agent.o format.o registry.o btrace.o record-btrace.o waitstatus.o
print-utils.o rsp-low.o errors.o common-debug.o debug.o
common-exceptions.o btrace-common.o compile.o compile-c-symbols.o
compile-c-types.o compile-object-load.o compile-object-run.o
compile-loc2c.o compile-c-support.o inflow.o init.o \
[ 190s] >------ ../readline/libreadline.a ../opcodes/libopcodes.a
../bfd/libbfd.a ../libiberty/libiberty.a
../libdecnumber/libdecnumber.a -ldl -ldl -lncurses -lm -ldl -lpthread
-ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic
/usr/lib64/libexpat.so ../libiberty/libiberty.a
build-gnulib/import/libgnu.a -ldl -Wl,--dynamic-list=./proc-service.list
[ 199s] aarch64-linux-nat.o: In function `initialize_tdesc_aarch64':
[ 199s]
/home/abuild/rpmbuild/BUILD/gdb-7.8.1/gdb/features/aarch64.c:11:
multiple definition of `tdesc_aarch64'
[ 199s]
aarch64-tdep.o:/home/abuild/rpmbuild/BUILD/gdb-7.8.1/gdb/objfiles.h:540:
first defined here
[ 199s] aarch64-linux-nat.o: In function `initialize_tdesc_aarch64':
[ 199s]
/home/abuild/rpmbuild/BUILD/gdb-7.8.1/gdb/features/aarch64.c:11:
multiple definition of `tdesc_aarch64'
[ 199s]
aarch64-tdep.o:/home/abuild/rpmbuild/BUILD/gdb-7.8.1/gdb/objfiles.h:540:
first defined here
[ 199s] collect2: error: ld returned 1 exit status
[ 199s] make[2]: *** [gdb] Error 1
[ 199s] make[2]: Leaving directory
`/home/abuild/rpmbuild/BUILD/gdb-7.8.1/gdb'
[ 199s] make[1]: *** [all-gdb] Error 2
[ 199s] make[1]: Leaving directory `/home/abuild/rpmbuild/BUILD/gdb-7.8.1'
[ 199s] make: *** [all] Error 2
This happens because struct target_desc *tdesc_aarch64 is defined in
gdb/features/aarch64.c source file, that is included to some other files
(gdb/aarch64-linux-nat.c, for example). So, we have multiple definition
of `tdesc_aarch64' error during link stage.
This small patch resolves the issue, OK to commit?
-Maxim
Comments
On 02/16/2015 04:24 PM, Maxim Ostapenko wrote:
> current trunk GDB (and gdb-7.8.1 too) fails to build on Aarch64 when
> -fno-common is enabled with:
> This small patch resolves the issue, OK to commit?
Thanks.
> gdb/Changelog
>
> 2015-02-16 Max Ostapenko <m.ostapenko@partner.samsung.com>
>
> PR gdb/17984
> * gdb/aarch64-linux-nat.c: Don't include features/aarch64.c anymore.
> (aarch64_linux_read_description): Remove initialize_tdesc_aarch64 call.
> * gdb/aarch64-tdep.h: Add struct target_desc *tdesc_aarch64
> declaration.
As this entry will be added to the gdb/ChangeLog file, the
"gdb/" path should be removed from the file names above.
Otherwise this is OK. Thanks for doing this.
gdb/Changelog
2015-02-16 Max Ostapenko <m.ostapenko@partner.samsung.com>
PR gdb/17984
* gdb/aarch64-linux-nat.c: Don't include features/aarch64.c anymore.
(aarch64_linux_read_description): Remove initialize_tdesc_aarch64 call.
* gdb/aarch64-tdep.h: Add struct target_desc *tdesc_aarch64
declaration.
@@ -37,8 +37,6 @@
#include "gregset.h"
-#include "features/aarch64.c"
-
/* Defines ps_err_e, struct ps_prochandle. */
#include "gdb_proc_service.h"
@@ -830,7 +828,6 @@ aarch64_linux_child_post_startup_inferior (struct target_ops *self,
static const struct target_desc *
aarch64_linux_read_description (struct target_ops *ops)
{
- initialize_tdesc_aarch64 ();
return tdesc_aarch64;
}
@@ -90,4 +90,6 @@ struct gdbarch_tdep
struct type *vnb_type;
};
+extern struct target_desc *tdesc_aarch64;
+
#endif /* aarch64-tdep.h */