#53316: fix: serialize the target's fs constants into the Node.js startup snapshot on cross-arch Linux builds
Description of Change
Fixes #53315
The embedded Node.js startup snapshot is generated by node_mksnapshot, a host tool built in v8_snapshot_toolchain. On the linux-arm64 and linux-armv7l builders that is an x86 binary, so DefineFsConstants() inside it was compiled against the x86 glibc headers and the snapshot captured x86 values for O_DIRECTORY, O_NOFOLLOW and O_DIRECT, the three open(2) flags arm and arm64 glibc override. Every process booted from the snapshot then asks the kernel for O_DIRECT when it meant O_DIRECTORY (EINVAL on any directory) and for O_LARGEFILE when it meant O_NOFOLLOW (symlink guards silently do nothing). Started with #52874 / #52880 / #52881, so 42.10.0, 44.0.0 and the 45 nightlies are affected; upstream Node avoids the whole class by never generating a snapshot when cross-compiling.
This PR lands in two commits so CI shows the detector working:
test:a spec that compares everything the snapshot captures (process.binding('constants'),process.binding('config'), buffer limits,process.features, arch, platform, endianness) between the snapshot-booted main process, anELECTRON_RUN_AS_NODEchild, and a renderer, which bootstraps Node.js from scratch and so holds the values this binary was built for. Plus two kernel-anchored checks for the reported symptom. Expected to fail on linux-arm64 before the fix and pass everywhere after.fix:defineNODE_SNAPSHOT_TARGET_LINUX_ARMfor the snapshot toolchain on Linux arm cross builds and havenode_constants.ccserialize the arm values. Also setNODE_USE_V8_PLATFORM=1wherever the snapshot is on: the host tool was the only libnode built with it on cross builds, so the snapshot bakedconfig.hasTracingand a requirabletrace_eventsinto a libnode built without them. Native builds already ship with it on because the toolchains coincide there.
What the detector caught on linux-arm64 with only the first commit (job): snapshot-booted process vs fresh renderer differed in exactly constants.fs.O_DIRECTORY (65536 vs 16384), O_NOFOLLOW (131072 vs 32768), O_DIRECT (16384 vs 65536) and config.hasTracing (true vs absent); errno, signals, crypto, zlib, buffer limits, features, arch and endianness all matched. open(dir, O_DIRECTORY) failed with EINVAL and open(symlink, O_NOFOLLOW) did not throw.
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
- PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, and past tense.
Release Notes
Notes: Fixed fs.constants.O_DIRECTORY, O_NOFOLLOW and O_DIRECT holding x86 values on Linux arm64 and armv7l, which made opening a directory fail with EINVAL, and made require('trace_events') behave the same on cross-compiled builds as on native ones.
Backports
Semver Impact
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron