gdb: unconditionally define _initialize_string_view_selftests

Message ID 20190314222828.28798-1-slyfox@gentoo.org
State New
Headers show
Series
  • gdb: unconditionally define _initialize_string_view_selftests
Related show

Commit Message

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(-)

-- 
2.21.0

Comments

Tom Tromey March 15, 2019, 2:24 p.m. | #1
>>>>> "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. | #2
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.

-- 

  Sergei
Sergio Durigan Junior March 18, 2019, 3:55 a.m. | #3
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,

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/
Tom Tromey March 18, 2019, 4 p.m. | #4
>>>>> "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 */