On Wed, 10 Apr 2024 00:51:22 GMT, Kim Barrett <kbarr...@openjdk.org> wrote:

>> src/hotspot/share/utilities/globalDefinitions_gcc.hpp line 36:
>> 
>>> 34: #if defined(_AIX)
>>> 35: #include <alloca.h>
>>> 36: #endif
>> 
>> I would much rather see this include added in the few places it was actually 
>> needed, rather than being
>> added here.
>
> Do we even need to include <alloca.h>? 
> 
> From the Linux man page for alloca:
> 
> By necessity, alloca() is a compiler built-in, also known as
> __builtin_alloca().  By default, modern compilers automatically
> translate all uses of alloca() into the built-in, but this is
> forbidden if standards conformance is requested (-ansi, -std=c*),
> in which case <alloca.h> is required, lest a symbol dependency be
> emitted.
> 
> There are uses of it in shared code where there isn't an applicable include,
> other than from globalDefinitions_xlc.hpp. So it appears all other supported
> compilers do treat it as a built-in with the options we are providing, and
> don't need the include. Maybe that's true for the new xlc compiler too?

If I omit this #include <alloca.h>
I get compiler errors of the following kind

.../src/hotspot/share/runtime/javaThread.cpp:2222:24: error: use of undeclared 
identifier 'alloca'
    char* p1 = (char*) alloca(1);
                       ^


Of course I can do this include in every nagging file, but I thought it is 
simpler to keep it in the central header.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18536#discussion_r1559150964

Reply via email to