"CC": CC,
"FLAGS": [
"USE_OBSOLETE_LINKER=1",
- 'DEBUG_CFLAGS="-g -fsanitize=address"',
- 'LDFLAGS="-fsanitize=address"',
+ 'ARCH_FLAGS="-g -fsanitize=address"',
'OPT_CFLAGS="-O1"',
"USE_ZLIB=1",
"USE_OT=1",
strategy:
matrix:
platform: [
- { name: x64, cc: gcc, QUICTLS_EXTRA_ARGS: "", ADDLIB_ATOMIC: "", DEBUG_CFLAGS: "", LDFLAGS: "" },
- { name: x64, cc: clang, QUICTLS_EXTRA_ARGS: "", ADDLIB_ATOMIC: "", DEBUG_CFLAGS: "", LDFLAGS: "" },
- { name: x86, cc: gcc, QUICTLS_EXTRA_ARGS: "-m32 linux-generic32", ADDLIB_ATOMIC: "-latomic", DEBUG_CFLAGS: "-m32", LDFLAGS: "-m32" },
- { name: x86, cc: clang, QUICTLS_EXTRA_ARGS: "-m32 linux-generic32", ADDLIB_ATOMIC: "-latomic", DEBUG_CFLAGS: "-m32", LDFLAGS: "-m32" }
+ { name: x64, cc: gcc, QUICTLS_EXTRA_ARGS: "", ADDLIB_ATOMIC: "", ARCH_FLAGS: "" },
+ { name: x64, cc: clang, QUICTLS_EXTRA_ARGS: "", ADDLIB_ATOMIC: "", ARCH_FLAGS: "" },
+ { name: x86, cc: gcc, QUICTLS_EXTRA_ARGS: "-m32 linux-generic32", ADDLIB_ATOMIC: "-latomic", ARCH_FLAGS: "-m32" },
+ { name: x86, cc: clang, QUICTLS_EXTRA_ARGS: "-m32 linux-generic32", ADDLIB_ATOMIC: "-latomic", ARCH_FLAGS: "-m32" }
]
name: ${{ matrix.platform.cc }}.${{ matrix.platform.name }}
runs-on: ubuntu-latest
make dev/hpack/decode dev/hpack/gen-enc dev/hpack/gen-rht
- name: Compile HAProxy with ${{ matrix.platform.cc }}
run: |
- make -j3 CC=${{ matrix.platform.cc }} V=1 ERR=1 TARGET=linux-glibc USE_OPENSSL=1 USE_QUIC=1 USE_ZLIB=1 USE_PCRE=1 USE_PCRE_JIT=1 USE_LUA=1 USE_SYSTEMD=1 ADDLIB="${{ matrix.platform.ADDLIB_ATOMIC }} -Wl,-rpath,${HOME}/opt/lib" SSL_LIB=${HOME}/opt/lib SSL_INC=${HOME}/opt/include DEBUG_CFLAGS="${{ matrix.platform.DEBUG_CFLAGS }}" LDFLAGS="${{ matrix.platform.LDFLAGS }}"
+ make -j3 CC=${{ matrix.platform.cc }} V=1 ERR=1 TARGET=linux-glibc USE_OPENSSL=1 USE_QUIC=1 USE_ZLIB=1 USE_PCRE=1 USE_PCRE_JIT=1 USE_LUA=1 USE_SYSTEMD=1 ADDLIB="${{ matrix.platform.ADDLIB_ATOMIC }} -Wl,-rpath,${HOME}/opt/lib" SSL_LIB=${HOME}/opt/lib SSL_INC=${HOME}/opt/include ARCH_FLAGS="${{ matrix.platform.ARCH_FLAGS }}"
make install
- name: Show HAProxy version
id: show-version
- name: Install VTest
run: scripts/build-vtest.sh
- name: Build
- run: make -j$(nproc) TARGET=linux-musl DEBUG_CFLAGS='-ggdb3' CC=cc V=1 USE_LUA=1 LUA_INC=/usr/include/lua5.3 LUA_LIB=/usr/lib/lua5.3 USE_OPENSSL=1 USE_PCRE2=1 USE_PCRE2_JIT=1 USE_PROMEX=1
+ run: make -j$(nproc) TARGET=linux-musl ARCH_FLAGS='-ggdb3' CC=cc V=1 USE_LUA=1 LUA_INC=/usr/include/lua5.3 LUA_LIB=/usr/lib/lua5.3 USE_OPENSSL=1 USE_PCRE2=1 USE_PCRE2_JIT=1 USE_PROMEX=1
- name: Show version
run: ./haproxy -vv
- name: Show linked libraries
details again. It is recommended to use this option when cross-compiling to
verify that the paths are correct and that /usr/include is never involved.
-You may want to build specific target binaries which do not match your native
-compiler's target. This is particularly true on 64-bit systems when you want
-to build a 32-bit binary. Use the ARCH variable for this purpose. Right now
-it only knows about a few x86 variants (i386,i486,i586,i686,x86_64), two
-generic ones (32,64) and sets -m32/-m64 as well as -march=<arch> accordingly.
-This variable is only used to set ARCH_FLAGS to preset values, so if you know
-the arch-specific flags that your system needs, you may prefer to set
-ARCH_FLAGS instead. Note that these flags are passed both to the compiler and
-to the linker. For example, in order to build a 32-bit binary on an x86_64
-Linux system with SSL support without support for compression but when OpenSSL
+Some options require to be consistent between the compilation stage and the
+linking stage. This is the case for options which enable debugging (e.g. "-g"),
+profiling ("-pg"), link-time optimization ("-flto"), endianness ("-EB", "-EL"),
+bit width ("-m32", "-m64"), or code analyzers ("-fsanitize=address"). These
+options can be passed via the ARCH_FLAGS variable, which will be used at both
+stages during the build process, thus avoiding the risk of inconsistencies. By
+default, ARCH_FLAGS only contains "-g" to enable the generation of debug
+symbols. For example, in order to build a 32-bit binary on an x86_64 Linux
+system with SSL support without support for compression but when OpenSSL
requires ZLIB anyway :
- $ make TARGET=linux-glibc ARCH=i386 USE_OPENSSL=1 ADDLIB=-lz
+ $ make TARGET=linux-glibc ARCH_FLAGS="-m32 -g" USE_OPENSSL=1 ADDLIB=-lz
+
+and building with the address sanitizer (ASAN) simply requires:
+
+ $ make TARGET=linux-glibc ARCH_FLAGS="-fsanitize=address -g"
Recent systems can resolve IPv6 host names using getaddrinfo(). This primitive
is not present in all libcs and does not work in all of them either. Support in
# This GNU Makefile supports different OS and CPU combinations.
#
# You should use it this way :
-# [g]make TARGET=os [ARCH=arch] [CFLAGS=...] USE_xxx=1 ...
+# [g]make TARGET=os [CFLAGS=...] USE_xxx=1 ...
#
# When in doubt, invoke help, possibly with a known target :
# [g]make help
# Variables useful for packagers :
# CC is set to "cc" by default and is used for compilation only.
# LD is set to "cc" by default and is used for linking only.
-# ARCH may be useful to force build of 32-bit binary on 64-bit systems
# OPT_CFLAGS sets the default optimization level (-O2).
# CFLAGS may be used to append any flags for the C compiler.
# LDFLAGS is automatically set to -g and may be overridden.
+# ARCH_FLAGS for flags common to both CC and LD. Defaults to -g.
# DEP may be cleared to ignore changes to include files during development
# DEBUG may be used to set some internal debugging options.
# ERR may be set to non-empty to pass -Werror to the compiler
endif
endif
-#### Architecture, used when not building for native architecture
-# Use ARCH=<arch_name> to force build for a specific architecture. Known
-# architectures will lead to "-m32" or "-m64" being added to CFLAGS and
-# LDFLAGS. This can be required to build 32-bit binaries on 64-bit targets.
-# Currently, only 32, 64, x86_64, i386, i486, i586 and i686 are understood.
+#### No longer used
ARCH =
+ifneq ($(ARCH),)
+$(warning Warning: the "ARCH" variable was forced to "$(ARCH)" but is no \
+ longer used and will be ignored. Please check the INSTALL file for other \
+ options, but usually in order to pass arch-specific options, ARCH_FLAGS, \
+ CFLAGS or LDFLAGS are preferred.)
+endif
#### Toolchain options.
CC = cc
# is better suited. The default is empty.
CPU_CFLAGS =
-#### ARCH dependent flags, may be overridden by CPU flags
-ARCH_FLAGS.32 = -m32
-ARCH_FLAGS.64 = -m64
-ARCH_FLAGS.i386 = -m32 -march=i386
-ARCH_FLAGS.i486 = -m32 -march=i486
-ARCH_FLAGS.i586 = -m32 -march=i586
-ARCH_FLAGS.i686 = -m32 -march=i686
-ARCH_FLAGS.x86_64 = -m64 -march=x86-64
-ARCH_FLAGS = $(ARCH_FLAGS.$(ARCH))
+#### Architecture dependent flags.
+# These flags are passed both to the compiler and to the linker. A number of
+# settings may need to be passed to both tools, among which some arch-specific
+# options such as -m32 or -m64, some debugging options (-g), some profiling
+# options (-pg), some options affecting how the linkage is done (-flto), as
+# well as some code analysers such as -fsanitize=address. All of these make
+# sense here and will be consistently propagated to both stages. By default
+# only the debugging is enabled (-g).
+ARCH_FLAGS = -g
#### Extra CFLAGS
# These CFLAGS are empty by default and are appended at the end of all the
src/haproxy.o: src/haproxy.c $(DEP)
$(cmd_CC) $(COPTS) \
-DBUILD_TARGET='"$(strip $(TARGET))"' \
- -DBUILD_ARCH='"$(strip $(ARCH))"' \
-DBUILD_CC='"$(strip $(CC))"' \
-DBUILD_CFLAGS='"$(strip $(VERBOSE_CFLAGS))"' \
-DBUILD_OPTIONS='"$(strip $(BUILD_OPTIONS))"' \