#54016: build: fix native addon cross-compilation
Description of Change
Linux ARM64 cross-builds fail while rebuilding the object-wrap test addon: the linker reports that the target libc++ archives are incompatible with elf64-x86-64.
The addon toolchain introduced in #53390 selects Chromium clang and the target build's libc++ libraries but supplies no cross-compilation target or sysroot. npm_config_arch=arm64 configures node-gyp, not clang, so the compiler and linker still default to x64 on an x64 worker.
Pass the requested target triple and Electron sysroot to C/C++ compilation and linking, preserving caller flags and reporting missing cross sysroots explicitly.
Related to #53390.
CC @deepak1556 @MarshallOfSound as reviewers/stakeholders of 53390.
CC @mlaurencin as downstream stakeholder
Validation
- Focused Node checks against the actual helper cover the original missing-target behavior, four cross targets, caller flags, native equivalence without overrides, environment-variable casing, compiler fallbacks, optional libc++abi, and missing-sysroot errors.
- Chromium clang
-###confirms target and sysroot forwarding for ARM64, ARM, ia32, and x64 compilation and linking. This is print-only validation, not a successful cross-build. - Scoped JavaScript lint, formatting, whitespace checks, and pre-commit hooks pass.
- The affected helper is identical on current
42-x-y,43-x-y,44-x-y, and45-x-y; the patch applies cleanly to all four, matching #53390's backport coverage. - Full ARM64 compile/link and runtime tests were not run: the local checkout lacks the ARM64 sysroot and target build artifacts.
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
-
npm testpasses
Release Notes
Notes: none
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