Skip to content

Commit

Permalink
fix: armv7 segmentfault
Browse files Browse the repository at this point in the history
  • Loading branch information
yisibl committed May 28, 2024
1 parent 9b957d9 commit 983df4c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ woff2 = "0.3.0"
[target.'cfg(not(any(target_os = "linux", target_family = "wasm")))'.dependencies]
mimalloc = "0.1"

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

[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand Down
35 changes: 25 additions & 10 deletions js-binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,32 @@ switch (platform) {
}
break
case 'arm':
localFileExisted = existsSync(
join(__dirname, 'resvgjs.linux-arm-gnueabihf.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./resvgjs.linux-arm-gnueabihf.node')
} else {
nativeBinding = require('@resvg/resvg-js-linux-arm-gnueabihf')
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'resvgjs.linux-arm-musleabihf.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./resvgjs.linux-arm-musleabihf.node')
} else {
nativeBinding = require('@resvg/resvg-js-linux-arm-musleabihf')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'resvgjs.linux-arm-gnueabihf.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./resvgjs.linux-arm-gnueabihf.node')
} else {
nativeBinding = require('@resvg/resvg-js-linux-arm-gnueabihf')
}
} catch (e) {
loadError = e
}
} catch (e) {
loadError = e
}
break
case 'riscv64':
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use error::Error;
use usvg::NodeExt;

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

Expand Down
2 changes: 1 addition & 1 deletion wasm/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated by dts-bundle-generator v9.3.1
// Generated by dts-bundle-generator v9.5.1

declare class BBox {
free(): void;
Expand Down

0 comments on commit 983df4c

Please sign in to comment.