Hi Brooks,
> On 29. Jul 2024, at 23:42, Brooks Davis <[email protected]> wrote:
>
> I wonder if AIX builds are producing SPEC1170-requesting programs
> most of the time, but not when building the autoconf code fragments?
> Otherwise I'd expect things to be failing more.
Thanks for the nudge in the right direction! I’ve looked into how do you
request SPEC1170 behavior on AIX, and you’re not going to believe me, but...
bash-5.1$ gcc mmap-full.c
bash-5.1$ export XPG_SUS_ENV=ON
bash-5.1$ ./a.out
bash-5.1$ echo $?
0
bash-5.1$ unset XPG_SUS_ENV
bash-5.1$ ./a.out
bash-5.1$ echo $?
10
So it appears to be not as trivial as “mmap on AIX has been broken for ages”,
but rather it seems that up to some version of AIX (4-5?), it used to require
unmapping the address first. After that IBM still kept it as the default
behavior, but added spec-compliant behavior to the set of behavioral changes
invoked by the XPG_SUS_ENV variable, most likely out of backwards compatibility
concerns…
The sad part is that it’s all controlled by a variable at runtime - on Solaris
in cases like that you can pass some magic defines during the build, which
would have definitively helped here, but alas… nothing one can do at the build
time, only runtime control.
It seems that Chrome people got hit by the same issue just a couple of years
ago (how many people are using AIX on their desktop to run Chrome, I wonder?!
surprisingly must be a significant number though) and what they do now is to
provide a separate implementation on AIX that would “most likely” work in the
default mode and always works in the compliant mode:
https://github.com/v8/v8/commit/3694775d080dbc13cd883b6129d66034eca1e963
Once one knows what to look for, more interesting bits can be found e.g. in
HotSpot platform support files (curiously, they took the approach of rejecting
compliant mode altogether):
https://github.com/openjdk/jdk/blob/master/src/hotspot/os/aix/os_aix.cpp
So, the bottom line, I guess, is still that the autoconf test is correct in
terms of checking for spec compliant behavior. It’s of no help to developers
who want mmap on AIX, but at least it prevents the worst.
Probably breaking the macro down as Zack has suggested would be helpful so that
MAP_FIXED behavior could be examined separately if needed, but still, for my
use case, it’s better to just get rid of mmap altogether.
All the best,
Yury