Message ID | 20170517081844.GA4447@gmail.com |
---|---|
State | RFC, archived |
Delegated to: | David Miller |
Headers | show |
On 5/17/17 1:18 AM, Alexander Alemayhu wrote: > I have looked into this but found it to be not easy and all attempts to > change the Makefile has resulted in obscure errors :/ > > Getting clang to output in a different directory was easy[0], but I guess > this is not the right approach either. Have you tried making the change? spent an hour so a few weeks back. It is not trivial, but someone needs to find to fix it now. perf is the example to use: you can build it from both top level kernel directory (e.g, make -C tools/perf O=/tmp/perf) and the perf directory (cd tools/perf; make O=/tmp/perf). Both are wanted for samples/bpf and it would be nice to keep the O= option as well. I don't have the time for the next few weeks. Perhaps mid-June I can take a look.
diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index 6c7468eb3684..79268d310ba5 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -1,6 +1,13 @@ # kbuild trick to avoid linker error. Can be omitted if a module is built. obj- := dummy.o +ifndef O + OUTPUT := $(shell pwd)/samples/bpf/_build/ +else + OUTPUT := $O/ +endif +$(shell mkdir -p $(OUTPUT)) + # List of programs to build hostprogs-y := test_lru_dist hostprogs-y += sock_example @@ -190,4 +197,4 @@ $(obj)/%.o: $(src)/%.c -Wno-gnu-variable-sized-type-not-at-end \ -Wno-address-of-packed-member -Wno-tautological-compare \ -Wno-unknown-warning-option \ - -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@ + -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $(OUTPUT)$(shell basename $@)