mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-06-21 15:43:21 +02:00
libbpf: Initialize CFLAGS before including Makefile.include
tools/scripts/Makefile.include may expand EXTRA_CFLAGS in a future change. This could alter the initialization of CFLAGS, as the default options "-g -O2" would never be set once EXTRA_CFLAGS is expanded. Prepare for this by moving the CFLAGS initialization before including tools/scripts/Makefile.include, so it is not affected by the extended EXTRA_CFLAGS. Append EXTRA_CFLAGS to CFLAGS only after including Makefile.include and place it last so that the extra flags propagate properly and can override the default options. tools/scripts/Makefile.include already appends $(CLANG_CROSS_FLAGS) to CFLAGS, the Makefile appends $(CLANG_CROSS_FLAGS) again, remove the redundant append. Signed-off-by: Leo Yan <leo.yan@arm.com> Acked-by: Ihor Solodrai <ihor.solodrai@linux.dev> Link: https://lore.kernel.org/r/20260602-tools_build_fix_zero_init_bpf_only-v2-4-c76e5250ea1c@arm.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
committed by
Alexei Starovoitov
parent
3f2fec5b02
commit
f3846b3800
@@ -49,6 +49,14 @@ man_dir_SQ = '$(subst ','\'',$(man_dir))'
|
||||
export man_dir man_dir_SQ INSTALL
|
||||
export DESTDIR DESTDIR_SQ
|
||||
|
||||
# Defer assigning EXTRA_CFLAGS to CFLAGS until after including
|
||||
# tools/scripts/Makefile.include, as it may add flags to EXTRA_CFLAGS.
|
||||
ifdef EXTRA_CFLAGS
|
||||
CFLAGS :=
|
||||
else
|
||||
CFLAGS := -g -O2
|
||||
endif
|
||||
|
||||
include $(srctree)/tools/scripts/Makefile.include
|
||||
|
||||
# copy a bit from Linux kbuild
|
||||
@@ -70,13 +78,6 @@ LIB_TARGET = libbpf.a libbpf.so.$(LIBBPF_VERSION)
|
||||
LIB_FILE = libbpf.a libbpf.so*
|
||||
PC_FILE = libbpf.pc
|
||||
|
||||
# Set compile option CFLAGS
|
||||
ifdef EXTRA_CFLAGS
|
||||
CFLAGS := $(EXTRA_CFLAGS)
|
||||
else
|
||||
CFLAGS := -g -O2
|
||||
endif
|
||||
|
||||
# Append required CFLAGS
|
||||
override CFLAGS += -std=gnu89
|
||||
override CFLAGS += $(EXTRA_WARNINGS) -Wno-switch-enum
|
||||
@@ -84,7 +85,7 @@ override CFLAGS += -Werror -Wall
|
||||
override CFLAGS += $(INCLUDES)
|
||||
override CFLAGS += -fvisibility=hidden
|
||||
override CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
|
||||
override CFLAGS += $(CLANG_CROSS_FLAGS)
|
||||
override CFLAGS += $(EXTRA_CFLAGS)
|
||||
|
||||
# flags specific for shared library
|
||||
SHLIB_FLAGS := -DSHARED -fPIC
|
||||
|
||||
Reference in New Issue
Block a user