From 0159b2321a42286ef12e6462975d8ec5b2eb1160 Mon Sep 17 00:00:00 2001 From: xfy Date: Tue, 16 Jun 2026 17:18:33 +0800 Subject: [PATCH] fix(build): make build-linux produce a statically linked musl binary - Work around Dioxus 0.7.9 leaking getrandom_backend=wasm_js cfg into the musl server build by disabling DX's auto flag and setting it only for wasm32 in .cargo/config.toml. - Split build-linux into @client and @server steps so the server build can explicitly enable the server feature and target x86_64-unknown-linux-musl. - Configure the musl linker to use x86_64-linux-musl-gcc. --- .cargo/config.toml | 9 +++++++++ Makefile | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..1e303a1 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,9 @@ +# Workaround for Dioxus 0.7.9 leaking the wasm_js getrandom backend cfg +# into the server build. We disable DX's automatic flag in the Makefile +# and set it only for the wasm32 target here. +[target.wasm32-unknown-unknown] +rustflags = ["--cfg", "getrandom_backend=\"wasm_js\""] + +# Uncomment and adjust after installing a musl C toolchain: +[target.x86_64-unknown-linux-musl] +linker = "x86_64-linux-musl-gcc" diff --git a/Makefile b/Makefile index 5031d6b..4fecf0c 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,8 @@ build-linux: @$(MAKE) build-editor @$(MAKE) highlight-css @tailwindcss -i input.css -o public/style.css --minify - @dx build --release --debug-symbols=false --target x86_64-unknown-linux-musl + @dx build @client --release --debug-symbols=false --wasm-js-cfg false + @dx build @server --release --debug-symbols=false --target x86_64-unknown-linux-musl --wasm-js-cfg false --features server highlight-css: @cargo run --bin generate_highlight_css