RFR: 8161145: The min/max macros make hotspot tests fail to build with GCC 6

Andrew Hughes gnu.andrew at redhat.com
Wed Jul 13 19:12:33 UTC 2016



----- Original Message -----
> > On Jul 12, 2016, at 2:21 PM, Andrew Hughes <gnu.andrew at redhat.com> wrote:
> > 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])
> 
> Since when does <stdlib.h> define / declare min or max?  To me, that seems
> like a bug in this wrapper.

It doesn't; it's defined in <limits>.

The stdlib.h C++ wrapper is new to GCC 6, and thus so is the define, so we
can use it to just disable these macros on that version.

It also wouldn't surprise me that the error is down to one of these new
wrapper headers bringing in other C++ headers, including limits. I
can't find the exact path for such an inclusion, but this issue
only shows up on GCC 6, where the wrapper headers are present.
Including <stdlib.h> on earlier versions just uses the C
header, not <cstdlib>.

> 
> > $ 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
> 
> 
> 

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