Skip to content

aix: add required changes to build with clang#62656

Open
abmusse wants to merge 5 commits intonodejs:mainfrom
abmusse:clang-aix-2
Open

aix: add required changes to build with clang#62656
abmusse wants to merge 5 commits intonodejs:mainfrom
abmusse:clang-aix-2

Conversation

@abmusse
Copy link
Copy Markdown
Contributor

@abmusse abmusse commented Apr 9, 2026

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:

  1. Confirm the changes in this PR doesn't break gcc builds (Node.js 24, 22, 20 still use it), then merge this PR

  2. 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-init

These are now conditionally added only when Clang is not enabled.

For Clang builds, we need additional flags:

  • -fno-integrated-as
  • -fno-xl-pragma-pack

These 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 sendmmsg and 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:

16:55:13 ../deps/openssl/openssl/crypto/bio/bss_dgram.c: In function 'dgram_sendmmsg':
16:55:13 ../deps/openssl/openssl/crypto/bio/bss_dgram.c:1416:11: warning: implicit declaration of function 'sendmmsg'; did you mean 'sendmsg'? [-Wimplicit-function-declaration]
16:55:14  1416 |     ret = sendmmsg(b->num, mh, num_msg, sysflags);
16:55:14       |           ^~~~~~~~
16:55:14       |           sendmsg
16:55:14 ../deps/openssl/openssl/crypto/bio/bss_dgram.c: In function 'dgram_recvmmsg':
16:55:14 ../deps/openssl/openssl/crypto/bio/bss_dgram.c:1609:11: warning: implicit declaration of function 'recvmmsg'; did you mean 'recvmsg'? [-Wimplicit-function-declaration]
16:55:14  1609 |     ret = recvmmsg(b->num, mh, num_msg, sysflags, NULL);
16:55:14       |           ^~~~~~~~
16:55:14       |           recvmsg

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:

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 recommendation 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

5. Add weak symbol detection in create_expfile.sh

AIX export files support the weak keyword to mark weak symbols. According to IBM documentation:

Each line within an import or export file contains the name of a symbol, optionally followed by an address or a keyword. Primary keywords are svc, svc32, svc3264, svc64, syscall, syscall32, syscall3264, syscall64, symbolic, nosymbolic, nosymbolic-, list, cm, bss, internal, hidden, protected, and export. A few more keywords are weak and required, which can be used along with another keyword.

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.

abmusse added 5 commits March 30, 2026 12:47
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.
@abmusse abmusse requested a review from richardlau April 9, 2026 18:49
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/gyp
  • @nodejs/security-wg
  • @nodejs/v8-update

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run. openssl Issues and PRs related to the OpenSSL dependency. tools Issues and PRs related to the tools directory. v8 engine Issues and PRs related to the V8 dependency. labels Apr 9, 2026
#if defined(_AIX) && !defined(_AIX72)
/* AIX >= 7.2 provides sendmmsg() and recvmmsg(). */
#if defined(_AIX)
/* Force fallback to sndmsg and recvmsg */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Issues and PRs related to build files or the CI. dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run. openssl Issues and PRs related to the OpenSSL dependency. tools Issues and PRs related to the tools directory. v8 engine Issues and PRs related to the V8 dependency.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants