Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 680232

Summary: sys-devel/gdb-8.3.50.20190312 needs a patch for C++17
Product: Gentoo Linux Reporter: Helmut Jarausch <jarausch>
Component: Current packagesAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: RESOLVED FIXED    
Severity: normal CC: slyfox
Priority: Normal Keywords: PATCH
Version: unspecified   
Hardware: All   
OS: Linux   
URL: https://sourceware.org/ml/gdb-patches/2019-03/msg00306.html
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: build log xz-compressed
gdb-c++17.patch

Description Helmut Jarausch 2019-03-13 13:05:08 UTC
This version of gdb is broken when beeing compiled with -std=c++17

In file gdb/unittests/string_view-selftests.c you can read
/* No need to test string_view if we're using C++17, since we're going to use
   the "real" version.  */
#if __cplusplus < 201703L

Therefore 
_initialize_string_view_selftests doesn't get defined.

But the generated file  gdb/init.c does invoke this, which gives a linker error.

The following patch fixes this

--- a/gdb/Makefile.in.ORIG	2019-03-12 02:49:16.000000000 +0100
+++ b/gdb/Makefile.in	2019-03-13 13:44:19.939962060 +0100
@@ -1870,6 +1870,9 @@
 	@sed -e 's/\(.*\)/  _initialize_\1 ();/' <init.l-tmp >>init.c-tmp
 	@echo '}' >>init.c-tmp
+	@sed -i -e'/_initialize_string_view_selftests ();/i \
+#if __cplusplus < 201703L' -e'/_initialize_string_view_selftests ();/a \
+#endif' init.c-tmp
 	@$(SHELL) $(srcdir)/../move-if-change init.c-tmp init.c
 	@echo stamp > stamp-init
 
 .PRECIOUS: init.c
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2019-03-13 20:51:23 UTC
(In reply to Helmut Jarausch from comment #0)
> This version of gdb is broken when being compiled with -std=c++17

Do you pass it explicitly to CXXFLAGS? Please provide a build.log.
Comment 2 Helmut Jarausch 2019-03-14 14:51:36 UTC
Created attachment 569092 [details]
build log  xz-compressed
Comment 3 Helmut Jarausch 2019-03-14 14:52:38 UTC
(In reply to Sergei Trofimovich from comment #1)
> (In reply to Helmut Jarausch from comment #0)
> > This version of gdb is broken when being compiled with -std=c++17
> 
> Do you pass it explicitly to CXXFLAGS? Please provide a build.log.

Yes, I have  CXXFLAGS="${CFLAGS} -std=c++17"
in my make.conf file.
Comment 4 Sergei Trofimovich (RETIRED) gentoo-dev 2019-03-14 19:50:27 UTC
Created attachment 569106 [details, diff]
gdb-c++17.patch

Aha. gdb-c++17.patch should be slightly less invasive way to do it: always define a test and make it a no-op on new compilers.

Can you elaborate why specifically you are using that flag explicitly?

Given it's not a default language yet it has a chance of triggering unexpected problems in upstream code. -std= is different from optimization flags in a way that it changes language semantics slightly (new overloads, default operators and keywords). It is expected to break occasionally (as opposed to optimization-only flags which should not affect C++ semantics).
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2019-03-14 22:29:48 UTC
Posted the fix upstream as https://sourceware.org/ml/gdb-patches/2019-03/msg00306.html
Comment 6 Larry the Git Cow gentoo-dev 2019-03-14 22:49:45 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=890e99a6aef35c3e8c9a828bdf5ca9eafec6a1bb

commit 890e99a6aef35c3e8c9a828bdf5ca9eafec6a1bb
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2019-03-14 22:49:20 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-03-14 22:49:37 +0000

    sys-devel/gdb: fix build against -std=c++17
    
    Patch is proposed upstream as:
    https://sourceware.org/ml/gdb-patches/2019-03/msg00306.html
    
    Reported-by: Helmut Jarausch
    Closes: https://bugs.gentoo.org/680232
    Package-Manager: Portage-2.3.62, Repoman-2.3.12
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 sys-devel/gdb/files/gdb-8.3.50.20190312-c++17.patch | 19 +++++++++++++++++++
 sys-devel/gdb/gdb-8.3.50.20190312-r1.ebuild         |  1 +
 2 files changed, 20 insertions(+)