Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754124AbbFJAzQ (ORCPT ); Tue, 9 Jun 2015 20:55:16 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:33217 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753631AbbFJAzL (ORCPT ); Tue, 9 Jun 2015 20:55:11 -0400 Message-ID: <5577891C.5010904@huawei.com> Date: Wed, 10 Jun 2015 08:47:24 +0800 From: "Wangnan (F)" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Alexei Starovoitov , , , , , , , , , , CC: , , , , Subject: Re: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config References: <1433829036-23687-1-git-send-email-wangnan0@huawei.com> <1433829036-23687-26-git-send-email-wangnan0@huawei.com> <55777A17.7030000@plumgrid.com> In-Reply-To: <55777A17.7030000@plumgrid.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.111.66.109] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.5577892A.0107,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 60da3a1300350e825ae124a8cb601290 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2771 Lines: 84 On 2015/6/10 7:43, Alexei Starovoitov wrote: > On 6/8/15 10:50 PM, Wang Nan wrote: >> perf_bpf_config() is added to parse 'bpf' section in perf config file. >> Following is an example: >> >> [bpf] >> clang-path = /llvm/bin/x86_64-linux-clang" >> llc-path = /llvm/bin/x86_64-linux-llc" >> clang-opt = "-nostdinc -isystem /llvm/lib/clang/include >> -I/kernel/arch/x86/include ..." >> llc-opt = "" > > a section to specify -I flags to compile prog.c is useful, > but users shouldn't be populating it manually for kernel headers. > How about adding a script that can figure out $(LINUXINCLUDE) > automatically ? > You can even invoke such flag detector from perf via something like: > f = open /tmpdir/Makefile > fprintf(f, "obj-y := dummy.o\n"); > fprintf(f, "$(obj)/%%.o: $(src)/%%.c\n"); > fprintf(f, "\t@echo -n \"$(NOSTDINC_FLAGS) $(LINUXINCLUDE) > $(EXTRA_CFLAGS)\" > %s\n", cachefile); > snprintf(cmd, "make -s -C /lib/modules/%s/build M=%s dummy.o", > uts_release, tmpdir); > system(cmd); > read flags from cachefile and cache it for the future. > ... > or as independent script that populates .perfconfig > That's cool, but could I implement it later? Introducing such stuffs also introduces a lot of trouble tasks: 1. Dependency on make and kernel build. We should search make and kbuild dir dynamically and also gives users the right to specify them by theirselves. A lot of configuration options should be appended: --make-path=/path/to/make --kbuild-dir=kernel/build/dir in cmdline and [kbuild] make_path = /path/to/make kbuild_dir = /path/to/kbuild in .perfconfig. 2. Selection of architectures. Although currently we want it to work only when we dynamically compile a script, I think finally we should consider cross compiling bpf objects. Then cmdline generation becomes complex. Also, --arch and [kbuild.arch] should also be introduced. 3. Kernel dependency. Consider if kernel decides to change its interface... I think currently we can pop some messages to let user know how to get include dirs manually, let further patches to do it for them automatically. P.S. Have you tested your Makefile? It doesn't work for me: # cat ./Makefile obj-y := dummy.o $(obj)/%.o: $(src)/%.c @echo -n "$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)" > xxxx # make -s -C kernel/build/dir M=`pwd` dummy.o make[2]: *** No rule to make target `dummy.o'. Stop. make[1]: *** [sub-make] Error 2 make: *** [__sub-make] Error 2 Thank you. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/