RFR: 8161145: The min/max macros make hotspot tests fail to build with GCC 6
Andrew Hughes
gnu.andrew at redhat.com
Tue Jul 12 18:21:12 UTC 2016
----- Original Message -----
> > On Jul 11, 2016, at 2:45 PM, Omair Majid <omajid at redhat.com> wrote:
> >
> > Hi,
> >
> > Bug: https://bugs.openjdk.java.net/browse/JDK-8161145
> > Webrev:
> > http://cr.openjdk.java.net/~omajid/webrevs/8161145-gcc6-min-max-macros/00/
>
> https://wiki.openjdk.java.net/display/HotSpot/StyleGuide
> All .cpp files include precompiled.hpp as the first include line.
>
> Also, fixing include order problems by tweaking the order of the
> includes rarely leads to a happy ending. I wonder whether
> runtime/test_arguments.cpp is already suffering from such tweaking, as
> it presently #includes unittest.hpp before
> utilities/globalDefinitions.hpp, which seems odd.
This was my worry as well when I saw Omair's patch. It fixes the
issue for now, but it seems a very fragile solution.
>
> I think a different approach is needed. Perhaps don't provided the
> poisoned definitions at all. Or maybe we can use blue paint, e.g.
>
> #define min min
> #define max max
>
The workaround that currently works for me is:
diff -r b515beb3b4ad src/share/vm/utilities/globalDefinitions.hpp
--- a/src/share/vm/utilities/globalDefinitions.hpp Thu Jul 07 18:40:53 2016 +0100
+++ b/src/share/vm/utilities/globalDefinitions.hpp Tue Jul 12 19:13:51 2016 +0100
@@ -1163,8 +1163,10 @@
#undef min
#endif
+#ifndef _GLIBCXX_STDLIB_H
#define max(a,b) Do_not_use_max_use_MAX2_instead
#define min(a,b) Do_not_use_min_use_MIN2_instead
+#endif
// It is necessary to use templates here. Having normal overloaded
// functions does not work because it is necessary to provide both 32-
_GLIBCXX_STDLIB_H only exists in GCC 6. Earlier versions use stdlib.h from the
C library. Thus this seems to provide the solution of only disabling
those macros only on GCC >= 6 where they conflict with the functions
max and min defined by this C++ stdlib.h wrapper (see stdlib.h changes
in [0])
$ find /usr/lib/gcc/x86_64-pc-linux-gnu -name 'stdlib.h'
/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5/tr1/stdlib.h
/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5/tr1/stdlib.h
/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0-alpha20160306/include/g++-v6/stdlib.h
/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0-alpha20160306/include/g++-v6/tr1/stdlib.h
$ grep -r '_GLIBCXX_STDLIB_H' /usr/lib/gcc/x86_64-pc-linux-gnu/
/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0-alpha20160306/include/g++-v6/stdlib.h:#ifndef _GLIBCXX_STDLIB_H
/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0-alpha20160306/include/g++-v6/stdlib.h:#define _GLIBCXX_STDLIB_H 1
/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0-alpha20160306/include/g++-v6/stdlib.h:#endif // _GLIBCXX_STDLIB_H
[0] https://gcc.gnu.org/gcc-6/porting_to.html
--
Andrew :)
Senior Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)
PGP Key: ed25519/35964222 (hkp://keys.gnupg.net)
Fingerprint = 5132 579D D154 0ED2 3E04 C5A0 CFDA 0F9B 3596 4222
More information about the hotspot-dev
mailing list