Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752843AbcK1HnP (ORCPT ); Mon, 28 Nov 2016 02:43:15 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:8314 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750878AbcK1HnF (ORCPT ); Mon, 28 Nov 2016 02:43:05 -0500 Subject: Re: [PATCH v3 10/30] perf clang: Add builtin clang support ant test case To: Alexei Starovoitov References: <20161126070354.141764-1-wangnan0@huawei.com> <20161126070354.141764-11-wangnan0@huawei.com> <20161126171715.GE83987@ast-mbp.thefacebook.com> CC: , , , , , , , Jiri Olsa From: "Wangnan (F)" Message-ID: <583BDFC2.3080404@huawei.com> Date: Mon, 28 Nov 2016 15:41:54 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <20161126171715.GE83987@ast-mbp.thefacebook.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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1919 Lines: 62 On 2016/11/27 1:17, Alexei Starovoitov wrote: > On Sat, Nov 26, 2016 at 07:03:34AM +0000, Wang Nan wrote: >> Add basic clang support in clang.cpp and test__clang() testcase. The >> first testcase checks if builtin clang is able to generate LLVM IR. >> >> tests/clang.c is a proxy. Real testcase resides in >> utils/c++/clang-test.cpp in c++ and exports C interface to perf test >> subsystem. >> >> Test result: >> >> $ perf test -v clang >> 51: Test builtin clang support : >> 51.1: Test builtin clang compile C source to IR : >> --- start --- >> test child forked, pid 13215 >> test child finished with 0 >> ---- end ---- >> Test builtin clang support subtest 0: Ok >> >> Signed-off-by: Wang Nan > ... >> +static CompilerInvocation * >> +createCompilerInvocation(StringRef& Path, DiagnosticsEngine& Diags) >> +{ >> + llvm::opt::ArgStringList CCArgs { >> + "-cc1", >> + "-triple", "bpf-pc-linux", >> + "-fsyntax-only", >> + "-ferror-limit", "19", >> + "-fmessage-length", "127", > why such limits? > >> + "-O2", >> + "-nostdsysteminc", >> + "-nobuiltininc", >> + "-vectorize-loops", >> + "-vectorize-slp", Thank you for pointing these out. These arguments are get by analysising the clang example: https://llvm.org/svn/llvm-project/cfe/branches/ggreif/CallInst-operands/examples/clang-interpreter/main.cpp The above example create a C compiler using clang::driver::Driver (bcc also uses driver). I form the argument list according to arglist the driver created for its CI, and leaves arguments I'm not quite sure unchanged. > why above two flags are needed? > >> + "-Wno-unused-value", >> + "-Wno-pointer-sign", > these two -Wno makes sense. please add the comment to explain the reasons. > They are inherited from samples/bpf/Makefile to suppress some warning when include kernel headers. Thank you.