Lines Matching +full:clang +full:- +full:format

1 # SPDX-License-Identifier: GPL-2.0
9 tprogs-y += hid_mouse
10 tprogs-y += hid_surface_dial
21 hid_mouse-objs := hid_mouse.o
22 hid_surface_dial-objs := hid_surface_dial.o
25 always-y := $(tprogs-y)
28 # Strip all except -D__LINUX_ARM_ARCH__ option needed to handle linux
30 ARM_ARCH_SELECTOR := $(filter -D__LINUX_ARM_ARCH__%, $(KBUILD_CFLAGS))
36 TPROGS_CFLAGS += -D__SANE_USERSPACE_TYPES__
38 BPF_EXTRA_CFLAGS += -I$(srctree)/arch/mips/include/asm/mach-loongson64
39 BPF_EXTRA_CFLAGS += -I$(srctree)/arch/mips/include/asm/mach-generic
43 TPROGS_CFLAGS += -Wall -O2
44 TPROGS_CFLAGS += -Wmissing-prototypes
45 TPROGS_CFLAGS += -Wstrict-prototypes
47 TPROGS_CFLAGS += -I$(objtree)/usr/include
48 TPROGS_CFLAGS += -I$(LIBBPF_INCLUDE)
49 TPROGS_CFLAGS += -I$(srctree)/tools/include
52 TPROGS_CFLAGS += --sysroot=$(SYSROOT)
53 TPROGS_LDFLAGS := -L$(SYSROOT)/usr/lib
56 TPROGS_LDLIBS += $(LIBBPF) -lelf -lz
58 # Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline:
59 # make M=samples/bpf LLC=~/git/llvm-project/llvm/build/bin/llc CLANG=~/git/llvm-project/llvm/build/…
61 CLANG ?= clang macro
63 LLVM_DIS ?= llvm-dis
64 LLVM_OBJCOPY ?= llvm-objcopy
65 LLVM_READELF ?= llvm-readelf
70 CLANG_ARCH_ARGS = --target=$(notdir $(CROSS_COMPILE:%-=%))
76 $(CC) $(TPROGS_CFLAGS) $(TPROGS_LDFLAGS) -x c - \
77 -o /dev/null 2>/dev/null && echo okay)
84 BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris)
85 BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
86 BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
88 $(CLANG) --target=bpf -O2 -g -c -x c - -o ./llvm_btf_verify.o; \
89 $(LLVM_READELF) -S ./llvm_btf_verify.o | grep BTF; \
90 /bin/rm -f ./llvm_btf_verify.o)
92 BPF_EXTRA_CFLAGS += -fno-stack-protector
94 BPF_EXTRA_CFLAGS += -g
97 BPF_EXTRA_CFLAGS += -g
98 LLC_FLAGS += -mattr=dwarfris
106 $(MAKE) -C ../../ M=$(CURDIR) HID_SAMPLES_PATH=$(CURDIR)
109 $(MAKE) -C ../../ M=$(CURDIR) clean
110 @find $(CURDIR) -type f -name '*~' -delete
111 @$(RM) -r $(CURDIR)/libbpf $(CURDIR)/bpftool
115 $(MAKE) -C $(LIBBPF_SRC) RM='rm -rf' EXTRA_CFLAGS="$(TPROGS_CFLAGS)" \
124 $(MAKE) -C $(BPFTOOLDIR) srctree=$(HID_SAMPLES_PATH)/../../ \
129 $(Q)mkdir -p $@
135 .PHONY: verify_cmds verify_target_bpf $(CLANG) $(LLC)
137 verify_cmds: $(CLANG) $(LLC)
139 if ! (which -- "$${TOOL}" > /dev/null 2>&1); then \
146 @if ! (${LLC} -march=bpf -mattr=help > /dev/null 2>&1); then \
162 -include $(HID_SAMPLES_PATH)/Makefile.target
175 $(Q)$(BPFTOOL) btf dump file $(VMLINUX_BTF) format c > $@
180 clean-files += vmlinux.h
182 # Get Clang's default includes on this system, as opposed to those seen by
183 # '--target=bpf'. This fixes "missing" files on some architectures/distros,
186 # Use '-idirafter': Don't interfere with include mechanics except where the
189 $(shell $(1) -v -E - </dev/null 2>&1 \
190 … | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \
191 $(shell $(1) -dM -E - </dev/null | grep '#define __riscv_xlen ' | sed 's/#define /-D/' | sed 's/ /=…
194 CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG))
199 @echo " CLANG-BPF " $@
200 $(Q)$(CLANG) -g -O2 --target=bpf -D__TARGET_ARCH_$(SRCARCH) \
201 -Wno-compare-distinct-pointer-types -I$(srctree)/include \
202 -I$(srctree)/samples/bpf -I$(srctree)/tools/include \
203 -I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES) \
204 -c $(filter %.bpf.c,$^) -o $@
207 clean-files += $(LINKED_SKELS)
209 hid_mouse.skel.h-deps := hid_mouse.bpf.o
210 hid_surface_dial.skel.h-deps := hid_surface_dial.bpf.o
212 LINKED_BPF_SRCS := $(patsubst %.bpf.o,%.bpf.c,$(foreach skel,$(LINKED_SKELS),$($(skel)-deps)))
219 @echo " BPF GEN-OBJ " $(@:.skel.h=)
220 $(Q)$(BPFTOOL) gen object $(@:.skel.h=.lbpf.o) $(addprefix $(obj)/,$($(@F)-deps))
221 @echo " BPF GEN-SKEL" $(@:.skel.h=)
224 # asm/sysreg.h - inline assembly used by it is incompatible with llvm.
227 # below we use long chain of commands, clang | opt | llvm-dis | llc,
228 # to generate final object file. 'clang' compiles the source into IR
230 # processing (llvm12) and IR optimizations. 'llvm-dis' converts
233 @echo " CLANG-bpf " $@
234 $(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(BPF_EXTRA_CFLAGS) \
235 -I$(obj) -I$(srctree)/tools/testing/selftests/bpf/ \
236 -I$(LIBBPF_INCLUDE) \
237 -D__KERNEL__ -D__BPF_TRACING__ -Wno-unused-value -Wno-pointer-sign \
238 -D__TARGET_ARCH_$(SRCARCH) -Wno-compare-distinct-pointer-types \
239 -Wno-gnu-variable-sized-type-not-at-end \
240 -Wno-address-of-packed-member -Wno-tautological-compare \
241 -Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \
242 -fno-asynchronous-unwind-tables \
243 -I$(srctree)/samples/hid/ \
244 -O2 -emit-llvm -Xclang -disable-llvm-passes -c $< -o - | \
245 $(OPT) -O2 -mtriple=bpf-pc-linux | $(LLVM_DIS) | \
246 $(LLC) -march=bpf $(LLC_FLAGS) -filetype=obj -o $@
248 $(BTF_PAHOLE) -J $@