dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

Subsecond does not respect rustflags cfg settings from .cargo/config.toml (getrandom fails to build)

Open niclashoyer opened this issue 6 months ago • 2 comments

Problem

I thought that #4146 was the same issue and that #4174 would fix the issue with getrandom, but the build still fails for me with 0.7.0-alpha.1 when using linker settings in .cargo/config.toml:

[target.wasm32-unknown-unknown]
rustflags = ['--cfg', 'getrandom_backend="wasm_js"']

Steps To Reproduce

git clone https://github.com/niclashoyer/dioxus-bug.git
cd dioxus-bug
cargo binstall --version "0.7.0-alpha.1" dioxus-cli --root .
bin/dx serve --hot-patch

(bin/dx serve without subsecond works)

Expected behavior

The build should work with getrandom enabled and hot patching working.

Environment:

  • Dioxus version: 0.7.0-alpha.1
  • Rust version: 1.87.0
  • OS info: Fedora Linux 42
  • App platform: web/fullstack

niclashoyer avatar Jun 01 '25 23:06 niclashoyer

Do you know what this actually passes to the linker? Its possible the actual resulting argument just needs to be added to the list of the ones getting passed through, like i did for -fuse-ld in:

  • #4222

if it helps: i used syscall tracing and /proc//cmdline to dump the rather lengthy linker commands during writing that, since adding logging output to dx code didn't work reliably (likely because dx ends up being called multiple times during hotpatch)

laundmo avatar Jun 12 '25 10:06 laundmo

Upon digging a bit further, it seems that these settings from RUSTFLAGS are not passed to the linker at all. I think these are just passed to rustc: https://doc.rust-lang.org/cargo/reference/config.html#buildrustflags

For getrandom to build, I think rustc just needs this one cfg setting, so that the conditional compilation triggers correctly to include the correct backend. I'll change the title of the issue.

niclashoyer avatar Jun 12 '25 10:06 niclashoyer