From 62d357d3c0756ec0f220e9cf3a874e591548a65c Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Tue, 15 Mar 2016 11:51:56 -0700 Subject: Unbreak static cross-gdb. GDB's configure mishandles the libexpat.{so,a} libraries when it is given -static in CFLAGS AND --with-libexpat-prefix in configure's args: it checks for /lib/libexpat.so and finding that, attempts to link it as `gcc -static .. conftest.c /lib/libexpat.so`; this obviously fails (.so cannot be statically linked), so configure assumes libexpat is unusable. Thus, --with-libexpat-prefix is dangerous and should be avoided; instead, configure should find the libraries via the supplied CC/LD definitions. --- scripts/build/debug/300-gdb.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'scripts/build/debug') diff --git a/scripts/build/debug/300-gdb.sh b/scripts/build/debug/300-gdb.sh index 418e85c6..02a8f7e0 100644 --- a/scripts/build/debug/300-gdb.sh +++ b/scripts/build/debug/300-gdb.sh @@ -69,7 +69,11 @@ do_debug_gdb_build() { cross_extra_config=("${extra_config[@]}") cross_extra_config+=("--with-expat") - cross_extra_config+=("--with-libexpat-prefix=${CT_HOST_COMPLIBS_DIR}") + # NOTE: DO NOT USE --with-libexpat-prefix (until GDB configure is smarter)!!! + # It conflicts with a static build: GDB's configure script will find the shared + # version of expat and will attempt to link that, despite the -static flag. + # The link will fail, and configure will abort with "expat missing or unusable" + # message. case "${CT_THREADS}" in none) cross_extra_config+=("--disable-threads");; *) cross_extra_config+=("--enable-threads");; @@ -88,11 +92,11 @@ do_debug_gdb_build() { cross_extra_config+=("--disable-nls") fi - CC_for_gdb= - LD_for_gdb= + CC_for_gdb="${CT_HOST}-gcc ${CT_CFLAGS_FOR_HOST} ${CT_LDFLAGS_FOR_HOST}" + LD_for_gdb="${CT_HOST}-ld ${CT_LDFLAGS_FOR_HOST}" if [ "${CT_GDB_CROSS_STATIC}" = "y" ]; then - CC_for_gdb="${CT_HOST}-gcc -static" - LD_for_gdb="${CT_HOST}-ld -static" + CC_for_gdb+=" -static" + LD_for_gdb+=" -static" fi # Disable binutils options when building from the binutils-gdb repo. @@ -162,6 +166,11 @@ do_debug_gdb_build() { fi native_extra_config+=("--with-expat") + # NOTE: DO NOT USE --with-libexpat-prefix (until GDB configure is smarter)!!! + # It conflicts with a static build: GDB's configure script will find the shared + # version of expat and will attempt to link that, despite the -static flag. + # The link will fail, and configure will abort with "expat missing or unusable" + # message. CT_DoLog EXTRA "Configuring native gdb" -- cgit v1.2.3 From 2162cbbdb7a425505e66f8b65f134c33302324f4 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Wed, 16 Mar 2016 11:41:55 -0700 Subject: Work-around another quirk in GDB configure. Previous fix for cross-gdb broke powerpc-unknown_nofpu-linux-gnu which uses an old GDB (6.8a). That GDB's configure chokes on $CC values with multiple consecutive spaces; see the comment in 300-gdb.sh. Signed-off-by: Alexey Neyman --- scripts/build/debug/300-gdb.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'scripts/build/debug') diff --git a/scripts/build/debug/300-gdb.sh b/scripts/build/debug/300-gdb.sh index 02a8f7e0..ee4753ef 100644 --- a/scripts/build/debug/300-gdb.sh +++ b/scripts/build/debug/300-gdb.sh @@ -99,10 +99,17 @@ do_debug_gdb_build() { LD_for_gdb+=" -static" fi - # Disable binutils options when building from the binutils-gdb repo. - cross_extra_config+=("--disable-binutils") - cross_extra_config+=("--disable-ld") - cross_extra_config+=("--disable-gas") + # Fix up whitespace. Some older GDB releases (e.g. 6.8a) get confused if there + # are multiple consecutive spaces: sub-configure scripts replace them with a + # single space and then complain that $CC value changed from that in + # the master directory. + CC_for_gdb=`echo $CC_for_gdb` + LD_for_gdb=`echo $LD_for_gdb` + + # Disable binutils options when building from the binutils-gdb repo. + cross_extra_config+=("--disable-binutils") + cross_extra_config+=("--disable-ld") + cross_extra_config+=("--disable-gas") CT_DoLog DEBUG "Extra config passed: '${cross_extra_config[*]}'" -- cgit v1.2.3