From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1551) id 47FE93857B9B; Wed, 28 Sep 2022 19:26:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 47FE93857B9B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664393213; bh=OFbPEMxwUnIuIF5aFMhI+NkE6pKv2wdnb1Hc08cwrHI=; h=From:To:Subject:Date:From; b=tB3xorHkDFmh8RCVPW2ogt6TSPAEFYZrZwNXdfE9OgU3oFn4W/bRiXgqHAsTCZI3E DooiNAkeJDAjIV0lIBz2cNW4QsL+632AuoYL6d7bwVGJRc5OZ3L/AB3mkGy2OGt6ny d+uAVOIbcmqNn2xq97ESH6+FLpjh0uK8/U7zqy1M= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Pedro Alves To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Fix GDB build: ELF support check & -lzstd X-Act-Checkin: binutils-gdb X-Git-Author: Pedro Alves X-Git-Refname: refs/heads/master X-Git-Oldrev: e875475e19d13aa4283571f399848eab64f96ae0 X-Git-Newrev: 16bd13978f3e02e869cea603579b9f60401ed61c Message-Id: <20220928192653.47FE93857B9B@sourceware.org> Date: Wed, 28 Sep 2022 19:26:53 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D16bd13978f3e= 02e869cea603579b9f60401ed61c commit 16bd13978f3e02e869cea603579b9f60401ed61c Author: Pedro Alves Date: Wed Sep 28 11:33:30 2022 +0100 Fix GDB build: ELF support check & -lzstd =20 GDB fails to build for me, on Ubuntu 20.04. I get: =20 ... CXXLD gdb /usr/bin/ld: linux-tdep.o: in function `linux_corefile_thread(thread_i= nfo*, linux_corefile_thread_data*)': /home/pedro/gdb/binutils-gdb/src/gdb/linux-tdep.c:1831: undefined refe= rence to `gcore_elf_build_thread_register_notes(gdbarch*, thread_info*, gdb= _signal, bfd*, std::unique_ptr >*, int*)' /usr/bin/ld: linux-tdep.o: in function `linux_make_corefile_notes(gdba= rch*, bfd*, int*)': /home/pedro/gdb/binutils-gdb/src/gdb/linux-tdep.c:2117: undefined refe= rence to `gcore_elf_make_tdesc_note(bfd*, std::unique_ptr >*, int*)' collect2: error: ld returned 1 exit status make[2]: *** [Makefile:2149: gdb] Error 1 make[2]: Leaving directory '/home/pedro/gdb/binutils-gdb/build/gdb' make[1]: *** [Makefile:11847: all-gdb] Error 2 make[1]: Leaving directory '/home/pedro/gdb/binutils-gdb/build' make: *** [Makefile:1004: all] Error 2 =20 Those undefined functions exist in gdb/gcore-elf.c, which is only included in the build if GDB's configure thinks that the target you're configuring for is an ELF target. GDB's configure thinks my system isn't ELF, which is incorrect. =20 For the ELF support check, gdb/config.log shows: =20 configure:17387: checking for ELF support in BFD configure:17407: gcc -o conftest -I/home/pedro/gdb/binutils-gdb/src/gd= b/../include -I../bfd -I/home/pedro/gdb/binutils-gdb/src/gdb/../bfd -g3 -O0= -L../bfd -L../libiberty -lzstd conftest.c -lbfd -liberty -lz -lnc= ursesw -lm -ldl >&5 /usr/bin/ld: ../bfd/libbfd.a(compress.o): in function `decompress_cont= ents': /home/pedro/gdb/binutils-gdb/src/bfd/compress.c:42: undefined referenc= e to `ZSTD_decompress' /usr/bin/ld: /home/pedro/gdb/binutils-gdb/src/bfd/compress.c:44: undef= ined reference to `ZSTD_isError' /usr/bin/ld: ../bfd/libbfd.a(compress.o): in function `bfd_compress_se= ction_contents': /home/pedro/gdb/binutils-gdb/src/bfd/compress.c:195: undefined referen= ce to `ZSTD_compress' /usr/bin/ld: /home/pedro/gdb/binutils-gdb/src/bfd/compress.c:198: unde= fined reference to `ZSTD_isError' collect2: error: ld returned 1 exit status configure:17407: $? =3D 1 ... configure:17417: result: no =20 Note how above, in the gcc command line, "-lzstd" appears before "-lbfd". That explain the link failure. It should appear after, like -lz does. =20 This commit fixes it, by moving ZSTD_LIBS from LDFLAGS to LIBS, next to -lz, in GDB_AC_CHECK_BFD, and regenerating gdb/configure. =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29630 Change-Id: I1f4128dde634e8ea04c9002904f1005a8b3a6863 Diff: --- gdb/acinclude.m4 | 4 ++-- gdb/configure | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4 index 28846119dcb..62fa66c7af3 100644 --- a/gdb/acinclude.m4 +++ b/gdb/acinclude.m4 @@ -234,9 +234,9 @@ AC_DEFUN([GDB_AC_CHECK_BFD], [ # always want our bfd. CFLAGS=3D"-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS" ZLIBDIR=3D`echo $zlibdir | sed 's,\$(top_builddir)/,,g'` - LDFLAGS=3D"-L../bfd -L../libiberty $ZLIBDIR $ZSTD_LIBS $LDFLAGS" + LDFLAGS=3D"-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS" intl=3D`echo $LIBINTL | sed 's,${top_builddir}/,,g'` - LIBS=3D"-lbfd -liberty -lz $intl $LIBS" + LIBS=3D"-lbfd -liberty -lz $ZSTD_LIBS $intl $LIBS" AC_CACHE_CHECK( [$1], [$2], diff --git a/gdb/configure b/gdb/configure index 238b66f3c60..33677262783 100755 --- a/gdb/configure +++ b/gdb/configure @@ -17412,9 +17412,9 @@ WIN32LIBS=3D"$WIN32LIBS $WIN32APILIBS" # always want our bfd. CFLAGS=3D"-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS" ZLIBDIR=3D`echo $zlibdir | sed 's,\$(top_builddir)/,,g'` - LDFLAGS=3D"-L../bfd -L../libiberty $ZLIBDIR $ZSTD_LIBS $LDFLAGS" + LDFLAGS=3D"-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS" intl=3D`echo $LIBINTL | sed 's,${top_builddir}/,,g'` - LIBS=3D"-lbfd -liberty -lz $intl $LIBS" + LIBS=3D"-lbfd -liberty -lz $ZSTD_LIBS $intl $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ELF support in BFD= " >&5 $as_echo_n "checking for ELF support in BFD... " >&6; } if ${gdb_cv_var_elf+:} false; then : @@ -17527,9 +17527,9 @@ fi # always want our bfd. CFLAGS=3D"-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS" ZLIBDIR=3D`echo $zlibdir | sed 's,\$(top_builddir)/,,g'` - LDFLAGS=3D"-L../bfd -L../libiberty $ZLIBDIR $ZSTD_LIBS $LDFLAGS" + LDFLAGS=3D"-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS" intl=3D`echo $LIBINTL | sed 's,${top_builddir}/,,g'` - LIBS=3D"-lbfd -liberty -lz $intl $LIBS" + LIBS=3D"-lbfd -liberty -lz $ZSTD_LIBS $intl $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mach-O support in = BFD" >&5 $as_echo_n "checking for Mach-O support in BFD... " >&6; } if ${gdb_cv_var_macho+:} false; then :