[gdb/build] Fix build breaker with --enable-shared

When building gdb with --enable-shared, I run into:
...
ld: build/zlib/libz.a(libz_a-inffast.o): relocation R_X86_64_32S against \
  `.rodata' can not be used when making a shared object; recompile with -fPIC
ld: build/zlib/libz.a(libz_a-inflate.o): warning: relocation against \
  `inflateResetKeep' in read-only section `.text'
collect2: error: ld returned 1 exit status
make[3]: *** [libbfd.la] Error 1
...

This is a regression since commit a08bdb159bb ("[gdb/build] Fix gdbserver
build with -fsanitize=thread").

The problem is that a single case statement in configure is shared to handle
special requirements for both the host libiberty and host zlib, which has the
effect that only one is handled.

Fix this by handling libiberty and zlib each in its own case statement.

Build on x86_64-linux, with and without --enable-shared.

ChangeLog:

2022-06-27  Tom de Vries  <tdevries@suse.de>

	* configure.ac: Set extra_host_libiberty_configure_flags and
	extra_host_zlib_configure_flags in separate case statements.
	* configure: Regenerate.
This commit is contained in:
Tom de Vries 2022-06-27 15:36:19 +02:00
parent 171fba11ab
commit 95127faf50
2 changed files with 12 additions and 4 deletions

8
configure vendored
View File

@ -6962,13 +6962,18 @@ fi
# Sometimes we have special requirements for the host libiberty. # Sometimes we have special requirements for the host libiberty.
extra_host_libiberty_configure_flags= extra_host_libiberty_configure_flags=
extra_host_zlib_configure_flags=
case " $configdirs " in case " $configdirs " in
*" lto-plugin "* | *" libcc1 "* | *" gdbserver "*) *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
# When these are to be built as shared libraries, the same applies to # When these are to be built as shared libraries, the same applies to
# libiberty. # libiberty.
extra_host_libiberty_configure_flags=--enable-shared extra_host_libiberty_configure_flags=--enable-shared
;; ;;
esac
# Sometimes we have special requirements for the host zlib.
extra_host_zlib_configure_flags=
case " $configdirs " in
*" bfd "*) *" bfd "*)
# When bfd is to be built as a shared library, the same applies to # When bfd is to be built as a shared library, the same applies to
# zlib. # zlib.
@ -6979,7 +6984,6 @@ case " $configdirs " in
esac esac
# Produce a warning message for the subdirs we can't configure. # Produce a warning message for the subdirs we can't configure.
# This isn't especially interesting in the Cygnus tree, but in the individual # This isn't especially interesting in the Cygnus tree, but in the individual
# FSF releases, it's important to let people know when their machine isn't # FSF releases, it's important to let people know when their machine isn't

View File

@ -2342,13 +2342,18 @@ fi
# Sometimes we have special requirements for the host libiberty. # Sometimes we have special requirements for the host libiberty.
extra_host_libiberty_configure_flags= extra_host_libiberty_configure_flags=
extra_host_zlib_configure_flags=
case " $configdirs " in case " $configdirs " in
*" lto-plugin "* | *" libcc1 "* | *" gdbserver "*) *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
# When these are to be built as shared libraries, the same applies to # When these are to be built as shared libraries, the same applies to
# libiberty. # libiberty.
extra_host_libiberty_configure_flags=--enable-shared extra_host_libiberty_configure_flags=--enable-shared
;; ;;
esac
AC_SUBST(extra_host_libiberty_configure_flags)
# Sometimes we have special requirements for the host zlib.
extra_host_zlib_configure_flags=
case " $configdirs " in
*" bfd "*) *" bfd "*)
# When bfd is to be built as a shared library, the same applies to # When bfd is to be built as a shared library, the same applies to
# zlib. # zlib.
@ -2357,7 +2362,6 @@ case " $configdirs " in
fi fi
;; ;;
esac esac
AC_SUBST(extra_host_libiberty_configure_flags)
AC_SUBST(extra_host_zlib_configure_flags) AC_SUBST(extra_host_zlib_configure_flags)
# Produce a warning message for the subdirs we can't configure. # Produce a warning message for the subdirs we can't configure.