Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: test bindings on x86_64-unknown-linux-musl #306

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
build: |-
set -e &&
yarn build &&
llvm-strip -x *.node
strip *.node
- host: macos-14
target: aarch64-apple-darwin
build: |
Expand Down
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ pathfinder_simd = { version = "0.5.2", features = ["pf-no-simd"] }
futures = "0.3.21"
woff2 = "0.3.0"

[target.'cfg(all(not(all(target_os = "linux", target_arch = "aarch64", target_env = "musl")), not(all(target_os = "windows", target_arch = "aarch64")), not(target_arch = "wasm32")))'.dependencies]
mimalloc-rust = { version = "0.2" }
[target.'cfg(not(any(target_os = "linux", target_family = "wasm")))'.dependencies]
mimalloc = "0.1"

[target.'cfg(target_os = "linux")'.dependencies]
mimalloc = { version = "0.1", features = ["local_dynamic_tls"] }
Copy link
Member Author

@yisibl yisibl Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

迁移到 mimalloc 测试就好了?@Brooooooklyn

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你需要在 Linux 下开启 local_dynamic_tls

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原先的 mimalloc-rust 支持 local_dynamic_tls

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

支持, 但是不维护了

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢!


[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "0.2.87"
Expand Down
43 changes: 43 additions & 0 deletions js-binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,49 @@ switch (platform) {
loadError = e
}
break
case 'riscv64':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'resvgjs.linux-riscv64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./resvgjs.linux-riscv64-musl.node')
} else {
nativeBinding = require('@resvg/resvg-js-linux-riscv64-musl')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'resvgjs.linux-riscv64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./resvgjs.linux-riscv64-gnu.node')
} else {
nativeBinding = require('@resvg/resvg-js-linux-riscv64-gnu')
}
} catch (e) {
loadError = e
}
}
break
case 's390x':
localFileExisted = existsSync(
join(__dirname, 'resvgjs.linux-s390x-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./resvgjs.linux-s390x-gnu.node')
} else {
nativeBinding = require('@resvg/resvg-js-linux-s390x-gnu')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on Linux: ${arch}`)
}
Expand Down
9 changes: 2 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,9 @@ mod options;
use error::Error;
use usvg::NodeExt;

#[cfg(all(
not(target_arch = "wasm32"),
not(debug_assertions),
not(all(target_os = "windows", target_arch = "aarch64")),
not(all(target_os = "linux", target_arch = "aarch64", target_env = "musl")),
))]
#[cfg(all(not(target_family = "wasm"), not(debug_assertions),))]
#[global_allocator]
static ALLOC: mimalloc_rust::GlobalMiMalloc = mimalloc_rust::GlobalMiMalloc;
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;

#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
Expand Down
Binary file modified wasm/index_bg.wasm
Binary file not shown.
Loading