Re: [PATCH 2/4] samples/bpf: Use llc in PATH, rather than a hardcoded value
From: Alexei Starovoitov <hidden>
Date: 2016-04-01 17:56:50
Also in:
lkml, netdev
On 4/1/16 7:37 AM, Naveen N. Rao wrote:
On 2016/03/31 08:19PM, Daniel Borkmann wrote:quoted
On 03/31/2016 07:46 PM, Alexei Starovoitov wrote:quoted
On 3/31/16 4:25 AM, Naveen N. Rao wrote:quoted
clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \ -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \ - -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@ + -O2 -emit-llvm -c $< -o -| llc -march=bpf -filetype=obj -o $@ clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \ -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \ - -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=asm -o $@.s + -O2 -emit-llvm -c $< -o -| llc -march=bpf -filetype=asm -o $@.sthat was a workaround when clang/llvm didn't have bpf support. Now clang 3.7 and 3.8 have bpf built-in, so make sense to remove manual calls to llc completely. Just use 'clang -target bpf -O2 -D... -c $< -o $@'+1, the clang part in that Makefile should also more correctly be called with '-target bpf' as it turns out (despite llc with '-march=bpf' ...). Better to use clang directly as suggested by Alexei.I'm likely missing something obvious, but I cannot get this to work. With this diff: $(obj)/%.o: $(src)/%.c clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \ -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \ - -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@ - clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \ - -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \ - -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=asm -o $@.s + -O2 -target bpf -c $< -o $@ I see far too many errors thrown starting with: ./arch/x86/include/asm/arch_hweight.h:31:10: error: invalid output constraint '=a' in asm : "="REG_OUT (res)
ahh. yes. when processing kernel headers clang has to assume x86 style inline asm, though all of these functions will be ignored. I don't have a quick fix for this yet. Let's go back to your original change $(LLC)->llc