Re: [PATCH v3 10/30] perf clang: Add builtin clang support ant test case

From: Wangnan (F)
Date: Sun Dec 04 2016 - 21:37:41 EST




On 2016/12/2 23:44, Arnaldo Carvalho de Melo wrote:
Em Sat, Nov 26, 2016 at 07:03:34AM +0000, Wang Nan escreveu:
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
While testing this I noticed that the perf binary got huge, can't this
be done in some other way, i.e. using dynamic library?

I intentionally use statically linking because it is good for
smartphone: we can simply 'adb push' a statically linked perf
to Android.

The resulting ELF executable would be even larger if LLVM is
built with default setting.

In my setting the resuling 'perf' is less than 60MB:

$ ls -s ~/perf -h
58M /home/wn/perf

$ size ~/perf
text data bss dec hex filename
56931273 2950808 24108632 83990713 50198b9 /home/wn/perf

It is reasonable for me.

I think using dynamic clang and llvm libraries is possible but I
never tried it before. It depend on LLVM compiling. I think if
distro provides shared libraries then perf can utilize them
automatically. Let me check it today.

About the file size, I discussed with Alexei, he taught me a lot
on it. Maybe he or his ioVisor ex-colleagues can provide some
new idea?

Thank you.