llvm-utils.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #include "debug.h"
  8. struct llvm_param {
  9. /* Path of clang executable */
  10. const char *clang_path;
  11. /*
  12. * Template of clang bpf compiling. 5 env variables
  13. * can be used:
  14. * $CLANG_EXEC: Path to clang.
  15. * $CLANG_OPTIONS: Extra options to clang.
  16. * $KERNEL_INC_OPTIONS: Kernel include directories.
  17. * $WORKING_DIR: Kernel source directory.
  18. * $CLANG_SOURCE: Source file to be compiled.
  19. */
  20. const char *clang_bpf_cmd_template;
  21. /* Will be filled in $CLANG_OPTIONS */
  22. const char *clang_opt;
  23. /* Where to find kbuild system */
  24. const char *kbuild_dir;
  25. /*
  26. * Arguments passed to make, like 'ARCH=arm' if doing cross
  27. * compiling. Should not be used for dynamic compiling.
  28. */
  29. const char *kbuild_opts;
  30. /*
  31. * Default is false. If one of the above fields is set by user
  32. * explicitly then user_set_llvm is set to true. This is used
  33. * for perf test. If user doesn't set anything in .perfconfig
  34. * and clang is not found, don't trigger llvm test.
  35. */
  36. bool user_set_param;
  37. };
  38. extern struct llvm_param llvm_param;
  39. extern int perf_llvm_config(const char *var, const char *value);
  40. extern int llvm__compile_bpf(const char *path, void **p_obj_buf,
  41. size_t *p_obj_buf_sz);
  42. /* This function is for test__llvm() use only */
  43. extern int llvm__search_clang(void);
  44. #endif