]> git.kaiwu.me - haproxy.git/commitdiff
BUILD: makefile: add a new generic target "tiny" master
authorWilly Tarreau <w@1wt.eu>
Thu, 21 May 2026 07:26:03 +0000 (09:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 3 Jul 2026 14:33:27 +0000 (16:33 +0200)
This target disables all possible features except poll(). It is meant to
serve as a base for small embedded setups, on top of which one may manually
enable select features. Even threads, traces/h2/fcgi/SPOE are disabled.
The default executable is roughly 80% smaller than with linux-glibc:

  $ size haproxy-linux-glibc haproxy-tiny
     text    data     bss      dec    hex filename
  3660924  176964 9868784 13706672 d125b0 haproxy-linux-glibc
  2537864  146512   84928  2769304 2a4198 haproxy-tiny

With SSL enabled, the difference shrinks a bit (-77%):

  $ size haproxy-linux-glibc-ssl haproxy-tiny-ssl
     text    data     bss      dec    hex filename
  4163373  208788 9873904 14246065 d960b1 haproxy-linux-glibc-ssl
  2950852  177732   90048  3218632 311cc8 haproxy-tiny-ssl

INSTALL
Makefile

diff --git a/INSTALL b/INSTALL
index fdbd5670eea0f9253ee8b28b893dbaf72aa284df..afe7def4603b3c6e45a44d96f75694c95a21984c 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -475,9 +475,9 @@ are the extra libraries that may be referenced at build time :
 -------------------
 Some build errors may happen depending on the options combinations or the
 selected target. When facing build errors, if you know that your system is a
-bit special or particularly old, start from TARGET=generic, it is easier to
-start from there and fix the remaining issues than trying to degrade another
-target. Common issues may include:
+bit special or particularly old, start from TARGET=generic or TARGET=tiny; it
+is easier to start from there and fix the remaining issues than trying to
+degrade another target. Common issues may include:
 
   - clock_gettime() not found
     => your system needs USE_RT=1
@@ -579,6 +579,7 @@ and assign it to the TARGET variable :
   - haiku               for Haiku
   - generic             for any other OS or version.
   - custom              to manually adjust every setting
+  - tiny                to turn all default options off by default
 
 Example:
     $ make -j $(nproc) TARGET=linux-glibc
@@ -603,8 +604,14 @@ well use that property to define your own set of options. USE_POLL and USE_SLZ
 can even be disabled by setting them to an empty string or a zero. For
 example :
 
-  $ gmake TARGET=tiny USE_POLL="" USE_SLZ=0 TARGET_CFLAGS=-fomit-frame-pointer
+  $ gmake TARGET=small USE_POLL="" USE_SLZ=0 TARGET_CFLAGS=-fomit-frame-pointer
 
+Note that when seeking the absolute smallest build (e.g. for low-spec embedded
+devices), the "tiny" target disables everything configurable and generally
+results in a binary that's 4-5 times smaller than the default one. From this
+point it then becomes possible to enable only what is desired:
+
+  $ make -j $(nproc) TARGET=tiny USE_EPOLL=1 USE_DL=1 USE_OPENSSL=1
 
 5.2) Adding extra CFLAGS for compiling
 --------------------------------------
index b046d1917f32b70587243901349ac86400e1db73..702fac8855a69b39e1bbc59967eb73a71b41d522 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -157,7 +157,7 @@ DOCDIR = $(PREFIX)/doc/haproxy
 # following list (use the default "generic" if uncertain) :
 #    linux-glibc, linux-glibc-legacy, linux-musl, solaris, freebsd, freebsd-glibc,
 #    dragonfly, openbsd, netbsd, cygwin, haiku, aix51, aix52, aix72-gcc, osx, generic,
-#    custom
+#    custom, tiny
 TARGET =
 
 #### No longer used
@@ -387,6 +387,13 @@ ifeq ($(TARGET),generic)
   set_target_defaults = $(call default_opts,USE_POLL USE_TPROXY)
 endif
 
+# For embedded systems or to be used as a base, tiniest binary with fewest
+# features. Only poll() is enabled to avoid issues with select().
+ifeq ($(TARGET),tiny)
+  set_target_defaults = $(call disable_opts,$(use_opts)) $(call enable_opts,USE_POLL)
+  INSTALL = install -v
+endif
+
 # Haiku
 ifeq ($(TARGET),haiku)
   TARGET_LDFLAGS = -lnetwork