Wang Nan | aa61fd0 | 2015-07-21 11:13:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015, Wang Nan <wangnan0@huawei.com> |
| 3 | * Copyright (C) 2015, Huawei Inc. |
| 4 | */ |
| 5 | #ifndef __LLVM_UTILS_H |
| 6 | #define __LLVM_UTILS_H |
| 7 | |
| 8 | #include "debug.h" |
| 9 | |
| 10 | struct llvm_param { |
| 11 | /* Path of clang executable */ |
| 12 | const char *clang_path; |
| 13 | /* |
| 14 | * Template of clang bpf compiling. 5 env variables |
| 15 | * can be used: |
| 16 | * $CLANG_EXEC: Path to clang. |
| 17 | * $CLANG_OPTIONS: Extra options to clang. |
| 18 | * $KERNEL_INC_OPTIONS: Kernel include directories. |
| 19 | * $WORKING_DIR: Kernel source directory. |
| 20 | * $CLANG_SOURCE: Source file to be compiled. |
| 21 | */ |
| 22 | const char *clang_bpf_cmd_template; |
| 23 | /* Will be filled in $CLANG_OPTIONS */ |
| 24 | const char *clang_opt; |
| 25 | /* Where to find kbuild system */ |
| 26 | const char *kbuild_dir; |
| 27 | /* |
| 28 | * Arguments passed to make, like 'ARCH=arm' if doing cross |
| 29 | * compiling. Should not be used for dynamic compiling. |
| 30 | */ |
| 31 | const char *kbuild_opts; |
Wang Nan | 9bc898c | 2015-07-08 10:04:02 +0000 | [diff] [blame] | 32 | /* |
Wang Nan | f078464 | 2016-06-16 08:02:40 +0000 | [diff] [blame] | 33 | * Default is false. If set to true, write compiling result |
| 34 | * to object file. |
| 35 | */ |
| 36 | bool dump_obj; |
| 37 | /* |
Wang Nan | 9bc898c | 2015-07-08 10:04:02 +0000 | [diff] [blame] | 38 | * Default is false. If one of the above fields is set by user |
| 39 | * explicitly then user_set_llvm is set to true. This is used |
| 40 | * for perf test. If user doesn't set anything in .perfconfig |
| 41 | * and clang is not found, don't trigger llvm test. |
| 42 | */ |
| 43 | bool user_set_param; |
Wang Nan | aa61fd0 | 2015-07-21 11:13:34 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | extern struct llvm_param llvm_param; |
Arnaldo Carvalho de Melo | 3938bad | 2016-03-23 15:06:35 -0300 | [diff] [blame] | 47 | int perf_llvm_config(const char *var, const char *value); |
Wang Nan | 4cea3a9 | 2015-06-11 10:31:09 +0000 | [diff] [blame] | 48 | |
Arnaldo Carvalho de Melo | 3938bad | 2016-03-23 15:06:35 -0300 | [diff] [blame] | 49 | int llvm__compile_bpf(const char *path, void **p_obj_buf, size_t *p_obj_buf_sz); |
Wang Nan | 9bc898c | 2015-07-08 10:04:02 +0000 | [diff] [blame] | 50 | |
| 51 | /* This function is for test__llvm() use only */ |
Arnaldo Carvalho de Melo | 3938bad | 2016-03-23 15:06:35 -0300 | [diff] [blame] | 52 | int llvm__search_clang(void); |
Wang Nan | aa61fd0 | 2015-07-21 11:13:34 +0000 | [diff] [blame] | 53 | #endif |