Bug 219126 - devel/gdb: Add upstream commits to get rid of min/max macros, improving C++ compatibility
Summary: devel/gdb: Add upstream commits to get rid of min/max macros, improving C++ c...
Status: Closed Overcome By Events
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-07 19:43 UTC by Dimitry Andric
Modified: 2018-01-31 21:57 UTC (History)
5 users (show)

See Also:
luca.pizzamiglio: maintainer-feedback+


Attachments
Fix min/max macro usage in devel/gdb (75.90 KB, patch)
2017-05-07 19:43 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer freebsd_triage 2017-05-07 19:43:52 UTC
Created attachment 182374 [details]
Fix min/max macro usage in devel/gdb

I have been experimenting with a newer version of libc++ in the projects/clang500-import branch, and it turns out that gdb has traditionally defined their own min/max macros.  However, it compiles most of its .c files as C++, and min/max macros are not compatible with C++.

Due to a slightly different include order in newer versions of libc++, this now even leads to compilation errors like the following:

In file included from doublest.c:30:
In file included from build-gnulib/import/math.h:27:
In file included from /usr/include/c++/v1/math.h:310:
In file included from /usr/include/c++/v1/limits:112:
/usr/include/c++/v1/__undef_min_max:17:2: warning: : macro min is incompatible with C++. #undefing min [-W#warnings]
#warning: macro min is incompatible with C++.  #undefing min
 ^
/usr/include/c++/v1/__undef_min_max:29:2: warning: : macro max is incompatible with C++. #undefing max [-W#warnings]
#warning: macro max is incompatible with C++.  #undefing max
 ^
c++: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
doublest.c:258:19: error: use of undeclared identifier 'min'; did you mean 'fmin'?
      mant_bits = min (mant_bits_left, 32);
                  ^~~
                  fmin
/usr/include/c++/v1/math.h:1221:1: note: 'fmin' declared here
fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
^
doublest.c:568:19: error: use of undeclared identifier 'min'; did you mean 'fmin'?
      mant_bits = min (mant_bits_left, 32);
                  ^~~
                  fmin
/usr/include/c++/v1/math.h:1221:1: note: 'fmin' declared here
fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
^
doublest.c:912:25: error: use of undeclared identifier 'min'; did you mean 'fmin'?
      memcpy (to, from, min (TYPE_LENGTH (from_type), TYPE_LENGTH (to_type)));
                        ^~~
                        fmin
/usr/include/c++/v1/math.h:1221:1: note: 'fmin' declared here
fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
^
2 warnings and 3 errors generated.

Upstream has also seen this problem with newer versions of GNU libstdc++, so it made the following two commits:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=325fac504a327de9c46a4e5cf9c88ece9d9d7701
("gdb: Use std::min and std::max throughout")

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=768adc05c44c7e8b5c0f9ca5ad3ca96657715293
("gdb: Fix std::{min, max}-related build breakage on 32-bit hosts")

Here is a patch to add these two commits to our devel/gdb port.  I hope they will no longer be necessary when a new gdb version is released.
Comment 1 luca.pizzamiglio 2017-05-08 09:11:45 UTC
Testing it. Soon a feedback will follow

thanks!
Comment 2 Walter Schwarzenfeld 2018-01-31 20:16:36 UTC
Is this still relevant?
Comment 3 Luca Pizzamiglio freebsd_committer freebsd_triage 2018-01-31 21:57:06 UTC
I guess, I've lost this PR when I changed account. Really sorry.
I can close it.

We're currently working on gdb 8.1, which already includes those patches.