提交 5eab5a7e 编写于 作者: J Jiri Olsa 提交者: Arnaldo Carvalho de Melo

perf llvm: Display eBPF compiling command in debug output

In addition to template, display also the real compile command line with
all the variables substituted.

  llvm compiling command template: $CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS ...
  llvm compiling command : /usr/bin/clang -D__KERNEL__ -D__NR_CPUS__=24 -DLINUX_VERSION_CODE=0x41000 ...
Signed-off-by: NJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20180312094313.18738-3-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 a3a4a3b3
......@@ -433,6 +433,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
char serr[STRERR_BUFSIZE];
char *kbuild_dir = NULL, *kbuild_include_opts = NULL;
const char *template = llvm_param.clang_bpf_cmd_template;
char *command_echo, *command_out;
if (path[0] != '-' && realpath(path, abspath) == NULL) {
err = errno;
......@@ -487,6 +488,16 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
(path[0] == '-') ? path : abspath);
pr_debug("llvm compiling command template: %s\n", template);
if (asprintf(&command_echo, "echo -n \"%s\"", template) < 0)
goto errout;
err = read_from_pipe(command_echo, (void **) &command_out, NULL);
if (err)
goto errout;
pr_debug("llvm compiling command : %s\n", command_out);
err = read_from_pipe(template, &obj_buf, &obj_buf_sz);
if (err) {
pr_err("ERROR:\tunable to compile %s\n", path);
......@@ -497,6 +508,8 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
goto errout;
}
free(command_echo);
free(command_out);
free(kbuild_dir);
free(kbuild_include_opts);
......@@ -509,6 +522,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
*p_obj_buf_sz = obj_buf_sz;
return 0;
errout:
free(command_echo);
free(kbuild_dir);
free(kbuild_include_opts);
free(obj_buf);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册