Commit ddaea6f
authored
Add gnu->musl loader fallback via @napi-rs/cli patch
Mirror PR #7's approach (which added the linux-ia32-gnu branch by patching
the napi-rs loader template) and add a gnu->musl fallback the same way,
instead of the runtime regex string-rewrite that was in
strip-binding-fallbacks.js.
The generated loader picks gnu vs musl purely by libc *family* (isMusl()),
with no glibc-version check. On a glibc host whose system glibc is older
than what our gnu prebuild was linked against, requiring
./index.linux-<arch>-gnu.node throws (e.g. GLIBC_2.33 not found) and the
loader gives up — even though we also bundle a statically-linked musl
binary that runs fine on glibc hosts.
This patches @napi-rs/cli's requireNative() template so the linux x64 and
arm64 gnu (else) branches also try ./index.linux-<arch>-musl.node after the
gnu require fails, using the generator's own requireTuple() helper so the
emitted code matches the generated style exactly. Because the fallback is
baked into the template at install time, the generated binding.js comes out
correct on every build regardless of how many times the build runs —
avoiding the docker+host double-pass idempotency problem that affected the
regex post-processor.1 parent 0140d1a commit ddaea6f
1 file changed
Lines changed: 51 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
6 | 21 | | |
7 | 22 | | |
8 | 23 | | |
| |||
12 | 27 | | |
13 | 28 | | |
14 | 29 | | |
15 | | - | |
| 30 | + | |
16 | 31 | | |
17 | 32 | | |
18 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
19 | 49 | | |
20 | 50 | | |
21 | 51 | | |
| |||
25 | 55 | | |
26 | 56 | | |
27 | 57 | | |
28 | | - | |
| 58 | + | |
29 | 59 | | |
30 | 60 | | |
31 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
32 | 77 | | |
33 | 78 | | |
34 | 79 | | |
| |||
0 commit comments