Patchwork gdb: unconditionally define _initialize_string_view_selftests

login
register
mail settings
Submitter Sergei Trofimovich
Date March 14, 2019, 10:28 p.m.
Message ID <20190314222828.28798-1-slyfox@gentoo.org>
Download mbox | patch
Permalink /patch/31857/
State New
Headers show

Comments

Sergei Trofimovich - March 14, 2019, 10:28 p.m.
The build failure was noticed by Helmut Jarausch in
https://bugs.gentoo.org/680232:
    $ ./configure CXXFLAGS='-std=c++17 -Os'
    ...
      CXXLD  gdb
    ld: init.o: in function `initialize_all_files()':
    init.c:(.text+0x113): undefined reference to `_initialize_string_view_selftests()'

It happens because '_initialize_string_view_selftests()' is
conditionally defined based on C++ default.

The change defines '_initialize_string_view_selftests()'
unconditionally and leaves implementation a no-op on c++17
compilers.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
---
 gdb/unittests/string_view-selftests.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Tom Tromey - March 15, 2019, 2:24 p.m.
>>>>> "Sergei" == Sergei Trofimovich <slyfox@gentoo.org> writes:

Sergei> The build failure was noticed by Helmut Jarausch in
Sergei> https://bugs.gentoo.org/680232:
Sergei>     $ ./configure CXXFLAGS='-std=c++17 -Os'
Sergei>     ...
Sergei>       CXXLD  gdb
Sergei>     ld: init.o: in function `initialize_all_files()':
Sergei>     init.c:(.text+0x113): undefined reference to `_initialize_string_view_selftests()'

Sergei> It happens because '_initialize_string_view_selftests()' is
Sergei> conditionally defined based on C++ default.

Sergei> The change defines '_initialize_string_view_selftests()'
Sergei> unconditionally and leaves implementation a no-op on c++17
Sergei> compilers.

Thank you.  This is OK with a ChangeLog entry.
Let me know if you need me to check it in for you.

thanks,
Tom
Sergei Trofimovich - March 17, 2019, 10:20 p.m.
On Fri, 15 Mar 2019 08:24:17 -0600
Tom Tromey <tom@tromey.com> wrote:

> >>>>> "Sergei" == Sergei Trofimovich <slyfox@gentoo.org> writes:  
> 
> Sergei> The build failure was noticed by Helmut Jarausch in
> Sergei> https://bugs.gentoo.org/680232:
> Sergei>     $ ./configure CXXFLAGS='-std=c++17 -Os'
> Sergei>     ...
> Sergei>       CXXLD  gdb
> Sergei>     ld: init.o: in function `initialize_all_files()':
> Sergei>     init.c:(.text+0x113): undefined reference to `_initialize_string_view_selftests()'  
> 
> Sergei> It happens because '_initialize_string_view_selftests()' is
> Sergei> conditionally defined based on C++ default.  
> 
> Sergei> The change defines '_initialize_string_view_selftests()'
> Sergei> unconditionally and leaves implementation a no-op on c++17
> Sergei> compilers.  
> 
> Thank you.  This is OK with a ChangeLog entry.
> Let me know if you need me to check it in for you.

Thank you for the quick review! Yes, I need someone to check the
change in for me. Should I indicate it the patch email next time?

I'll send a follow-up v2 with ChangeLog added and author email
matching the company which has agreement already signed with FSF.
Sergio Durigan Junior - March 18, 2019, 3:55 a.m.
On Sunday, March 17 2019, Sergei Trofimovich wrote:

> On Fri, 15 Mar 2019 08:24:17 -0600
> Tom Tromey <tom@tromey.com> wrote:
>
>> >>>>> "Sergei" == Sergei Trofimovich <slyfox@gentoo.org> writes:  
>> 
>> Sergei> The build failure was noticed by Helmut Jarausch in
>> Sergei> https://bugs.gentoo.org/680232:
>> Sergei>     $ ./configure CXXFLAGS='-std=c++17 -Os'
>> Sergei>     ...
>> Sergei>       CXXLD  gdb
>> Sergei>     ld: init.o: in function `initialize_all_files()':
>> Sergei>     init.c:(.text+0x113): undefined reference to `_initialize_string_view_selftests()'  
>> 
>> Sergei> It happens because '_initialize_string_view_selftests()' is
>> Sergei> conditionally defined based on C++ default.  
>> 
>> Sergei> The change defines '_initialize_string_view_selftests()'
>> Sergei> unconditionally and leaves implementation a no-op on c++17
>> Sergei> compilers.  
>> 
>> Thank you.  This is OK with a ChangeLog entry.
>> Let me know if you need me to check it in for you.
>
> Thank you for the quick review! Yes, I need someone to check the
> change in for me. Should I indicate it the patch email next time?

Either that, or you can request commit access to the repository here:

  https://sourceware.org/cgi-bin/pdw/ps_form.cgi

I'm not a global maintainer, but I believe Tom wouldn't mind if you put
him as the person who approved the request.

Thanks,
Tom Tromey - March 18, 2019, 4 p.m.
>>>>> "Sergio" == Sergio Durigan Junior <sergiodj@redhat.com> writes:

Sergio> I'm not a global maintainer, but I believe Tom wouldn't mind if you put
Sergio> him as the person who approved the request.

Indeed.  The rule is you need one accepted patch to get
write-after-review access.  If you go this route then you should send
and commit a patch to update the MAINTAINERS file to add your name.

thanks,
Tom

Patch

diff --git a/gdb/unittests/string_view-selftests.c b/gdb/unittests/string_view-selftests.c
index 21a10e65af..b2a2bf7f2e 100644
--- a/gdb/unittests/string_view-selftests.c
+++ b/gdb/unittests/string_view-selftests.c
@@ -170,10 +170,12 @@  run_tests ()
 } /* namespace string_view */
 } /* namespace selftests */
 
+#endif /* __cplusplus < 201703L */
+
 void
 _initialize_string_view_selftests ()
 {
+#if defined(GDB_STRING_VIEW)
   selftests::register_test ("string_view", selftests::string_view::run_tests);
+#endif
 }
-
-#endif /* __cplusplus < 201703L */