Skip to content

Commit 1df8b75

Browse files
committed
Force dynamic linking
1 parent 00a08d7 commit 1df8b75

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

packages/ferric/src/napi-rs.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,27 @@ export async function generateTypeScriptDeclarations({
4444
);
4545
const tempOutputPath = path.join(tempPath, outputFilename);
4646
// Call into napi.rs to generate TypeScript declarations
47-
// RUSTFLAGS: "-C link-arg=-undefined -C link-arg=dynamic_lookup",
48-
const { task } = await napiCli.build({
49-
verbose: false,
50-
dts: outputFilename,
51-
outputDir: tempPath,
52-
cwd: createPath,
53-
cargoOptions: ["--quiet"],
54-
});
55-
await task;
47+
try {
48+
assert.equal(
49+
typeof process.env.RUSTFLAGS,
50+
"undefined",
51+
"Expected RUSTFLAGS to be undefined"
52+
);
53+
// Workaround to instruct the rust compiler to not worry about undefined symbols
54+
// TODO: Figure out why this is actually necessary - it should link against sys::nodeapi
55+
process.env.RUSTFLAGS =
56+
"-C link-arg=-undefined -C link-arg=dynamic_lookup";
57+
const { task } = await napiCli.build({
58+
verbose: false,
59+
dts: outputFilename,
60+
outputDir: tempPath,
61+
cwd: createPath,
62+
cargoOptions: ["--quiet"],
63+
});
64+
await task;
65+
} finally {
66+
delete process.env.RUSTFLAGS;
67+
}
5668
// Override the banner
5769
assert(
5870
fs.existsSync(tempOutputPath),

0 commit comments

Comments
 (0)