build: musl static by default, glibc optional, strip the release binary

This commit is contained in:
2026-09-09 16:10:17 -04:00
parent e5c6c8d3f0
commit e52e97a825
2 changed files with 35 additions and 0 deletions
+6
View File
@@ -3,10 +3,16 @@ AM_CFLAGS = -Wall -Wextra -O2 -pthread
bin_PROGRAMS = fastwc
fastwc_SOURCES = src/main.c
# configure.ac fills this in with -static when the default musl toolchain
# was selected (empty for --enable-glibc builds).
fastwc_LDFLAGS = @STATIC_LDFLAGS@
# Release build consumed by benchmarks/ (expects bin/release/fastwc).
# Strip the copy, not the tree binary: the debug build stays debuggable.
release: all
$(MKDIR_P) bin/release
cp -f fastwc bin/release/fastwc
$(STRIP) bin/release/fastwc
# Convenience: build the release binary, then run every benchmark suite.
bench: release
+29
View File
@@ -2,9 +2,38 @@ AC_PREREQ([2.69])
AC_INIT([fastwc], [0.1.0], [], [fastwc])
AC_CONFIG_SRCDIR([src/main.c])
# Build flavor: --enable-glibc links dynamically against the system libc
# (respecting CC, whatever it is). The default is a fully static musl
# binary, preferring musl-gcc even when CC is set in the environment,
# since removing ld.so from startup is exactly what the tiny-file
# benchmark races hinge on.
AC_ARG_ENABLE([glibc],
[AS_HELP_STRING([--enable-glibc],
[link dynamically against the system libc (respects CC) instead of the default static musl])],
[enable_glibc=$enableval], [enable_glibc=no])
STATIC_LDFLAGS=
if test "x$enable_glibc" = xno; then
# Static musl is the default toolchain. Fall back to the system
# compiler (dynamic link) only when no musl compiler is installed.
AC_PATH_PROGS([MUSL_CC], [musl-gcc x86_64-linux-musl-gcc])
if test -n "$MUSL_CC"; then
CC="$MUSL_CC"
STATIC_LDFLAGS="-static"
fi
fi
AC_PROG_CC
AC_CHECK_TOOL([STRIP], [strip], [:])
AC_USE_SYSTEM_EXTENSIONS
AM_INIT_AUTOMAKE([foreign subdir-objects])
AS_IF([test "x$enable_glibc" = xyes],
[AC_MSG_NOTICE([fastwc: glibc build requested, using $CC])],
[AS_IF([test -n "$MUSL_CC"],
[AC_MSG_NOTICE([fastwc: building against static musl ($MUSL_CC)])],
[AC_MSG_WARN([fastwc: musl-gcc not found; falling back to $CC (dynamic link). Install a musl toolchain or configure --enable-glibc.])])])
AC_SUBST([STATIC_LDFLAGS])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT