Best size minimization of wpa_supplicant/wpa_cli : our -23%/-36% example and your suggestions?

Ivan Ivanov qmastery16 at gmail.com
Fri Feb 6 18:29:30 PST 2026


Dear friends, we are building wpa_supplicant / wpa_cli for Busybox and
would like our target binaries size to be as-small-as-possible. After
a lot of trial-and-error, below are our magic flags that we copy-paste
to the beginning of ./wpa_supplicant/Makefile . With this current set
of flags our builds are stable working on a live hardware and do not
segfault. If compared to a basic "-Os -s -static", for our config -
the binary size reductions are -23% (426KB vs 552KB) for
wpa_supplicant and -36% (86 KB vs 135 KB) for wpa_cli. We wonder if
its possible to squeeze more without a risk of segfaulting, please let
us know if there are any further possible improvements

LDFLAGS = -L/home/artix/my-floppy-distro/x86_64-linux-musl-cross/lib \
          -L/home/artix/my-floppy-distro/x86_64-linux-musl-cross/x86_64-linux-musl/lib
\
          -static \
          -s \
          -Wl,--gc-sections \
          -Wl,--strip-all \
          -Wl,--build-id=none \
          -Wl,-z,norelro \
          -Wl,--hash-style=sysv \
          -Wl,--no-eh-frame-hdr \
          -Wl,-z,noseparate-code \
          -Wl,--no-undefined-version \
          -Wl,--as-needed \
          -Wl,--sort-common \
          -Wl,--sort-section=alignment \
          -Wl,--compress-debug-sections=none \
          -Wl,--warn-common \
          -Wl,--fatal-warnings \
          -Wl,--discard-all \
          -Wl,--discard-locals \
          -Wl,--no-ld-generated-unwind-info \
          -Wl,--orphan-handling=place \
          -no-pie

EXTRA_CFLAGS = -static \
    -Os \
    -s \
    -ffunction-sections -fdata-sections \
    -fno-unwind-tables -fno-asynchronous-unwind-tables \
    -fno-stack-protector -fomit-frame-pointer \
    -fmerge-all-constants -fno-ident \
    -fno-math-errno \
    -fno-unroll-loops \
    -ffast-math \
    -fno-plt \
    -fvisibility=hidden \
    -fno-exceptions \
    -march=x86-64 \
    -mtune=generic \
    -fno-align-functions \
    -fno-align-jumps \
    -fno-align-loops \
    -fno-align-labels



More information about the Hostap mailing list