aix: add required changes to build with clang#62656
aix: add required changes to build with clang#62656abmusse wants to merge 6 commits intonodejs:mainfrom
Conversation
Some gcc flags dont work on clang: -mfprnd -mno-popcntb -fno-extern-tls-init So now we conditionally add them when clang is not enabled Also for clang builds we need to pass some additonal flags: -fno-integrated-as -fno-xl-pragma-pack These flags are discuessed in: https://chromium-review.googlesource.com/c/chromium/src/+/7120638
to header files not shipping declarations. This seems like a bug in AIX header files because the examples show including the headers but upon inspecting these files there are no declarations for sendmmsg and others: https://www.ibm.com/docs/en/aix/7.2.0?topic=s-sendmmsg-subroutine For now we can claim to not have these functions. Alternatively we can declare these ourselves if we are AIX 7.2 or newer. The actual functions look to be available in libc. GCC also has the same implicit function declaration but it happily moves forward. Clang started making this an explict error in clang 16: https://www.redhat.com/en/blog/new-warnings-and-errors-clang-16
Original commit message: aix: add required changes to build with clang Change-Id: Icc78c58831306aa2f227843b0b4ec2321585fa64 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7107287 Reviewed-by: Toon Verwaest <verwaest@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/main@{#104364}
visibility for symbols.
Without these changes we are getting back linker errors
AIX with clang builds:
```text
ld: 0711-407 ERROR: Symbol [SYMBOL_NAME]
Visibility is not allowed on a reference to an imported symbol.
```
Not including hidden symbols in the export files matches the
recomendation by XLC documentation:
> When using export lists, it is not recommended to put symbols with
> hidden visibility in the lists.
ref: https://www.ibm.com/docs/en/openxl-c-and-cpp-aix/17.1.4?topic=libraries-symbol-exports-visibilities
in create_expfile.sh AIX export files support the `weak` keyword to mark weak symbols. ref: https://www.ibm.com/docs/en/aix/7.2.0?topic=l-ld-command#ld__a3119106d This helps preserve C++ weak symbol semantics and preventing potential linker conflicts.
|
Review requested:
|
| #if defined(_AIX) && !defined(_AIX72) | ||
| /* AIX >= 7.2 provides sendmmsg() and recvmmsg(). */ | ||
| #if defined(_AIX) | ||
| /* Force fallback to sndmsg and recvmsg */ |
There was a problem hiding this comment.
This needs to be made upstream as otherwise it's going to get reverted every OpenSSL upgrade we take: https://github.com/openssl/openssl/blob/72d5e8dcd2977234e47e840d2173917daa8bb0fa/crypto/bio/bss_dgram.c#L71-L72
There was a problem hiding this comment.
I found a similar issue upstream: openssl/openssl#23751
Someone there mentioned that the headers for sendmmsg recvmmsg are in another location:
#include <net/proto_uipc.h>
I will open up a PR on upstream and see what maintainers say.
There was a problem hiding this comment.
I see that that documentation claims its available here: https://www.ibm.com/docs/en/aix/7.2.0?topic=s-sendmmsg-subroutine
(Starting in AIX 7.2)
Following those docs you get back implicit function declaration for it.
You can re-recreate the behavior with this simple c program:
#include <sys/types.h>
#include <sys/socketvar.h>
#include <sys/socket.h>
#include <net/proto_uipc.h>
int main() {
struct mmsghdr msgs[1];
/* This causes implicit declaration warning - no header declares sendmmsg */
sendmmsg(0, msgs, 1, 0);
return 0;
}Clang:
$ /opt/clang+llvm-20.1.7-powerpc64-ibm-aix-7.2/bin/clang -o aix-sendmmsg-issue.out aix-sendmmsg-issue.c
aix-sendmmsg-issue.c:23:5: error: call to undeclared function 'sendmmsg'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
23 | sendmmsg(0, msgs, 1, 0);
| ^
aix-sendmmsg-issue.c:23:5: note: did you mean 'nsendmsg'?
/usr/include/sys/socket.h:645:9: note: 'nsendmsg' declared here
645 | ssize_t sendmsg(int, const struct msghdr *, int);
| ^
/usr/include/sys/socket.h:174:25: note: expanded from macro 'sendmsg'
174 | #define sendmsg nsendmsg
| ^
1 error generated.
GCC:
$ /opt/freeware/bin/gcc-12 -o aix-sendmmsg-issue.out aix-sendmmsg-issue.c
aix-sendmmsg-issue.c: In function 'main':
aix-sendmmsg-issue.c:23:5: warning: implicit declaration of function 'sendmmsg'; did you mean 'sendmsg'? [-Wimplicit-function-declaration]
23 | sendmmsg(0, msgs, 1, 0);
| ^~~~~~~~
| sendmsg
Even including net/proto_uipc.h it fails too, upon further investigation looks like everything in that header is wrapped in #ifdef _KERNEL so it seems like sendmmsg / recvmmsg is not really usuable unless _KERNEL is defined.
With the above information, I'm now going forward with my changes in the PR on upstream openssl to just fall back to sendmsg and recvmsg.
I will try to open an issue with AIX team about sendmmsg not being available.
There was a problem hiding this comment.
Opened Upstream PR: openssl/openssl#30832
AIX header files don't properly expose sendmmsg/recvmmsg function declarations. Disable these functions to avoid implicit declaration errors with clang 16+. This issue was discovered when building Node.js with clang ref: nodejs/node#62656 Fixes: openssl#30806
Commit Queue failed- Loading data for nodejs/node/pull/62656 ✔ Done loading data for nodejs/node/pull/62656 ----------------------------------- PR info ------------------------------------ Title aix: add required changes to build with clang (#62656) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch abmusse:clang-aix-2 -> nodejs:main Labels build, v8 engine, openssl, tools, needs-ci, dependencies Commits 6 - build: aix add conditonal flags for clang builds - openssl: fix aix implicit declaration due ... - deps: V8: cherry-pick 7107287 - aix: fix export script to filter hidden ... - aix: Add weak symbol detection ... - fixup! create_expfile.sh add -r to read Committers 2 - Abdirahim Musse <33973272+abmusse@users.noreply.github.com> - GitHub <noreply@github.com> PR-URL: https://github.com/nodejs/node/pull/62656 Refs: https://ci.nodejs.org/job/node-test-commit-aix/nodes=aix72-power9/62022/consoleFull Refs: https://www.ibm.com/docs/en/aix/7.2.0?topic=s-sendmmsg-subroutine Refs: https://www.ibm.com/docs/en/openxl-c-and-cpp-aix/17.1.4?topic=libraries-symbol-exports-visibilities Refs: https://www.ibm.com/docs/en/aix/7.2.0?topic=l-ld-command#ld__a3119106d Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/62656 Refs: https://ci.nodejs.org/job/node-test-commit-aix/nodes=aix72-power9/62022/consoleFull Refs: https://www.ibm.com/docs/en/aix/7.2.0?topic=s-sendmmsg-subroutine Refs: https://www.ibm.com/docs/en/openxl-c-and-cpp-aix/17.1.4?topic=libraries-symbol-exports-visibilities Refs: https://www.ibm.com/docs/en/aix/7.2.0?topic=l-ld-command#ld__a3119106d Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> -------------------------------------------------------------------------------- ℹ This PR was created on Thu, 09 Apr 2026 18:49:46 GMT ✔ Approvals: 2 ✔ - Richard Lau (@richardlau) (TSC): https://github.com/nodejs/node/pull/62656#pullrequestreview-4100747583 ✔ - Michaël Zasso (@targos) (TSC): https://github.com/nodejs/node/pull/62656#pullrequestreview-4103825783 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2026-04-14T21:31:42Z: https://ci.nodejs.org/job/node-test-pull-request/72695/ - Querying data for job/node-test-pull-request/72695/ ✔ Build data downloaded ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ No git cherry-pick in progress ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/main up to date... From https://github.com/nodejs/node * branch main -> FETCH_HEAD ✔ origin/main is now up-to-date - Downloading patch for 62656 From https://github.com/nodejs/node * branch refs/pull/62656/merge -> FETCH_HEAD ✔ Fetched commits as ed05549e5bef..02197619c997 -------------------------------------------------------------------------------- Auto-merging common.gypi [main 7b2dd32e20] build: aix add conditonal flags for clang builds Author: Abdirahim Musse <33973272+abmusse@users.noreply.github.com> Date: Mon Mar 30 12:47:43 2026 -0500 2 files changed, 30 insertions(+), 4 deletions(-) Auto-merging deps/openssl/openssl/crypto/bio/bss_dgram.c [main be685c25c5] openssl: fix aix implicit declaration due ... Author: Abdirahim Musse <33973272+abmusse@users.noreply.github.com> Date: Mon Mar 30 12:55:12 2026 -0500 1 file changed, 2 insertions(+), 2 deletions(-) Auto-merging common.gypi [main 3df1ffc88d] deps: V8: cherry-pick 7107287 Author: Abdirahim Musse <33973272+abmusse@users.noreply.github.com> Date: Mon Mar 30 13:21:43 2026 -0500 6 files changed, 33 insertions(+), 12 deletions(-) [main eec11ec016] aix: fix export script to filter hidden ... Author: Abdirahim Musse <33973272+abmusse@users.noreply.github.com> Date: Thu Apr 2 13:05:48 2026 -0500 1 file changed, 24 insertions(+), 7 deletions(-) [main 16baaf4cf9] aix: Add weak symbol detection ... Author: Abdirahim Musse <33973272+abmusse@users.noreply.github.com> Date: Fri Apr 3 11:50:39 2026 -0500 1 file changed, 44 insertions(+), 25 deletions(-) [main b21684d322] fixup! create_expfile.sh add -r to read Author: Abdirahim Musse <33973272+abmusse@users.noreply.github.com> Date: Mon Apr 13 10:56:41 2026 -0500 1 file changed, 1 insertion(+), 1 deletion(-) ✔ Patches applied There are 6 commits in the PR. Attempting autorebase. (node:375) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated. (Use `node --trace-deprecation ...` to show where the warning was created) Rebasing (2/12) Executing: git node land --amend --yes --------------------------------- New Message ---------------------------------- build: aix add conditonal flags for clang buildshttps://github.com/nodejs/node/actions/runs/24448445285 |
This PR enables building Node.js on AIX with Clang by addressing several issues.
The game plan I have in mind to get AIX building with clang:
Confirm the changes in this PR doesn't break gcc builds (Node.js 24, 22, 20 still use it), then merge this PR
After this PR gets merged, update select compiler to use clang for Node.js 26+ builds
(I have a draft PR for that here: aix: select clang for Node.26+ builds build#4286)
Changes
1. Add conditional flags for Clang builds
Some GCC flags don't work on Clang:
-mfprnd-mno-popcntb-fno-extern-tls-initThese are now conditionally added only when Clang is not enabled.
For Clang builds, we need additional flags:
-fno-integrated-as-fno-xl-pragma-packThese flags are discussed in: https://chromium-review.googlesource.com/c/chromium/src/+/7120638
2. Fix OpenSSL implicit declaration errors
AIX header files don't ship declarations for
sendmmsgand related functions, despite documentation showing they should be included. This appears to be a bug in AIX header files.GCC tolerates implicit function declarations, but Clang 16+ treats them as errors:
https://www.redhat.com/en/blog/new-warnings-and-errors-clang-16
example:
ref: https://ci.nodejs.org/job/node-test-commit-aix/nodes=aix72-power9/62022/consoleFull
For now, we claim to not have these functions. The actual functions are available in libc, so an alternative would be to declare them ourselves for AIX 7.2+.
Ref: https://www.ibm.com/docs/en/aix/7.2.0?topic=s-sendmmsg-subroutine
3. Cherry-pick V8 commit for AIX Clang support
Cherry-picked V8 commit 7107287 which adds required changes to build V8 with Clang on AIX.
Original commit: https://chromium-review.googlesource.com/c/v8/v8/+/7107287
4. Filter hidden visibility symbols from export script
Without filtering HIDDEN symbols, AIX Clang builds fail with linker errors:
Not including hidden symbols in the export files matches the recommendation by XLC documentation:
Ref: https://www.ibm.com/docs/en/openxl-c-and-cpp-aix/17.1.4?topic=libraries-symbol-exports-visibilities
5. Add weak symbol detection in create_expfile.sh
AIX export files support the
weakkeyword to mark weak symbols. According to IBM documentation:ref: https://www.ibm.com/docs/en/aix/7.2.0?topic=l-ld-command#ld__a3119106d
This helps preserve C++ weak symbol semantics and preventing potential linker conflicts.