mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-05 22:56:57 +02:00
BUILD: makefile: move -O2 from CPU_CFLAGS to OPT_CFLAGS
CPU_CFLAGS is meant to set the CPU-specific options (-mcpu, -march etc). The fact that it also includes the optimization level is annoying because one cannot be set without replacing the other. Let's move the optimization level to a new independent OPT_CFLAGS that is added early to the list, so that other CFLAGS (including CPU_CFLAGS) can continue to override it if necessary.
This commit is contained in:
parent
97725dd136
commit
8194499bec
2
.github/matrix.py
vendored
2
.github/matrix.py
vendored
@ -152,7 +152,7 @@ def main(ref_name):
|
|||||||
"USE_OBSOLETE_LINKER=1",
|
"USE_OBSOLETE_LINKER=1",
|
||||||
'DEBUG_CFLAGS="-g -fsanitize=address"',
|
'DEBUG_CFLAGS="-g -fsanitize=address"',
|
||||||
'LDFLAGS="-fsanitize=address"',
|
'LDFLAGS="-fsanitize=address"',
|
||||||
'CPU_CFLAGS.generic="-O1"',
|
'OPT_CFLAGS="-O1"',
|
||||||
"USE_ZLIB=1",
|
"USE_ZLIB=1",
|
||||||
"USE_OT=1",
|
"USE_OT=1",
|
||||||
"OT_INC=${HOME}/opt-ot/include",
|
"OT_INC=${HOME}/opt-ot/include",
|
||||||
|
4
INSTALL
4
INSTALL
@ -583,6 +583,10 @@ 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
|
compiler. These flags are passed last so the variable may be used to override
|
||||||
other options such as warnings, optimization levels, include paths etc.
|
other options such as warnings, optimization levels, include paths etc.
|
||||||
|
|
||||||
|
A default optimization level of -O2 is set by variable OPT_CFLAGS which may be
|
||||||
|
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.
|
||||||
|
|
||||||
If you are building for a different system than the one you're building on,
|
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
|
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
|
well and tries to ease it by letting you adjust paths to all libraries (please
|
||||||
|
35
Makefile
35
Makefile
@ -76,6 +76,7 @@
|
|||||||
# CC is set to "cc" by default and is used for compilation only.
|
# 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.
|
# 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
|
# 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.
|
# CFLAGS may be used to append any flags for the C compiler.
|
||||||
# LDFLAGS is automatically set to -g and may be overridden.
|
# LDFLAGS is automatically set to -g and may be overridden.
|
||||||
# DEP may be cleared to ignore changes to include files during development
|
# DEP may be cleared to ignore changes to include files during development
|
||||||
@ -169,6 +170,11 @@ ARCH =
|
|||||||
CC = cc
|
CC = cc
|
||||||
LD = $(CC)
|
LD = $(CC)
|
||||||
|
|
||||||
|
#### Default optimizations
|
||||||
|
# Those are integrated early in the list of CFLAGS, and may be overridden by
|
||||||
|
# other CFLAGS options if needed.
|
||||||
|
OPT_CFLAGS = -O2
|
||||||
|
|
||||||
#### Debug flags (typically "-g").
|
#### Debug flags (typically "-g").
|
||||||
# Those flags only feed CFLAGS so it is not mandatory to use this form.
|
# Those flags only feed CFLAGS so it is not mandatory to use this form.
|
||||||
DEBUG_CFLAGS = -g
|
DEBUG_CFLAGS = -g
|
||||||
@ -258,17 +264,17 @@ EXTRA =
|
|||||||
# feed CPU_CFLAGS, which in turn feed CFLAGS, so it is not mandatory to use
|
# 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
|
# them. You should not have to change these options. Better use CPU_CFLAGS or
|
||||||
# even CFLAGS instead.
|
# even CFLAGS instead.
|
||||||
CPU_CFLAGS.generic = -O2
|
CPU_CFLAGS.generic =
|
||||||
CPU_CFLAGS.native = -O2 -march=native
|
CPU_CFLAGS.native = -march=native
|
||||||
CPU_CFLAGS.i586 = -O2 -march=i586
|
CPU_CFLAGS.i586 = -march=i586
|
||||||
CPU_CFLAGS.i686 = -O2 -march=i686
|
CPU_CFLAGS.i686 = -march=i686
|
||||||
CPU_CFLAGS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
|
CPU_CFLAGS.ultrasparc = -mcpu=v9 -mtune=ultrasparc
|
||||||
CPU_CFLAGS.power8 = -O2 -mcpu=power8 -mtune=power8
|
CPU_CFLAGS.power8 = -mcpu=power8 -mtune=power8
|
||||||
CPU_CFLAGS.power9 = -O2 -mcpu=power9 -mtune=power9
|
CPU_CFLAGS.power9 = -mcpu=power9 -mtune=power9
|
||||||
CPU_CFLAGS.a53 = -O2 -mcpu=cortex-a53
|
CPU_CFLAGS.a53 = -mcpu=cortex-a53
|
||||||
CPU_CFLAGS.a72 = -O2 -mcpu=cortex-a72
|
CPU_CFLAGS.a72 = -mcpu=cortex-a72
|
||||||
CPU_CFLAGS.armv81 = -O2 -march=armv8.1-a
|
CPU_CFLAGS.armv81 = -march=armv8.1-a
|
||||||
CPU_CFLAGS.armv8-auto = -O2 -march=armv8-a+crc -moutline-atomics
|
CPU_CFLAGS.armv8-auto = -march=armv8-a+crc -moutline-atomics
|
||||||
CPU_CFLAGS = $(CPU_CFLAGS.$(CPU))
|
CPU_CFLAGS = $(CPU_CFLAGS.$(CPU))
|
||||||
|
|
||||||
#### ARCH dependent flags, may be overridden by CPU flags
|
#### ARCH dependent flags, may be overridden by CPU flags
|
||||||
@ -468,7 +474,7 @@ $(set_target_defaults)
|
|||||||
# linking with it by default as it's not always available nor deployed
|
# linking with it by default as it's not always available nor deployed
|
||||||
# (especially on archs which do not need it).
|
# (especially on archs which do not need it).
|
||||||
ifneq ($(USE_THREAD:0=),)
|
ifneq ($(USE_THREAD:0=),)
|
||||||
ifneq ($(shell $(CC) $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(SPEC_CFLAGS) $(CFLAGS) -dM -E -xc - </dev/null 2>/dev/null | grep -c 'LOCK_FREE.*1'),0)
|
ifneq ($(shell $(CC) $(OPT_CFLAGS) $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(SPEC_CFLAGS) $(CFLAGS) -dM -E -xc - </dev/null 2>/dev/null | grep -c 'LOCK_FREE.*1'),0)
|
||||||
USE_LIBATOMIC = implicit
|
USE_LIBATOMIC = implicit
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -837,10 +843,10 @@ endif
|
|||||||
$(collect_opts_flags)
|
$(collect_opts_flags)
|
||||||
|
|
||||||
#### Global compile options
|
#### Global compile options
|
||||||
VERBOSE_CFLAGS = $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(SPEC_CFLAGS) $(TARGET_CFLAGS) $(CFLAGS) $(DEFINE)
|
VERBOSE_CFLAGS = $(OPT_CFLAGS) $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(SPEC_CFLAGS) $(TARGET_CFLAGS) $(CFLAGS) $(DEFINE)
|
||||||
COPTS = -Iinclude
|
COPTS = -Iinclude
|
||||||
|
|
||||||
COPTS += $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(SPEC_CFLAGS) $(TARGET_CFLAGS) $(DEFINE) $(SILENT_DEFINE)
|
COPTS += $(OPT_CFLAGS) $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(SPEC_CFLAGS) $(TARGET_CFLAGS) $(DEFINE) $(SILENT_DEFINE)
|
||||||
COPTS += $(DEBUG) $(OPTIONS_CFLAGS) $(CFLAGS) $(ADDINC)
|
COPTS += $(DEBUG) $(OPTIONS_CFLAGS) $(CFLAGS) $(ADDINC)
|
||||||
|
|
||||||
ifneq ($(VERSION)$(SUBVERS)$(EXTRAVERSION),)
|
ifneq ($(VERSION)$(SUBVERS)$(EXTRAVERSION),)
|
||||||
@ -1148,6 +1154,7 @@ opts:
|
|||||||
@echo -n 'ARCH="$(strip $(ARCH))" '
|
@echo -n 'ARCH="$(strip $(ARCH))" '
|
||||||
@echo -n 'CPU="$(strip $(CPU))" '
|
@echo -n 'CPU="$(strip $(CPU))" '
|
||||||
@echo -n 'CC="$(strip $(CC))" '
|
@echo -n 'CC="$(strip $(CC))" '
|
||||||
|
@echo -n 'OPT_CFLAGS="$(strip $(OPT_CFLAGS))" '
|
||||||
@echo -n 'ARCH_FLAGS="$(strip $(ARCH_FLAGS))" '
|
@echo -n 'ARCH_FLAGS="$(strip $(ARCH_FLAGS))" '
|
||||||
@echo -n 'CPU_CFLAGS="$(strip $(CPU_CFLAGS))" '
|
@echo -n 'CPU_CFLAGS="$(strip $(CPU_CFLAGS))" '
|
||||||
@echo -n 'DEBUG_CFLAGS="$(strip $(DEBUG_CFLAGS))" '
|
@echo -n 'DEBUG_CFLAGS="$(strip $(DEBUG_CFLAGS))" '
|
||||||
|
Loading…
Reference in New Issue
Block a user