On 18/01/2021 11:59 pm, Magnus Ihse Bursie wrote:
On Fri, 15 Jan 2021 04:57:24 GMT, David Holmes <[email protected]> wrote:

We are now confident that we have build-time and runtime support for 
clock_gettime and CLOCK_MONOTONIC on all our OpenJDK supported POSIX platforms 
- see bug report for some more details on different OS. Consequently we can 
simplify a lot of the code in this area and move common code to os_posix.

As of glibc 2.17 the necessary functions are in glibc rather than librt, but we 
(Oracle at least) aren't yet in position to set our minimum Linux version to 
support that. We still have supported platforms at glibc 2.12. So to address 
that we link librt at build time on Linux. This seems to work find for older 
and more modern Linuxes and also works for the Apline Linux with Musl variant.

The changes are in layered commits:

Step 1: Remove build time checks. SUPPORTS_CLOCK_MONOTONIC is assumed true and 
removed.
Step 2: make supports_monotonic_clock always true and so remove checking in OS 
code
Step 3: Replace gettimeofday by clock_gettime(CLOCK_REALTIME)
Step 4: Move shared time functions to os_posix.cpp
Step 5: Alway link librt on Linux so we don't rely on glibc > 2.17

Testing: tiers 1-3 for functional testing
              built and checked (-Xlog:os) on Linux with glibc 2.12 and 2.17,  
macOS 10.13.6 and 10.15.7

Looks like a good cleanup. But please minimize the use of -lrt to hotspot only 
as per the comment above.

make/autoconf/flags-ldflags.m4 line 116:

114:       # has glibc 2.17, this can be removed as the functions are
115:       # in libc.
116:       OS_LDFLAGS="-lrt"

I believe this should be `OS_LDFLAGS_JVM_ONLY`, right?

Right - sorry, don't know how I missed that.

Thanks,
David

-------------

Changes requested by ihse (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/2090

Reply via email to