JDK-8354941 : Build failure with glibc 2.42 due to uabs() name collision
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8,11,17,21,24,25
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2025-04-17
  • Updated: 2025-05-21
  • Resolved: 2025-05-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 25
25 b23Fixed
Related Reports
Relates :  
Description
When attempting to build OpenJDK with GCC 15 and glibc 2.42 (the GCC/glibc versions for F43 to be released in Fall 2025) the build fails with something like this:

++ /usr/bin/tee -a /builddir/build/BUILD/java-latest-openjdk-portable-24.0.1.0.9-build/java-24-openjdk-24.0.1.0.9-1.rolling.fc43.x86_64/build/newboot/hotspot/variant-server/libjvm/objs/precompiled/precompiled.hpp.gch.log
++ /usr/bin/tee -a /builddir/build/BUILD/java-latest-openjdk-portable-24.0.1.0.9-build/java-24-openjdk-24.0.1.0.9-1.rolling.fc43.x86_64/build/newboot/hotspot/variant-server/libjvm/objs/precompiled/precompiled.hpp.gch.log
In file included from /builddir/build/BUILD/java-latest-openjdk-portable-24.0.1.0.9-build/java-24-openjdk-24.0.1.0.9-1.rolling.fc43.x86_64/jdk-24.0.1+9/src/hotspot/share/nmt/memTag.hpp:28,
                 from /builddir/build/BUILD/java-latest-openjdk-portable-24.0.1.0.9-build/java-24-openjdk-24.0.1.0.9-1.rolling.fc43.x86_64/jdk-24.0.1+9/src/hotspot/share/memory/allocation.hpp:29,
                 from /builddir/build/BUILD/java-latest-openjdk-portable-24.0.1.0.9-build/java-24-openjdk-24.0.1.0.9-1.rolling.fc43.x86_64/jdk-24.0.1+9/src/hotspot/share/classfile/classLoaderData.hpp:28,
                 from /builddir/build/BUILD/java-latest-openjdk-portable-24.0.1.0.9-build/java-24-openjdk-24.0.1.0.9-1.rolling.fc43.x86_64/jdk-24.0.1+9/src/hotspot/share/precompiled/precompiled.hpp:34:
/builddir/build/BUILD/java-latest-openjdk-portable-24.0.1.0.9-build/java-24-openjdk-24.0.1.0.9-1.rolling.fc43.x86_64/jdk-24.0.1+9/src/hotspot/share/utilities/globalDefinitions.hpp:1166:28: error: ‘unsigned int uabs(int)’ was declared ‘extern’ and later ‘static’ [-fpermissive]
 1166 | static inline unsigned int uabs(int n) { return uabs((unsigned int)n); }
      |                            ^~~~
In file included from /usr/include/c++/15/cstdlib:83,
                 from /usr/include/c++/15/stdlib.h:36,
                 from /builddir/build/BUILD/java-latest-openjdk-portable-24.0.1.0.9-build/java-24-openjdk-24.0.1.0.9-1.rolling.fc43.x86_64/jdk-24.0.1+9/src/hotspot/share/utilities/globalDefinitions_gcc.hpp:42,
                 from /builddir/build/BUILD/java-latest-openjdk-portable-24.0.1.0.9-build/java-24-openjdk-24.0.1.0.9-1.rolling.fc43.x86_64/jdk-24.0.1+9/src/hotspot/share/utilities/globalDefinitions.hpp:35:
/usr/include/stdlib.h:989:21: note: previous declaration of ‘unsigned int uabs(int)’
  989 | extern unsigned int uabs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |                     ^~~~
+ exitcode=1

The reason for this seems to be a name clash of uabs() when stdlib.h is being included. GCC defines a version of it and so does HotSpot.
Comments
Given that uabs was globally exposed by JDK-8213419, I think this will eventually hit all current JDK updates once we start to update toolchains. Marking affected versions to capture this.
14-05-2025

Changeset: 38bb8adf Branch: master Author: Severin Gehwolf <sgehwolf@openjdk.org> Date: 2025-05-13 09:59:49 +0000 URL: https://git.openjdk.org/jdk/commit/38bb8adf4f632b08af15f2d8530b35f05f86a020
13-05-2025

ILW = Build failure due to name collision, with future glibc, use different glibc version = HLM = P3
22-04-2025

Mark Wielaard kindly pointed out this this glibc commit that introduced uabs: https://sourceware.org/cgit/glibc/commit/?id=5b132ec2b7712dbc055838b3b538b83ad1196414
17-04-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/24723 Date: 2025-04-17 12:31:18 +0000
17-04-2025

Thanks [~fweimer]. I'll update the bug.
17-04-2025

Please not that this is a glibc 2.42 incompatibility and future C++ standard incompatibility (once an upcoming C++ standard imports the C23 successor), not a GCC 15 incompatibility (stdlib.h comes from glibc).
17-04-2025

Can be reproduced fairly easily with the attached test.cpp file (derived from globalDefinitions.hpp): $ g++ -Wall -O3 -c -o test.o test.cpp test.cpp:26:28: error: ‘unsigned int uabs(int)’ was declared ‘extern’ and later ‘static’ [-fpermissive] 26 | static inline unsigned int uabs(int n) { return uabs((unsigned int)n); } | ^~~~ In file included from /usr/include/c++/15/cstdlib:83, from /usr/include/c++/15/stdlib.h:36, from test.cpp:2: /usr/include/stdlib.h:989:21: note: previous declaration of ‘unsigned int uabs(int)’ 989 | extern unsigned int uabs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~~
17-04-2025