Skip to content

Commit 2d0a5dc

Browse files
authored
fix: fix building with --[fully|partly]-static and --shared-openssl on Node.js 20 (#42)
1 parent 3411ce8 commit 2d0a5dc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,23 @@ async function compileNode (
210210
configure.push('--link-module', module);
211211
}
212212
await spawnBuildCommand(configure, options);
213+
if (configure.includes('--fully-static') || configure.includes('--partly-static')) {
214+
// https://github.com/nodejs/node/issues/41497#issuecomment-1013137433
215+
for (const file of [
216+
'out/tools/v8_gypfiles/gen-regexp-special-case.target.mk',
217+
'out/test_crypto_engine.target.mk'
218+
]) {
219+
const target = path.join(sourcePath, file);
220+
try {
221+
await fs.stat(target);
222+
} catch {
223+
continue;
224+
}
225+
let source = await fs.readFile(target, 'utf8');
226+
source = source.replace(/-static/g, '');
227+
await fs.writeFile(target, 'utf8');
228+
}
229+
}
213230

214231
const make = ['make', ...makeArgs];
215232
if (!make.some((arg) => /^-j/.test(arg))) { make.push(`-j${cpus}`); }

0 commit comments

Comments
 (0)