diff --git a/.github/matrix.py b/.github/matrix.py index 7925c94a8..5e474dec0 100755 --- a/.github/matrix.py +++ b/.github/matrix.py @@ -150,8 +150,7 @@ def main(ref_name): "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", diff --git a/.github/workflows/fedora-rawhide.yml b/.github/workflows/fedora-rawhide.yml index 90f270e5c..303521997 100644 --- a/.github/workflows/fedora-rawhide.yml +++ b/.github/workflows/fedora-rawhide.yml @@ -12,10 +12,10 @@ jobs: 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 @@ -40,7 +40,7 @@ jobs: 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 diff --git a/.github/workflows/musl.yml b/.github/workflows/musl.yml index 930a22e01..a54414fab 100644 --- a/.github/workflows/musl.yml +++ b/.github/workflows/musl.yml @@ -26,7 +26,7 @@ jobs: - 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 diff --git a/INSTALL b/INSTALL index c13bd8186..48260e481 100644 --- a/INSTALL +++ b/INSTALL @@ -605,19 +605,22 @@ flags are passed to the compiler nor what compiler is involved. Simply append 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= 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 diff --git a/Makefile b/Makefile index cd5538f16..44d5bd9a8 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # 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 @@ -75,10 +75,10 @@ # 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 @@ -163,12 +163,14 @@ $(warning Warning: the "CPU" variable was forced to "$(CPU)" but is no longer \ endif endif -#### Architecture, used when not building for native architecture -# Use ARCH= 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 @@ -271,15 +273,15 @@ EXTRA = # 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 @@ -1042,7 +1044,6 @@ src/calltrace.o: src/calltrace.c $(DEP) 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))"' \