Skip to content

Commit d0546f6

Browse files
committed
fix: armv7 segmentfault
1 parent 6d02e4f commit d0546f6

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ woff2 = "0.3.0"
2626
[target.'cfg(not(any(target_os = "linux", target_family = "wasm")))'.dependencies]
2727
mimalloc = "0.1"
2828

29-
[target.'cfg(target_os = "linux")'.dependencies]
29+
[target.'cfg(all(target_os = "linux", not(target_arch = "arm")))'.dependencies]
3030
mimalloc = { version = "0.1", features = ["local_dynamic_tls"] }
3131

3232
[target.'cfg(target_arch = "wasm32")'.dependencies]

js-binding.js

+25-10
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,32 @@ switch (platform) {
224224
}
225225
break
226226
case 'arm':
227-
localFileExisted = existsSync(
228-
join(__dirname, 'resvgjs.linux-arm-gnueabihf.node')
229-
)
230-
try {
231-
if (localFileExisted) {
232-
nativeBinding = require('./resvgjs.linux-arm-gnueabihf.node')
233-
} else {
234-
nativeBinding = require('@resvg/resvg-js-linux-arm-gnueabihf')
227+
if (isMusl()) {
228+
localFileExisted = existsSync(
229+
join(__dirname, 'resvgjs.linux-arm-musleabihf.node')
230+
)
231+
try {
232+
if (localFileExisted) {
233+
nativeBinding = require('./resvgjs.linux-arm-musleabihf.node')
234+
} else {
235+
nativeBinding = require('@resvg/resvg-js-linux-arm-musleabihf')
236+
}
237+
} catch (e) {
238+
loadError = e
239+
}
240+
} else {
241+
localFileExisted = existsSync(
242+
join(__dirname, 'resvgjs.linux-arm-gnueabihf.node')
243+
)
244+
try {
245+
if (localFileExisted) {
246+
nativeBinding = require('./resvgjs.linux-arm-gnueabihf.node')
247+
} else {
248+
nativeBinding = require('@resvg/resvg-js-linux-arm-gnueabihf')
249+
}
250+
} catch (e) {
251+
loadError = e
235252
}
236-
} catch (e) {
237-
loadError = e
238253
}
239254
break
240255
case 'riscv64':

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use error::Error;
3535
use usvg::NodeExt;
3636

3737
#[cfg(all(not(target_family = "wasm"), not(debug_assertions),))]
38+
#[cfg(not(all(target_os = "linux", target_arch = "arm")))]
3839
#[global_allocator]
3940
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
4041

wasm/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Generated by dts-bundle-generator v9.3.1
1+
// Generated by dts-bundle-generator v9.5.1
22

33
declare class BBox {
44
free(): void;

0 commit comments

Comments
 (0)