Files
rust-for-the-haters/rust-teeny-nostd/justfile
T

54 lines
1.6 KiB
Makefile

alias b := build
alias s := stat
alias z := stat-size
alias basm := build-asm
alias sasm := stat-asm
alias zasm := stat-size-asm
target := "x86_64-unknown-linux-gnu"
build:
RUSTFLAGS="\
-Zunstable-options \
\
-Zlocation-detail=none -Zfmt-debug=none \
\
-Clinker=clang -Clink-arg=-fuse-ld=lld \
-Clink-arg=-Wl,--gc-sections -Clink-arg=-Wl,--as-needed -Clink-arg=-Wl,--strip-all -Clink-arg=-Wl,--build-id=none \
\
-Cpanic=immediate-abort --remap-path-prefix=$PWD=[src] \
" cargo \
\
-Zbuild-std=core,panic_abort \
-Zbuild-std-features="optimize_for_size" \
\
b -r --target {{ target }}
# Base, does like nothing
strip --strip-all --strip-unneeded target/{{ target }}/release/rust-teeny
# BS, I don't want these
strip -R .comment -R .note.\* target/{{ target }}/release/rust-teeny
# Only OK because we don't do unwinding
strip -R .eh_frame\* target/{{ target }}/release/rust-teeny
# Not sure why .gnu.version and .gnu.hash don't break if I remove them in my machine, but that's very relative and its related to dynamic loading, but they could reduce size by `0.2 KiB`
build-asm:
clang -Wl,--gc-sections -Wl,--as-needed -Wl,--strip-all -Wl,--build-id=none -s -fuse-ld=lld -Oz same.S -o target/asm
strip --strip-all --strip-unneeded -R .comment -R .note.\* -R .eh_frame\* target/asm
stat:
stat target/{{ target }}/release/rust-teeny
stat-asm:
stat target/asm
stat-size:
stat target/{{ target }}/release/rust-teeny -c "%s" | numfmt --to=iec-i
stat-size-asm:
stat target/asm -c "%s" | numfmt --to=iec-i