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

JDK 8 doesn't compile in modern compilers deprecating register keyword

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      ❯ gcc --version
      gcc (GCC) 11.4.1 20231218 (Red Hat 11.4.1-3)
      Copyright (C) 2021 Free Software Foundation, Inc.
      This is free software; see the source for copying conditions. There is NO
      warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

      A DESCRIPTION OF THE PROBLEM :
      When compiling latest jdk8u432-b01, revision, on centos native GCC I face compilation error such as

      /home/elazarl/jdk8u-dev/hotspot/src/share/vm/adlc/arena.cpp:82:19: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register]
         82 | register Chunk *k = _first;
            | ^

      REGRESSION : Last worked in version 22.0.2

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Just `bash ./configure && make all` on latest tag in jdk8u, tested on jdk8u432-b01

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      JDK will be built
      ACTUAL -
      Compilation error

      CUSTOMER SUBMITTED WORKAROUND :
      Apply the following patch

      diff --git a/hotspot/src/share/vm/adlc/adlparse.cpp b/hotspot/src/share/vm/adlc/adlparse.cpp
      index 31955ff7d3..6dcd90acb5 100644
      --- a/hotspot/src/share/vm/adlc/adlparse.cpp
      +++ b/hotspot/src/share/vm/adlc/adlparse.cpp
      @@ -4564,7 +4564,7 @@ char *ADLParser::get_paren_expr(const char *description, bool include_location)
       // string(still inside the file buffer). Returns a pointer to the string or
       // NULL if some other token is found instead.
       char *ADLParser::get_ident_common(bool do_preproc) {
      - register char c;
      + char c;
         char *start; // Pointer to start of token
         char *end; // Pointer to end of token

      @@ -4762,7 +4762,7 @@ char *ADLParser::get_unique_ident(FormDict& dict, const char* nameDescription){
       // invokes a parse_err if the next token is not an integer.
       // This routine does not leave the integer null-terminated.
       int ADLParser::get_int(void) {
      - register char c;
      + char c;
         char *start; // Pointer to start of token
         char *end; // Pointer to end of token
         int result; // Storage for integer result
      diff --git a/hotspot/src/share/vm/adlc/arena.cpp b/hotspot/src/share/vm/adlc/arena.cpp
      index d7e4fc6eb4..406187ae91 100644
      --- a/hotspot/src/share/vm/adlc/arena.cpp
      +++ b/hotspot/src/share/vm/adlc/arena.cpp
      @@ -79,7 +79,7 @@ Arena::Arena( Arena *a )
       // Total of all Chunks in arena
       size_t Arena::used() const {
         size_t sum = _chunk->_len - (_max-_hwm); // Size leftover in this Chunk
      - register Chunk *k = _first;
      + Chunk *k = _first;
         while( k != _chunk) { // Whilst have Chunks in a row
           sum += k->_len; // Total size of this Chunk
           k = k->_next; // Bump along to next Chunk
      @@ -93,7 +93,7 @@ void* Arena::grow( size_t x ) {
         // Get minimal required size. Either real big, or even bigger for giant objs
         size_t len = max(x, Chunk::size);

      - register Chunk *k = _chunk; // Get filled-up chunk address
      + Chunk *k = _chunk; // Get filled-up chunk address
         _chunk = new (len) Chunk(len);

         if( k ) k->_next = _chunk; // Append new chunk to end of linked list
      diff --git a/hotspot/src/share/vm/adlc/dict2.cpp b/hotspot/src/share/vm/adlc/dict2.cpp
      index f341a2b67b..2dc60b250b 100644
      --- a/hotspot/src/share/vm/adlc/dict2.cpp
      +++ b/hotspot/src/share/vm/adlc/dict2.cpp
      @@ -283,9 +283,9 @@ void Dict::print(PrintKeyOrValue print_key, PrintKeyOrValue print_value) {
       // limited to MAXID characters in length. Experimental evidence on 150K of
       // C text shows excellent spreading of values for any size hash table.
       int hashstr(const void *t) {
      - register char c, k = 0;
      - register int sum = 0;
      - register const char *s = (const char *)t;
      + char c, k = 0;
      + int sum = 0;
      + const char *s = (const char *)t;

         while (((c = s[k]) != '\0') && (k < MAXID-1)) { // Get characters till nul
           c = (char) ((c << 1) + 1); // Characters are always odd!
      diff --git a/hotspot/src/share/vm/adlc/main.cpp b/hotspot/src/share/vm/adlc/main.cpp
      index 52044f12d4..40bcda743a 100644
      --- a/hotspot/src/share/vm/adlc/main.cpp
      +++ b/hotspot/src/share/vm/adlc/main.cpp
      @@ -58,7 +58,7 @@ int main(int argc, char *argv[])

         // Read command line arguments and file names
         for( int i = 1; i < argc; i++ ) { // For all arguments
      - register char *s = argv[i]; // Get option/filename
      + char *s = argv[i]; // Get option/filename

           if( *s++ == '-' ) { // It's a flag? (not a filename)
             if( !*s ) { // Stand-alone `-' means stdin

      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: