Skip to content

Commit 1269aa0

Browse files
authored
Fix ferric example (#333)
* Prevent weak-node-api from being stripped when building with ferric * Updating napi-rs crates * Pinning napi and napi-sys
1 parent 441dcc4 commit 1269aa0

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

packages/ferric-example/Cargo.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,21 @@ license = "MIT"
88
crate-type = ["cdylib"]
99

1010
[dependencies.napi]
11-
version = "3.1"
12-
default-features = false
11+
version = "=3.4.0"
1312
# see https://nodejs.org/api/n-api.html#node-api-version-matrix
13+
default-features = false
1414
features = ["napi3"]
1515

1616
[dependencies.napi-derive]
17-
version = "3.1"
17+
version = "3.3.0"
1818
features = ["type-def"]
1919

20+
# See https://github.com/callstackincubator/react-native-node-api/issues/331
21+
[dependencies.napi-sys]
22+
version = "=3.0.1"
23+
2024
[build-dependencies]
21-
napi-build = "2"
25+
napi-build = "2.2.4"
2226

2327
[profile.release]
2428
lto = true

packages/ferric/src/cargo.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,9 @@ export function getTargetEnvironmentVariables({
221221
CARGO_ENCODED_RUSTFLAGS: [
222222
"-L",
223223
weakNodeApiPath,
224-
"-l",
225-
"weak-node-api",
224+
"-C",
225+
// Passing --no-as-needed to prevent weak-node-api from being optimized away
226+
"link-arg=-Wl,--push-state,--no-as-needed,-lweak-node-api,--pop-state",
226227
].join(String.fromCharCode(0x1f)),
227228
CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER: joinPathAndAssertExistence(
228229
toolchainBinPath,

0 commit comments

Comments
 (0)