Today I Learned

tags


2024/05/04

That a go.work file can point to local “main modules” used for minimum-version selection. go will maintain a separate go.work.sum file with the checksums of the workspace’s dependencies. go work {init,use,edit} manages the work-files. $GOWORK pointing to a file named like *.work can switch between multiple workspace files. See https://go.dev/ref/mod#workspaces; the syntax of *.work files is roughly equivalent to the syntax in go.mod.


That none of the following options ensure unused debug info is not included in rust wasm output:

[profile.release]
opt-level = "z"
lto = true
codegen-units = 1
panic = "abort"

Commenting each line and rebuilding with --target=wasm32-unknown-unknown --release resulted in 0% change in output .wasm size. In each experiment, twiggy garbage ./target/wasm*/release/my_lib.wasm reported

 Bytes  │ Size % │ Garbage Item
────────┼────────┼─────────────────────────────────────────
 280220 ┊ 33.30% ┊ custom section '.debug_str'
 181364 ┊ 21.55% ┊ custom section '.debug_info'
 159353 ┊ 18.94% ┊ custom section '.debug_line'
  96881 ┊ 11.51% ┊ custom section '.debug_pubnames'
  87936 ┊ 10.45% ┊ custom section '.debug_ranges'
   2030 ┊  0.24% ┊ custom section '.debug_abbrev'
    342 ┊  0.04% ┊ custom section '.debug_pubtypes'
     67 ┊  0.01% ┊ custom section 'producers'
     28 ┊  0.00% ┊ custom section 'target_features'
 808221 ┊ 96.05% ┊ Σ [9 Total Rows]

I cut those sections out using the 2-year-old recipe from https://github.com/Xe/x/blob/c87eb51e0afe78a958eecaffb83318f91c6f78dd/web/mastosan/README.md:

wasm-opt -oZ ...
wasm-snip \
  --skip-producers-section \
  --snip-rust-panicking-code \
  --snip-rust-fmt-code \
  ...