CC=/opt/cross/gcc730-arm/bin/gcc ADDLIB=-latomic
- Build with static PCRE on Solaris / UltraSPARC :
- $ make TARGET=solaris CPU=ultrasparc USE_STATIC_PCRE2=1
+ $ make TARGET=solaris CPU_CFLAGS="-mcpu=v9" USE_STATIC_PCRE2=1
For more advanced build options or if a command above reports an error, please
read the following sections.
- generic for any other OS or version.
- custom to manually adjust every setting
-You may also choose your CPU to benefit from some optimizations. This is
-particularly important on UltraSparc machines. For this, you can assign
-one of the following choices to the CPU variable :
-
- - i686 for intel PentiumPro, Pentium 2 and above, AMD Athlon (32 bits)
- - i586 for intel Pentium, AMD K6, VIA C3.
- - ultrasparc : Sun UltraSparc I/II/III/IV processor
- - power8 : IBM POWER8 processor
- - power9 : IBM POWER9 processor
- - armv81 : modern ARM cores (Cortex A55/A75/A76/A78/X1, Neoverse, Graviton2)
- - a72 : ARM Cortex-A72 or A73 (e.g. RPi4, Odroid N2, AWS Graviton)
- - a53 : ARM Cortex-A53 or any of its successors in 64-bit mode (e.g. RPi3)
- - armv8-auto : support both older and newer armv8 cores with a minor penalty,
- thanks to gcc 10's outline atomics (default with gcc 10.2).
- - native : use the build machine's specific processor optimizations. Use with
- extreme care, and never in virtualized environments (known to break).
- - generic : any other processor or no CPU-specific optimization. (default)
-
-Alternatively, you may just set the CPU_CFLAGS value to the optimal GCC options
-for your platform.
-
A generic CFLAGS variable may be set to append any option to pass to the C
compiler. These flags are passed last so the variable may be used to override
other options such as warnings, optimization levels, include paths etc.
overridden if desired. It's used early in the list of CFLAGS so that any other
set of CFLAGS providing a different value may easily override it.
+Some platforms may benefit from some CPU-specific options that will enable
+certain instruction sets, word size or endianness for example. One of them is
+the common "-march=native" that indicates to modern compilers that they need to
+optimize for the machine the compiler is running on. Such options may be either
+passed in the CPU_CFLAGS or in the CFLAGS variable, either will work though
+one may be more convenient for certain methods of packaging and the other one
+for other methods. Among the many possible options, the following ones are
+known for having successfully been used:
+
+ - "-march=native" for a native build
+ - "-march=armv8-a+crc" for older ARM Cortex A53/A72/A73 (such as RPi 3B/4B)
+ - "-march=armv8.1-a" for modern ARM Cortex A55/A76, Graviton2+, RPi 5
+ - "-march=armv8-a+crc -moutline-atomics" to support older ARM with better
+ support of modern cores with gcc-10+
+ - "-mavx", "-mavx2", "-mavx512", to enable certain x86 SIMD instruction sets
+ - "-march=i586" to support almost all 32-bit x86 systems
+ - "-march=i686" to support only the latest 32-bit x86 systems
+ - "-march=i386" to support even the oldest 32-bit x86 systems
+ - "-mlittle-endian -march=armv5te" for some little-endian ARMv5 systems
+ - "-mcpu=v9 -mtune=ultrasparc -m64" for a 64-bit Solaris SPARC build
+ - "-march=1004kc -mtune=1004kc" for some multi-core 32-bit MIPS 1004Kc
+ - "-march=24kc -mtune=24kc" for some single-core 32-bit MIPS 24Kc
+
If you are building for a different system than the one you're building on,
this is called "cross-compiling". HAProxy supports cross-compilation pretty
well and tries to ease it by letting you adjust paths to all libraries (please
# This GNU Makefile supports different OS and CPU combinations.
#
# You should use it this way :
-# [g]make TARGET=os [ARCH=arch] [CPU=cpu] USE_xxx=1 ...
+# [g]make TARGET=os [ARCH=arch] [CFLAGS=...] USE_xxx=1 ...
#
# When in doubt, invoke help, possibly with a known target :
# [g]make help
# custom
TARGET =
-#### TARGET CPU
-# Use CPU=<cpu_name> to optimize for a particular CPU, among the following
-# list :
-# generic, native, i586, i686, ultrasparc, power8, power9, custom,
-# a53, a72, armv81, armv8-auto
-CPU = generic
+#### No longer used
+CPU =
+ifneq ($(CPU),)
+ifneq ($(CPU),generic)
+$(warning Warning: the "CPU" variable was forced to "$(CPU)" but is no longer \
+ used and will be ignored. For native builds, modern compilers generally \
+ prefer that the string "-march=native" is passed in CPU_CFLAGS or CFLAGS. \
+ For other CPU-specific options, please read suggestions in the INSTALL file.)
+endif
+endif
#### Architecture, used when not building for native architecture
# Use ARCH=<arch_name> to force build for a specific architecture. Known
EXTRA =
#### CPU dependent optimizations
-# Some CFLAGS are set by default depending on the target CPU. Those flags only
-# feed CPU_CFLAGS, which in turn feed CFLAGS, so it is not mandatory to use
-# them. You should not have to change these options. Better use CPU_CFLAGS or
-# even CFLAGS instead.
-CPU_CFLAGS.generic =
-CPU_CFLAGS.native = -march=native
-CPU_CFLAGS.i586 = -march=i586
-CPU_CFLAGS.i686 = -march=i686
-CPU_CFLAGS.ultrasparc = -mcpu=v9 -mtune=ultrasparc
-CPU_CFLAGS.power8 = -mcpu=power8 -mtune=power8
-CPU_CFLAGS.power9 = -mcpu=power9 -mtune=power9
-CPU_CFLAGS.a53 = -mcpu=cortex-a53
-CPU_CFLAGS.a72 = -mcpu=cortex-a72
-CPU_CFLAGS.armv81 = -march=armv8.1-a
-CPU_CFLAGS.armv8-auto = -march=armv8-a+crc -moutline-atomics
-CPU_CFLAGS = $(CPU_CFLAGS.$(CPU))
+# This may optionally be used to pass CPU-specific optimizations such as
+# -march=native, -mcpu=something, -m64 etc independently of CFLAGS if it is
+# considered more convenient. Historically, the optimization level was also
+# passed there. This is still supported but not recommended though; OPT_CFLAGS
+# is better suited. The default is empty.
+CPU_CFLAGS =
#### ARCH dependent flags, may be overridden by CPU flags
ARCH_FLAGS.32 = -m32
$(cmd_CC) $(COPTS) \
-DBUILD_TARGET='"$(strip $(TARGET))"' \
-DBUILD_ARCH='"$(strip $(ARCH))"' \
- -DBUILD_CPU='"$(strip $(CPU))"' \
-DBUILD_CC='"$(strip $(CC))"' \
-DBUILD_CFLAGS='"$(strip $(VERBOSE_CFLAGS))"' \
-DBUILD_OPTIONS='"$(strip $(BUILD_OPTIONS))"' \
@echo -n 'Using: '
@echo -n 'TARGET="$(strip $(TARGET))" '
@echo -n 'ARCH="$(strip $(ARCH))" '
- @echo -n 'CPU="$(strip $(CPU))" '
@echo -n 'CC="$(strip $(CC))" '
@echo -n 'OPT_CFLAGS="$(strip $(OPT_CFLAGS))" '
@echo -n 'ARCH_FLAGS="$(strip $(ARCH_FLAGS))" '