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

Message ID 20220627130323.GA7270@delia.com
State New
Headers
Series [gdb/build] Fix build breaker with --enabled-shared |

Commit Message

Tom de Vries June 27, 2022, 1:03 p.m. UTC
  Hi,

When building gdb with --enabled-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.

OK for gcc trunk?

Thanks,
- Tom

[gdb/build] Fix build breaker with --enabled-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.

---
 configure    | 8 ++++++--
 configure.ac | 8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)
  

Comments

Tom de Vries June 27, 2022, 1:38 p.m. UTC | #1
On 6/27/22 15:03, Tom de Vries wrote:
> Hi,
> 
> When building gdb with --enabled-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.
> 
> OK for gcc trunk?
> 

To fix the buildbot breakage, I already pushed to the gdb repo.

Thanks,
- Tom

> 
> [gdb/build] Fix build breaker with --enabled-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.
> 
> ---
>   configure    | 8 ++++++--
>   configure.ac | 8 ++++++--
>   2 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/configure b/configure
> index aac80b88d70..be433ef6d5d 100755
> --- a/configure
> +++ b/configure
> @@ -6962,13 +6962,18 @@ fi
>   
>   # Sometimes we have special requirements for the host libiberty.
>   extra_host_libiberty_configure_flags=
> -extra_host_zlib_configure_flags=
>   case " $configdirs " in
>     *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
>       # When these are to be built as shared libraries, the same applies to
>       # libiberty.
>       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 "*)
>       # When bfd is to be built as a shared library, the same applies to
>       # zlib.
> @@ -6979,7 +6984,6 @@ case " $configdirs " in
>   esac
>   
>   
> -
>   # Produce a warning message for the subdirs we can't configure.
>   # 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
> diff --git a/configure.ac b/configure.ac
> index 29f74d10b5a..1651cbf3b02 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -2342,13 +2342,18 @@ fi
>   
>   # Sometimes we have special requirements for the host libiberty.
>   extra_host_libiberty_configure_flags=
> -extra_host_zlib_configure_flags=
>   case " $configdirs " in
>     *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
>       # When these are to be built as shared libraries, the same applies to
>       # libiberty.
>       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 "*)
>       # When bfd is to be built as a shared library, the same applies to
>       # zlib.
> @@ -2357,7 +2362,6 @@ case " $configdirs " in
>       fi
>       ;;
>   esac
> -AC_SUBST(extra_host_libiberty_configure_flags)
>   AC_SUBST(extra_host_zlib_configure_flags)
>   
>   # Produce a warning message for the subdirs we can't configure.
  
Tom de Vries July 12, 2022, 1:42 p.m. UTC | #2
[ dropped gdb-patches, since already applied there. ]

On 6/27/22 15:38, Tom de Vries wrote:
> On 6/27/22 15:03, Tom de Vries wrote:
>> Hi,
>>
>> When building gdb with --enabled-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.
>>
>> OK for gcc trunk?
>>

Ping.

Thanks,
- Tom

> To fix the buildbot breakage, I already pushed to the gdb repo.
> 
> Thanks,
> - Tom
> 
>>
>> [gdb/build] Fix build breaker with --enabled-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.
>>
>> ---
>>   configure    | 8 ++++++--
>>   configure.ac | 8 ++++++--
>>   2 files changed, 12 insertions(+), 4 deletions(-)
>>
>> diff --git a/configure b/configure
>> index aac80b88d70..be433ef6d5d 100755
>> --- a/configure
>> +++ b/configure
>> @@ -6962,13 +6962,18 @@ fi
>>   # Sometimes we have special requirements for the host libiberty.
>>   extra_host_libiberty_configure_flags=
>> -extra_host_zlib_configure_flags=
>>   case " $configdirs " in
>>     *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
>>       # When these are to be built as shared libraries, the same 
>> applies to
>>       # libiberty.
>>       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 "*)
>>       # When bfd is to be built as a shared library, the same applies to
>>       # zlib.
>> @@ -6979,7 +6984,6 @@ case " $configdirs " in
>>   esac
>> -
>>   # Produce a warning message for the subdirs we can't configure.
>>   # 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
>> diff --git a/configure.ac b/configure.ac
>> index 29f74d10b5a..1651cbf3b02 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -2342,13 +2342,18 @@ fi
>>   # Sometimes we have special requirements for the host libiberty.
>>   extra_host_libiberty_configure_flags=
>> -extra_host_zlib_configure_flags=
>>   case " $configdirs " in
>>     *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
>>       # When these are to be built as shared libraries, the same 
>> applies to
>>       # libiberty.
>>       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 "*)
>>       # When bfd is to be built as a shared library, the same applies to
>>       # zlib.
>> @@ -2357,7 +2362,6 @@ case " $configdirs " in
>>       fi
>>       ;;
>>   esac
>> -AC_SUBST(extra_host_libiberty_configure_flags)
>>   AC_SUBST(extra_host_zlib_configure_flags)
>>   # Produce a warning message for the subdirs we can't configure.
  
Iain Sandoe July 12, 2022, 1:59 p.m. UTC | #3
Hi Tom

> On 12 Jul 2022, at 14:42, Tom de Vries via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> 
> [ dropped gdb-patches, since already applied there. ]
> 
> On 6/27/22 15:38, Tom de Vries wrote:
>> On 6/27/22 15:03, Tom de Vries wrote:
>>> Hi,
>>> 
>>> When building gdb with --enabled-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.
>>> 
>>> OK for gcc trunk?
>>> 
> 
> Ping.

see also 
https://gcc.gnu.org/pipermail/gcc-patches/2022-June/597263.html
which is approved but i didn’t yet push it .. 

do you not see any issues with GMP et. al. (or are they not used)?
Iain

> 
> Thanks,
> - Tom
> 
>> To fix the buildbot breakage, I already pushed to the gdb repo.
>> Thanks,
>> - Tom
>>> 
>>> [gdb/build] Fix build breaker with --enabled-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.
>>> 
>>> ---
>>>   configure    | 8 ++++++--
>>>   configure.ac | 8 ++++++--
>>>   2 files changed, 12 insertions(+), 4 deletions(-)
>>> 
>>> diff --git a/configure b/configure
>>> index aac80b88d70..be433ef6d5d 100755
>>> --- a/configure
>>> +++ b/configure
>>> @@ -6962,13 +6962,18 @@ fi
>>>   # Sometimes we have special requirements for the host libiberty.
>>>   extra_host_libiberty_configure_flags=
>>> -extra_host_zlib_configure_flags=
>>>   case " $configdirs " in
>>>     *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
>>>       # When these are to be built as shared libraries, the same applies to
>>>       # libiberty.
>>>       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 "*)
>>>       # When bfd is to be built as a shared library, the same applies to
>>>       # zlib.
>>> @@ -6979,7 +6984,6 @@ case " $configdirs " in
>>>   esac
>>> -
>>>   # Produce a warning message for the subdirs we can't configure.
>>>   # 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
>>> diff --git a/configure.ac b/configure.ac
>>> index 29f74d10b5a..1651cbf3b02 100644
>>> --- a/configure.ac
>>> +++ b/configure.ac
>>> @@ -2342,13 +2342,18 @@ fi
>>>   # Sometimes we have special requirements for the host libiberty.
>>>   extra_host_libiberty_configure_flags=
>>> -extra_host_zlib_configure_flags=
>>>   case " $configdirs " in
>>>     *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
>>>       # When these are to be built as shared libraries, the same applies to
>>>       # libiberty.
>>>       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 "*)
>>>       # When bfd is to be built as a shared library, the same applies to
>>>       # zlib.
>>> @@ -2357,7 +2362,6 @@ case " $configdirs " in
>>>       fi
>>>       ;;
>>>   esac
>>> -AC_SUBST(extra_host_libiberty_configure_flags)
>>>   AC_SUBST(extra_host_zlib_configure_flags)
>>>   # Produce a warning message for the subdirs we can't configure.
  
Tom de Vries July 12, 2022, 2:11 p.m. UTC | #4
On 7/12/22 15:59, Iain Sandoe wrote:
> Hi Tom
> 
>> On 12 Jul 2022, at 14:42, Tom de Vries via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>>
>> [ dropped gdb-patches, since already applied there. ]
>>
>> On 6/27/22 15:38, Tom de Vries wrote:
>>> On 6/27/22 15:03, Tom de Vries wrote:
>>>> Hi,
>>>>
>>>> When building gdb with --enabled-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.
>>>>
>>>> OK for gcc trunk?
>>>>
>>
>> Ping.
> 
> see also
> https://gcc.gnu.org/pipermail/gcc-patches/2022-June/597263.html
> which is approved but i didn’t yet push it ..
> 

Ack.

> do you not see any issues with GMP et. al. (or are they not used)?

Well, it's used, but I'm not building it in-tree:
...
$ ldd ./gdb | grep gmp
         libgmp.so.10 => /usr/lib64/libgmp.so.10 (0x00007f7008706000)
...

Thanks,
- Tom

> Iain
> 
>>
>> Thanks,
>> - Tom
>>
>>> To fix the buildbot breakage, I already pushed to the gdb repo.
>>> Thanks,
>>> - Tom
>>>>
>>>> [gdb/build] Fix build breaker with --enabled-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.
>>>>
>>>> ---
>>>>    configure    | 8 ++++++--
>>>>    configure.ac | 8 ++++++--
>>>>    2 files changed, 12 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/configure b/configure
>>>> index aac80b88d70..be433ef6d5d 100755
>>>> --- a/configure
>>>> +++ b/configure
>>>> @@ -6962,13 +6962,18 @@ fi
>>>>    # Sometimes we have special requirements for the host libiberty.
>>>>    extra_host_libiberty_configure_flags=
>>>> -extra_host_zlib_configure_flags=
>>>>    case " $configdirs " in
>>>>      *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
>>>>        # When these are to be built as shared libraries, the same applies to
>>>>        # libiberty.
>>>>        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 "*)
>>>>        # When bfd is to be built as a shared library, the same applies to
>>>>        # zlib.
>>>> @@ -6979,7 +6984,6 @@ case " $configdirs " in
>>>>    esac
>>>> -
>>>>    # Produce a warning message for the subdirs we can't configure.
>>>>    # 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
>>>> diff --git a/configure.ac b/configure.ac
>>>> index 29f74d10b5a..1651cbf3b02 100644
>>>> --- a/configure.ac
>>>> +++ b/configure.ac
>>>> @@ -2342,13 +2342,18 @@ fi
>>>>    # Sometimes we have special requirements for the host libiberty.
>>>>    extra_host_libiberty_configure_flags=
>>>> -extra_host_zlib_configure_flags=
>>>>    case " $configdirs " in
>>>>      *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
>>>>        # When these are to be built as shared libraries, the same applies to
>>>>        # libiberty.
>>>>        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 "*)
>>>>        # When bfd is to be built as a shared library, the same applies to
>>>>        # zlib.
>>>> @@ -2357,7 +2362,6 @@ case " $configdirs " in
>>>>        fi
>>>>        ;;
>>>>    esac
>>>> -AC_SUBST(extra_host_libiberty_configure_flags)
>>>>    AC_SUBST(extra_host_zlib_configure_flags)
>>>>    # Produce a warning message for the subdirs we can't configure.
>
  
Tom de Vries Sept. 6, 2022, 12:58 p.m. UTC | #5
On 7/12/22 15:42, Tom de Vries wrote:
> [ dropped gdb-patches, since already applied there. ]
> 
> On 6/27/22 15:38, Tom de Vries wrote:
>> On 6/27/22 15:03, Tom de Vries wrote:
>>> Hi,
>>>
>>> When building gdb with --enabled-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.
>>>
>>> OK for gcc trunk?
>>>
> 

Ping^2.

Thanks,
- Tom

>> To fix the buildbot breakage, I already pushed to the gdb repo.
>>
>> Thanks,
>> - Tom
>>
>>>
>>> [gdb/build] Fix build breaker with --enabled-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.
>>>
>>> ---
>>>   configure    | 8 ++++++--
>>>   configure.ac | 8 ++++++--
>>>   2 files changed, 12 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/configure b/configure
>>> index aac80b88d70..be433ef6d5d 100755
>>> --- a/configure
>>> +++ b/configure
>>> @@ -6962,13 +6962,18 @@ fi
>>>   # Sometimes we have special requirements for the host libiberty.
>>>   extra_host_libiberty_configure_flags=
>>> -extra_host_zlib_configure_flags=
>>>   case " $configdirs " in
>>>     *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
>>>       # When these are to be built as shared libraries, the same 
>>> applies to
>>>       # libiberty.
>>>       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 "*)
>>>       # When bfd is to be built as a shared library, the same applies to
>>>       # zlib.
>>> @@ -6979,7 +6984,6 @@ case " $configdirs " in
>>>   esac
>>> -
>>>   # Produce a warning message for the subdirs we can't configure.
>>>   # 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
>>> diff --git a/configure.ac b/configure.ac
>>> index 29f74d10b5a..1651cbf3b02 100644
>>> --- a/configure.ac
>>> +++ b/configure.ac
>>> @@ -2342,13 +2342,18 @@ fi
>>>   # Sometimes we have special requirements for the host libiberty.
>>>   extra_host_libiberty_configure_flags=
>>> -extra_host_zlib_configure_flags=
>>>   case " $configdirs " in
>>>     *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
>>>       # When these are to be built as shared libraries, the same 
>>> applies to
>>>       # libiberty.
>>>       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 "*)
>>>       # When bfd is to be built as a shared library, the same applies to
>>>       # zlib.
>>> @@ -2357,7 +2362,6 @@ case " $configdirs " in
>>>       fi
>>>       ;;
>>>   esac
>>> -AC_SUBST(extra_host_libiberty_configure_flags)
>>>   AC_SUBST(extra_host_zlib_configure_flags)
>>>   # Produce a warning message for the subdirs we can't configure.
  
Richard Sandiford Sept. 7, 2022, 11:06 a.m. UTC | #6
Tom de Vries via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> On 7/12/22 15:42, Tom de Vries wrote:
>> [ dropped gdb-patches, since already applied there. ]
>> 
>> On 6/27/22 15:38, Tom de Vries wrote:
>>> On 6/27/22 15:03, Tom de Vries wrote:
>>>> Hi,
>>>>
>>>> When building gdb with --enabled-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.
>>>>
>>>> OK for gcc trunk?
>>>>
>> 
>
> Ping^2.

OK, thanks.

(Not really my area, but since noone else has commented...)

Richard

> Thanks,
> - Tom
>
>>> To fix the buildbot breakage, I already pushed to the gdb repo.
>>>
>>> Thanks,
>>> - Tom
>>>
>>>>
>>>> [gdb/build] Fix build breaker with --enabled-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.
>>>>
>>>> ---
>>>>   configure    | 8 ++++++--
>>>>   configure.ac | 8 ++++++--
>>>>   2 files changed, 12 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/configure b/configure
>>>> index aac80b88d70..be433ef6d5d 100755
>>>> --- a/configure
>>>> +++ b/configure
>>>> @@ -6962,13 +6962,18 @@ fi
>>>>   # Sometimes we have special requirements for the host libiberty.
>>>>   extra_host_libiberty_configure_flags=
>>>> -extra_host_zlib_configure_flags=
>>>>   case " $configdirs " in
>>>>     *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
>>>>       # When these are to be built as shared libraries, the same 
>>>> applies to
>>>>       # libiberty.
>>>>       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 "*)
>>>>       # When bfd is to be built as a shared library, the same applies to
>>>>       # zlib.
>>>> @@ -6979,7 +6984,6 @@ case " $configdirs " in
>>>>   esac
>>>> -
>>>>   # Produce a warning message for the subdirs we can't configure.
>>>>   # 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
>>>> diff --git a/configure.ac b/configure.ac
>>>> index 29f74d10b5a..1651cbf3b02 100644
>>>> --- a/configure.ac
>>>> +++ b/configure.ac
>>>> @@ -2342,13 +2342,18 @@ fi
>>>>   # Sometimes we have special requirements for the host libiberty.
>>>>   extra_host_libiberty_configure_flags=
>>>> -extra_host_zlib_configure_flags=
>>>>   case " $configdirs " in
>>>>     *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
>>>>       # When these are to be built as shared libraries, the same 
>>>> applies to
>>>>       # libiberty.
>>>>       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 "*)
>>>>       # When bfd is to be built as a shared library, the same applies to
>>>>       # zlib.
>>>> @@ -2357,7 +2362,6 @@ case " $configdirs " in
>>>>       fi
>>>>       ;;
>>>>   esac
>>>> -AC_SUBST(extra_host_libiberty_configure_flags)
>>>>   AC_SUBST(extra_host_zlib_configure_flags)
>>>>   # Produce a warning message for the subdirs we can't configure.
  

Patch

diff --git a/configure b/configure
index aac80b88d70..be433ef6d5d 100755
--- a/configure
+++ b/configure
@@ -6962,13 +6962,18 @@  fi
 
 # Sometimes we have special requirements for the host libiberty.
 extra_host_libiberty_configure_flags=
-extra_host_zlib_configure_flags=
 case " $configdirs " in
   *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
     # When these are to be built as shared libraries, the same applies to
     # libiberty.
     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 "*)
     # When bfd is to be built as a shared library, the same applies to
     # zlib.
@@ -6979,7 +6984,6 @@  case " $configdirs " in
 esac
 
 
-
 # Produce a warning message for the subdirs we can't configure.
 # 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
diff --git a/configure.ac b/configure.ac
index 29f74d10b5a..1651cbf3b02 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2342,13 +2342,18 @@  fi
 
 # Sometimes we have special requirements for the host libiberty.
 extra_host_libiberty_configure_flags=
-extra_host_zlib_configure_flags=
 case " $configdirs " in
   *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
     # When these are to be built as shared libraries, the same applies to
     # libiberty.
     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 "*)
     # When bfd is to be built as a shared library, the same applies to
     # zlib.
@@ -2357,7 +2362,6 @@  case " $configdirs " in
     fi
     ;;
 esac
-AC_SUBST(extra_host_libiberty_configure_flags)
 AC_SUBST(extra_host_zlib_configure_flags)
 
 # Produce a warning message for the subdirs we can't configure.