Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8262501

jdk17 libjvm link failure with --as-needed and clock_gettime in librt

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 17
    • 17
    • hotspot
    • b19
    • generic
    • linux

      The fix from JDK-8246112 breaks the build with old (but according to comments still supported) glibc versions, when ld defaults to the --as-needed behavior.

      The reason for that is the passing of a library (-lrt) in a LDFLAGS macro, not in a LIBS macro.

      A quick workaround is

      --- a/make/autoconf/flags-ldflags.m4
      +++ b/make/autoconf/flags-ldflags.m4
      @@ -113,7 +113,7 @@
             # But once our supported minimum build and runtime platform
             # has glibc 2.17, this can be removed as the functions are
             # in libc.
      - OS_LDFLAGS_JVM_ONLY="-lrt"
      + OS_LDFLAGS_JVM_ONLY="-Wl,--no-as-needed -lrt"
           fi
         fi

      So -lrt should be passed in the macros which are used to pass -ldl -lpthread ...

            dholmes David Holmes
            doko Matthias Klose
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: