BUILD: makefile: drop the ARCH variable and better document ARCH_FLAGS
ARCH_FLAGS was always present and is documented as being fed to both CC and LD during the build. This is meant for options that need to be consistent between the two stages such as -pg, -flto, -fsanitize=address, -m64, -g etc. Its doc was lacking a bit of clarity though, and it was not enumerated in the makefile's variables list. ARCH however was only documented as affecting ARCH_FLAGS, and was just never used as the only two really usable and supported ARCH_FLAGS options were -m32 and -m64. In addition it was even written in the makefile that it was CPU that was affecting the ARCH_FLAGS. Let's just drop ARCH and improve the documentation on ARCH_FLAGS. Again, if ARCH is set, a warning is emitted explaining how to proceed. ARCH_FLAGS is now preset to -g so that we finally have a correct place to deal with such debugging options that need to be passed to both stages. The fedora and musl CI workflows were updated to also use it instead of sticking to duplicate DEBUG_CFLAGS+LDFLAGS. It's also worth noting that BUILD_ARCH was being passed to the build process and never used anywhere in the code, so its removal will not be noticed.
This commit is contained in:
parent
018443b8a1
commit
88c151f9ca
3
.github/matrix.py
vendored
3
.github/matrix.py
vendored
@ -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",
|
||||
|
10
.github/workflows/fedora-rawhide.yml
vendored
10
.github/workflows/fedora-rawhide.yml
vendored
@ -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
|
||||
|
2
.github/workflows/musl.yml
vendored
2
.github/workflows/musl.yml
vendored
@ -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
|
||||
|
25
INSTALL
25
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=<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
|
||||
|
35
Makefile
35
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=<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
|
||||
@ -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))"' \
|
||||
|
Loading…
x
Reference in New Issue
Block a user