Linux Perf
llvm-utils.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2015, Wang Nan <wangnan0@huawei.com>
4  * Copyright (C) 2015, Huawei Inc.
5  */
6 #ifndef __LLVM_UTILS_H
7 #define __LLVM_UTILS_H
8 
9 #include "debug.h"
10 
11 struct llvm_param {
12  /* Path of clang executable */
13  const char *clang_path;
14  /*
15  * Template of clang bpf compiling. 5 env variables
16  * can be used:
17  * $CLANG_EXEC: Path to clang.
18  * $CLANG_OPTIONS: Extra options to clang.
19  * $KERNEL_INC_OPTIONS: Kernel include directories.
20  * $WORKING_DIR: Kernel source directory.
21  * $CLANG_SOURCE: Source file to be compiled.
22  */
24  /* Will be filled in $CLANG_OPTIONS */
25  const char *clang_opt;
26  /* Where to find kbuild system */
27  const char *kbuild_dir;
28  /*
29  * Arguments passed to make, like 'ARCH=arm' if doing cross
30  * compiling. Should not be used for dynamic compiling.
31  */
32  const char *kbuild_opts;
33  /*
34  * Default is false. If set to true, write compiling result
35  * to object file.
36  */
37  bool dump_obj;
38  /*
39  * Default is false. If one of the above fields is set by user
40  * explicitly then user_set_llvm is set to true. This is used
41  * for perf test. If user doesn't set anything in .perfconfig
42  * and clang is not found, don't trigger llvm test.
43  */
45 };
46 
47 extern struct llvm_param llvm_param;
48 int perf_llvm_config(const char *var, const char *value);
49 
50 int llvm__compile_bpf(const char *path, void **p_obj_buf, size_t *p_obj_buf_sz);
51 
52 /* This function is for test__llvm() use only */
53 int llvm__search_clang(void);
54 
55 /* Following functions are reused by builtin clang support */
56 void llvm__get_kbuild_opts(char **kbuild_dir, char **kbuild_include_opts);
57 int llvm__get_nr_cpus(void);
58 
59 void llvm__dump_obj(const char *path, void *obj_buf, size_t size);
60 #endif
int llvm__get_nr_cpus(void)
Definition: llvm-utils.c:371
bool dump_obj
Definition: llvm-utils.h:37
int value
Definition: python.c:1143
const char * clang_bpf_cmd_template
Definition: llvm-utils.h:23
size_t size
Definition: evsel.c:60
void llvm__get_kbuild_opts(char **kbuild_dir, char **kbuild_include_opts)
Definition: llvm-utils.c:291
const char * kbuild_dir
Definition: llvm-utils.h:27
bool user_set_param
Definition: llvm-utils.h:44
const char * clang_opt
Definition: llvm-utils.h:25
void llvm__dump_obj(const char *path, void *obj_buf, size_t size)
Definition: llvm-utils.c:389
int llvm__search_clang(void)
Definition: llvm-utils.c:545
int perf_llvm_config(const char *var, const char *value)
Definition: llvm-utils.c:36
const char * clang_path
Definition: llvm-utils.h:13
const char * kbuild_opts
Definition: llvm-utils.h:32
int llvm__compile_bpf(const char *path, void **p_obj_buf, size_t *p_obj_buf_sz)
Definition: llvm-utils.c:424