From 4cea3a9cb30a962fa759fcb081fb83351113d9c4 Mon Sep 17 00:00:00 2001 From: Wang Nan Date: Thu, 11 Jun 2015 10:31:09 +0000 Subject: perf tools: Call clang to compile C source to object code This is the core patch for supporting eBPF on-the-fly compiling, does the following work: 1. Search clang compiler using search_program(). 2. Run command template defined in llvm-bpf-cmd-template option in [llvm] config section using read_from_pipe(). Patch of clang and source code path is injected into shell command using environment variable using force_set_env(). Commiter notice: When building with DEBUG=1 we get a compiler error that gets fixed with the same approach described in commit b236512280fb: perf kmem: Fix compiler warning about may be accessing uninitialized variable The last argument to strtok_r doesn't need to be initialized, its just a placeholder to make this routine reentrant, but gcc doesn't know about that and complains, breaking the build, fix it by setting it to NULL. Signed-off-by: Wang Nan Acked-by: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: He Kuang Cc: Jiri Olsa Cc: Kaixu Xia Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Zefan Li Cc: pi3orama@163.com Link: http://lkml.kernel.org/n/1436445342-1402-14-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/llvm-utils.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tools/perf/util/llvm-utils.h') diff --git a/tools/perf/util/llvm-utils.h b/tools/perf/util/llvm-utils.h index 504b799687fb..d23adbca120b 100644 --- a/tools/perf/util/llvm-utils.h +++ b/tools/perf/util/llvm-utils.h @@ -33,4 +33,7 @@ struct llvm_param { extern struct llvm_param llvm_param; extern int perf_llvm_config(const char *var, const char *value); + +extern int llvm__compile_bpf(const char *path, void **p_obj_buf, + size_t *p_obj_buf_sz); #endif -- cgit v1.2.3