Skip to content

Commit f59e766

Browse files
committed
samples: seccomp: build sample programs for target architecture
These userspace programs include UAPI headers exported to usr/include/. 'make headers' always works for the target architecture (i.e. the same architecture as the kernel), so the sample programs should be built for the target as well. Kbuild now supports 'userprogs' for that. I also guarded the CONFIG option by 'depends on CC_CAN_LINK' because $(CC) may not provide libc. The 'ifndef CROSS_COMPILE' is no longer needed. BTW, the -m31 for s390 is left-over code. Commit 5a79859 ("s390: remove 31 bit support") killed it. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Acked-by: Sam Ravnborg <sam@ravnborg.org>
1 parent 8a2cc05 commit f59e766

2 files changed

Lines changed: 4 additions & 40 deletions

File tree

‎samples/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ config SAMPLE_PIDFD
126126

127127
config SAMPLE_SECCOMP
128128
bool "Build seccomp sample code"
129-
depends on SECCOMP_FILTER && HEADERS_INSTALL
129+
depends on SECCOMP_FILTER && CC_CAN_LINK && HEADERS_INSTALL
130130
help
131131
Build samples of seccomp filters using various methods of
132132
BPF filter construction.

‎samples/seccomp/Makefile‎

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,8 @@
11
# SPDX-License-Identifier: GPL-2.0
2-
ifndef CROSS_COMPILE
3-
hostprogs := bpf-fancy dropper bpf-direct user-trap
2+
userprogs := bpf-fancy dropper bpf-direct user-trap
43

5-
HOSTCFLAGS_bpf-fancy.o += -I$(objtree)/usr/include
6-
HOSTCFLAGS_bpf-fancy.o += -idirafter $(objtree)/include
7-
HOSTCFLAGS_bpf-helper.o += -I$(objtree)/usr/include
8-
HOSTCFLAGS_bpf-helper.o += -idirafter $(objtree)/include
94
bpf-fancy-objs := bpf-fancy.o bpf-helper.o
105

11-
HOSTCFLAGS_dropper.o += -I$(objtree)/usr/include
12-
HOSTCFLAGS_dropper.o += -idirafter $(objtree)/include
13-
dropper-objs := dropper.o
6+
userccflags += -I usr/include
147

15-
HOSTCFLAGS_bpf-direct.o += -I$(objtree)/usr/include
16-
HOSTCFLAGS_bpf-direct.o += -idirafter $(objtree)/include
17-
bpf-direct-objs := bpf-direct.o
18-
19-
HOSTCFLAGS_user-trap.o += -I$(objtree)/usr/include
20-
HOSTCFLAGS_user-trap.o += -idirafter $(objtree)/include
21-
user-trap-objs := user-trap.o
22-
23-
# Try to match the kernel target.
24-
ifndef CONFIG_64BIT
25-
26-
# s390 has -m31 flag to build 31 bit binaries
27-
ifndef CONFIG_S390
28-
MFLAG = -m32
29-
else
30-
MFLAG = -m31
31-
endif
32-
33-
HOSTCFLAGS_bpf-direct.o += $(MFLAG)
34-
HOSTCFLAGS_dropper.o += $(MFLAG)
35-
HOSTCFLAGS_bpf-helper.o += $(MFLAG)
36-
HOSTCFLAGS_bpf-fancy.o += $(MFLAG)
37-
HOSTCFLAGS_user-trap.o += $(MFLAG)
38-
HOSTLDLIBS_bpf-direct += $(MFLAG)
39-
HOSTLDLIBS_bpf-fancy += $(MFLAG)
40-
HOSTLDLIBS_dropper += $(MFLAG)
41-
HOSTLDLIBS_user-trap += $(MFLAG)
42-
endif
43-
always-y := $(hostprogs)
44-
endif
8+
always-y := $(userprogs)

0 commit comments

Comments
 (0)