Skip to content

Commit fdf1c72

Browse files
Jiangshan Yianakryiko
Jiangshan Yi
authored andcommitted
samples/bpf: Fix compilation errors with cf-protection option
Currently, compiling the bpf programs will result the compilation errors with the cf-protection option as follows in arm64 and loongarch64 machine when using gcc 12.3.1 and clang 17.0.6. This commit fixes the compilation errors by limited the cf-protection option only used in x86 platform. [root@localhost linux]# make M=samples/bpf ...... CLANG-bpf samples/bpf/xdp2skb_meta_kern.o error: option 'cf-protection=return' cannot be specified on this target error: option 'cf-protection=branch' cannot be specified on this target 2 errors generated. CLANG-bpf samples/bpf/syscall_tp_kern.o error: option 'cf-protection=return' cannot be specified on this target error: option 'cf-protection=branch' cannot be specified on this target 2 errors generated. ...... Fixes: 34f6e38 ("samples/bpf: fix warning with ignored-attributes") Reported-by: Jiangshan Yi <[email protected]> Signed-off-by: Jiangshan Yi <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Tested-by: Qiang Wang <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent fab45b9 commit fdf1c72

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

samples/bpf/Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ BPF_EXTRA_CFLAGS += -I$(srctree)/arch/mips/include/asm/mach-generic
169169
endif
170170
endif
171171

172+
ifeq ($(ARCH), x86)
173+
BPF_EXTRA_CFLAGS += -fcf-protection
174+
endif
175+
172176
TPROGS_CFLAGS += -Wall -O2
173177
TPROGS_CFLAGS += -Wmissing-prototypes
174178
TPROGS_CFLAGS += -Wstrict-prototypes
@@ -405,7 +409,7 @@ $(obj)/%.o: $(src)/%.c
405409
-Wno-gnu-variable-sized-type-not-at-end \
406410
-Wno-address-of-packed-member -Wno-tautological-compare \
407411
-Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \
408-
-fno-asynchronous-unwind-tables -fcf-protection \
412+
-fno-asynchronous-unwind-tables \
409413
-I$(srctree)/samples/bpf/ -include asm_goto_workaround.h \
410414
-O2 -emit-llvm -Xclang -disable-llvm-passes -c $< -o - | \
411415
$(OPT) -O2 -mtriple=bpf-pc-linux | $(LLVM_DIS) | \

0 commit comments

Comments
 (0)