Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 680232 - sys-devel/gdb-8.3.50.20190312 needs a patch for C++17
Summary: sys-devel/gdb-8.3.50.20190312 needs a patch for C++17
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL: https://sourceware.org/ml/gdb-patches...
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2019-03-13 13:05 UTC by Helmut Jarausch
Modified: 2019-03-18 07:56 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build log xz-compressed (gdb-8.3.50.20190312.build.xz,23.23 KB, application/x-xz)
2019-03-14 14:51 UTC, Helmut Jarausch
Details
gdb-c++17.patch (gdb-c++17.patch,461 bytes, patch)
2019-03-14 19:50 UTC, Sergei Trofimovich
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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 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 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 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(+)