OpenJDK fails to build with GCC when the #include<time.h> inside zip.cpp comes from a non-sysroot path
Florian Weimer
fweimer at redhat.com
Thu Nov 29 11:06:29 UTC 2018
* Patrick Zhang:
> Hi Florian
>
> Thanks for your comments
>
>>> I doubt it has anything to do with a sysroot vs non-sysroot configuration.
>
> The tests are done on two systems respectively, CentOS 7.4 (glibc 2.17) and Fedora 28 (glibc 2.27).
> GCC 9 can be used as well to reproduce the issue as well like this:
> 1. /opt/gcc900/bin/g++ -c timetest.cpp
> 2. /opt/gcc900/bin/g++ -I<another-root>/usr/include -c timetest.cpp
> 3. /opt/gcc900/bin/g++ --sysroot=<another-root> -c timetest.cpp
> 4. /opt/gcc900/bin/g++ --sysroot=<another-root> -I/usr/include -c timetest.cpp
> In above experiments, #1, #3 are good, because the time.h they found
> are under their sysroot path and treated as system header file
> (linemarker 3), while #2, #4 are bad since time.h comes from a
> non-sysroot path.
I see. I would have expected /usr/include to be brought into the
sysroot via a symbolic link.
You see the issue because you used “-I/usr/include” and not
“-isystem /usr/include”. The latter would have marked /usr/include
as a system header location, with warning suppressions and all that.
> Agree, as the declaration may be a redundant one in most occasions,
> what about changing it like below? I tested in my env it works well.
>
> diff -r 70a423caee44 src/share/native/com/sun/java/util/jar/pack/zip.cpp
> --- a/src/share/native/com/sun/java/util/jar/pack/zip.cpp Tue Oct 09 08:33:33 2018 +0100
> +++ b/src/share/native/com/sun/java/util/jar/pack/zip.cpp Wed Nov 28 22:13:12 2018 -0500
> @@ -415,9 +415,7 @@
> ((uLong)h << 11) | ((uLong)m << 5) | ((uLong)s >> 1);
> }
>
> -#ifdef _REENTRANT // solaris
> -extern "C" struct tm *gmtime_r(const time_t *, struct tm *);
> -#else
> +#if !defined(_REENTRANT) // linux
> #define gmtime_r(t, s) gmtime(t)
> #endif
> /*
This looks more reasonable to me (but I'm not a Reviewer).
Thanks,
Florian
More information about the jdk-dev
mailing list