Commit 7b5eb40
committed
fix: override host-specific variables when reading headers config.gypi
The official Node release headers tarball is a single universal artifact
shipped to all platforms, but its embedded config.gypi reflects the build
host of the Node release-engineering machine (currently Linux x64 / GCC).
When a consumer on a different host inherits it verbatim via --disturl or
--nodedir (PR #2497), host-specific fields end up wrong:
* host_arch is x64 even on arm64 hosts
* clang is 0 even when the local toolchain is clang
* llvm_version, xcode_version, arm_fpu, gas_version, shlib_suffix
similarly reflect the build farm rather than the local host
The most visible symptom is on macOS arm64, where clang=0 silently
drops the `clang==1` branches in common.gypi (notably -std=gnu++20).
C++ compilation then falls back to C++03 and node-addon-api/napi.h
fails with "no template named initializer_list", "unknown type name
constexpr", etc.
Affected scope: anyone with disturl set in .npmrc or env (China mirrors
such as npmmirror/taobao, self-hosted Nexus/JFrog with disturl rewriting,
Electron projects via electron-rebuild). See electron/rebuild#1209 for
the original report.
Override only the host-specific variables from process.config after
parsing the headers' config.gypi. PR #2497's intent is preserved:
target build config (v8 features, bundled vs shared deps,
node_module_version, etc.) still comes from the headers tarball; only
host fields are corrected. Verified that the fix is a no-op on Linux
x64 (all 7 fields already match between cache and process.config) and
necessary on macOS arm64 (all 7 fields mismatched).
Refs: #2497, electron/rebuild#1209
Signed-off-by: iFwu <[email protected]>
Made-with: Cursor1 parent 19da158 commit 7b5eb40
3 files changed
Lines changed: 95 additions & 1 deletion
File tree
- lib
- test
- fixtures/nodedir-mismatched-host/include/node
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
18 | 52 | | |
19 | 53 | | |
20 | 54 | | |
| |||
25 | 59 | | |
26 | 60 | | |
27 | 61 | | |
28 | | - | |
| 62 | + | |
29 | 63 | | |
30 | 64 | | |
31 | 65 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
55 | 101 | | |
56 | 102 | | |
57 | 103 | | |
| |||
0 commit comments