git clone https://github.com/shadr/leptos-subsecond-cli-temp
cd leptos-subsecond-cli-temp
RUST_LOG=debug LEPTOS_OUTPUT_NAME=your-package cargo run --release -- --manifest-path ../your-project/Cargo.toml leptos --package your-package --server-bin your-server-bin --server-features ssr --lib-features hydrate --server-no-default-features --lib-no-default-featuresCurrently there is no file watcher, so to hot reload or do a full rebuild you would need to enter "r" or "R" characters into stdin respectively.
Here I outline my understanding of how fat and thin builds work:
Fat builds are big and slow, we compile every dependency into a shared library without removing any dead code
- Clear fingerprints for the top-level crate to trigger rebuild (this will be needed in step 3)
- Run
cargo rustcwith needed flags and env variables-Clinker=dxwe passdxas a linker wrapper to store linker arguments to a file-Clink-dead-codedo not omit dead code when linkingRUSTC_WRAPPERdxwe passdxalso as a rustc wrapper to store its argumentsDX_RUSTCpath to a file where to store rustc argumentsDX_LINK_ARGS_FILEpath to a file where to store linker arguments- a few link arguments for handling wasm builds
- Link fat build, take into account every
.ofile in every rlib - Read rustc arguments from a
DX_RUSTCfile - Create a HotpatchModuleCache with compiled binary
- (Optional) run the binary, binary should tell the build tool its aslr reference (e.g. passing it when connecting to websocket)
Thin builds are uses rustc directly
- Build crate object file with rustc
-Clinker=dxused to pass/filter custom linker argumentsDX_LINK_ARGS_FILEfile path to read saved linker arguments from
- Link using custom linker setup and previously saved aslr reference and rustc arguments to generate a patch library file
- Create a jump table using HotpatchModuleCache
- Send the jump table to the connected clients
Here is links to build related functions in original dioxus-cli code:
- BuildRequest::build - do either fat or thin build including linking
- BuildRequest::cargo_build - create a
cargo rustcorrustccommand and run it with setted env variables and arguments, if it is a fat build also link the binary - BuildRequest::run_fat_link - link fat binary
- BuildRequest::write_patch - custom linker setup for thin builds to generate a patch file
- AppBuilder::hotpatch - using compiled thin binary and HotpatchModuleCache creates a jump table and sends it to the running binaries
- create_jump_table - creates a jump table, this whole file can be copied without any modifications, it doesn't have any dependencies on cli code