@@ -4,6 +4,7 @@ from lit import Test
44import lit .formats
55import lit .util
66import os
7+ import re
78import subprocess
89
910clang_bolt_mode = config .clang_bolt_mode .lower ()
@@ -20,9 +21,24 @@ elif clang_bolt_mode == "perf":
2021else :
2122 assert 0 , "Unsupported CLANG_BOLT_MODE variable"
2223
23- config . clang = perf_wrapper + os .path .realpath (
24+ clang_nowrapper = os .path .realpath (
2425 lit .util .which (clang_binary , config .clang_tools_dir )
2526).replace ("\\ " , "/" )
27+ config .clang = perf_wrapper + clang_nowrapper
28+ config .cmake_compiler_args = "-DCMAKE_CXX_COMPILER_LAUNCHER='{0}' -DCMAKE_C_COMPILER_LAUNCHER='{0}' -DCMAKE_C_COMPILER='{1}' -DCMAKE_CXX_COMPILER='{1};--driver-mode=g++'" .format (
29+ re .sub (r"\s+" , ";" , perf_wrapper .rstrip ()),
30+ re .sub (r"\s+" , ";" , clang_nowrapper )
31+ )
32+
33+ # We need to limit the number of build jobs with perf in order to avoid this
34+ # error:
35+ #
36+ # | Permission error mapping pages.
37+ # | Consider increasing /proc/sys/kernel/perf_event_mlock_kb,
38+ # | or try again with a smaller value of -m/--mmap_pages.
39+ ninja_args = ""
40+ if clang_bolt_mode != "instrument" :
41+ ninja_args = "-j1"
2642
2743config .name = "Clang Perf Training"
2844config .suffixes = [
@@ -49,6 +65,8 @@ config.substitutions.append(("%clang_cpp", f" {config.clang} --driver-mode=g++ "
4965config .substitutions .append (("%clang_skip_driver" , config .clang ))
5066config .substitutions .append (("%clang" , config .clang ))
5167config .substitutions .append (("%test_root" , config .test_exec_root ))
68+ config .substitutions .append (("%cmake_compiler_args" , config .cmake_compiler_args ))
5269config .substitutions .append (('%cmake_generator' , config .cmake_generator ))
5370config .substitutions .append (('%cmake' , config .cmake_exe ))
5471config .substitutions .append (('%llvm_src_dir' , config .llvm_src_dir ))
72+ config .substitutions .append (('%ninja_args' , ninja_args ))
0 commit comments