Skip to content

src: update node.cc and related for z/OS - #66569

Open
gabylb wants to merge 2 commits into
nodejs:mainfrom
gabylb:zos-src
Open

gabylb wants to merge 2 commits into
nodejs:mainfrom
gabylb:zos-src

Conversation

@gabylb

@gabylb gabylb commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Updates here apply to z/OS only.

  • Add new src/node_zos.h and src/node_zos.cc, used by src/node.cc and src/inspector_agent.cc.
  • Add new src/zos_setlibpath.cc and link its .o directly into node, so that the __setlibpath object's constructor finds libnode.so and adds its directory to LIBPATH, allowing it to be loaded.
  • Pass -Wl,-bedit=no when linking libnode.so to reduce its size.
  • Use z/OS-specific signal handling, as signals on z/OS must be handled in a dedicated thread:
    • All signals are blocked on the main thread. A dedicated thread, created with every signal blocked, installs its own alternate signal stack and then unblocks them, so no signal is delivered on a thread without one.
    • The inspector's SIGUSR1 handling uses its own thread for the same reason (src/inspector_agent.cc).
    • SA_ONSTACK and SA_SIGINFO are used for handlers so that they run on the alternate stack, which keeps them from interfering with the z/OS Language Environment (LE), and so that sa_sigaction is honored.
  • Force the V8 flag --nohard_abort: a trap with V8 frames on the stack ends with SIGKILL on z/OS because those frames lack XPLINK metadata, so LE can't traverse the stack.
  • Register Node.js for Tailored Fit Pricing at startup.
  • Include display of the zoslib build version.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/gyp
  • @nodejs/startup

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels Oct 7, 2026
@inoway46

inoway46 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for working on this! The commit and lint checks are currently failing. Have you also verified that this builds successfully locally?

Please follow the guide below:
https://github.com/nodejs/node/blob/main/doc/contributing/pull-requests.md

@gabylb
gabylb marked this pull request as draft October 7, 2026 15:19
@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.51%. Comparing base (7ed1ca0) to head (fc5d6c7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66569      +/-   ##
==========================================
- Coverage   90.51%   90.51%   -0.01%     
==========================================
  Files         805      805              
  Lines      285878   285878              
  Branches    55200    55201       +1     
==========================================
- Hits       258756   258754       -2     
- Misses      17214    17223       +9     
+ Partials     9908     9901       -7     
Files with missing lines Coverage Δ
src/inspector_agent.cc 83.33% <ø> (-0.13%) ⬇️
src/node.cc 79.16% <ø> (-0.11%) ⬇️

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gabylb

gabylb commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for working on this! The commit and lint checks are currently failing. Have you also verified that this builds successfully locally?

Please follow the guide below: https://github.com/nodejs/node/blob/main/doc/contributing/pull-requests.md

Hello Yuya. This PR is part of a number of PRs to be opened for the z/OS port; in our environment, which includes all the port, node builds successfully.

@gabylb
gabylb marked this pull request as ready for review October 7, 2026 19:05
Comment thread src/node.cc Resolved
@inoway46

Copy link
Copy Markdown
Contributor

The QUIC build failure has been fixed in #66603. Rebasing onto the latest main should resolve it.

@gabylb
gabylb force-pushed the zos-src branch 2 times, most recently from c903803 to c484ca3 Compare October 12, 2026 14:27
@gabylb
gabylb requested a review from addaleax October 12, 2026 14:30
Comment thread src/node_zos.h Resolved
Comment thread src/zos_setlibpath.cc Resolved

@jasnell jasnell left a comment

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.

The license of the zos_setlibpath.cc file needs to be clarified before this can be merged.

- Add new src/node_zos.h and src/node_zos.cc, used by src/node.cc.
- Add new src/zos_setlibpath.cc and link its .o directly into node
  so the __setlibpath object's constructor finds libnode.so
  and add its path to LIBPATH, so it can be loaded.
- Pass '-Wl,-bedit=no' when linking libnode.so to reduce its size.
- Use z/OS specific signal handling logic, as signals on z/OS must be
  handled in a dedicated thread.
- Force V8 flag --nohard_abort due to absence of XPLINK headers in JS
  generated code.
- Include display of zoslib build version.

Signed-off-by: Gaby Baghdadi <baghdadi@ca.ibm.com>
@gabylb
gabylb marked this pull request as ready for review November 27, 2026 20:18
@gabylb
gabylb requested a review from jasnell November 27, 2026 20:18
Address review comments:
- Add comments explaining why the z/OS-specific code is needed:
  the SIGABRT handler (see zosSignalExit()) and the --nohard_abort V8
  flag.
- Remove the copyright headers from the new node_zos.{h,cc} and
  zos_setlibpath.cc files.

Other changes:
- Create the z/OS signal handler thread after blocking all signals on
  the main thread, so it starts with every signal blocked. It installs
  its own alternate signal stack before unblocking them, so no signal
  can be delivered on a thread without one.
- Remove zosIgnorePipeChildSignals(). All signals are blocked on the
  main thread, and SIGPIPE is already ignored by ResetSignalHandlers().
- Zero-initialize the struct sigaction in zosSignalExit().
- Check the result of sigaltstack() and report alternate stack setup
  failures in zosStart().
- Check pthread_cancel() for any non-zero return, not just -1.
- Do not append directories to LIBPATH if already present.
- Handle SIGUSR1 for the inspector on z/OS, where the main thread blocks
  all signals.
- Call RegisterProduct() from zosStart() so that Node.js is registered
  for Tailored Fit Pricing.

Assisted-by: IBM Bob

Signed-off-by: Gaby Baghdadi <baghdadi@ca.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants