RFR: 8354941: Build failure with glibc 2.42 due to uabs() name collision

Severin Gehwolf sgehwolf at openjdk.org
Tue Apr 29 12:36:46 UTC 2025


On Sun, 27 Apr 2025 10:13:28 GMT, Andrew Haley <aph at openjdk.org> wrote:

>> glibc 2.42 defines its own version of `uabs` when `stdlib.h` is being included. I propose to rename the hotspot version of `uabs` to `custom_uabs` (or some other suitable name) to avoid the name clash. The rename of the function is hidden by using a `UABS` macro instead in the code.
>> 
>> Testing:
>> - [x] GHA (also [here](https://github.com/jerboaa/jdk/actions/runs/14513365723))
>> - [x] Builds with this patch with GCC 15 where the build would fail earlier and pass with this patch.
>> 
>> Thoughts?
>
> So here's the root of the problem: we define _GNU_SOURCE, which pulls in even nonstandard definitions that violate the usual namespace rules. In this case, defining uabs() which is proposed for standardization in C2Y. 
> 
> We're always going to be vulnerable to problems like this as long as we define _GNU_SOURCE, because we cannot predict what names will be used in future C and C++ standards. The only way we can really defend ourselves against this is to use a private namespace.

@theRealAph OK to you as well?

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

PR Comment: https://git.openjdk.org/jdk/pull/24723#issuecomment-2838650531


More information about the hotspot-dev mailing list