Lines Matching full:env
1 #!/usr/bin/env python3
37 def _run_benchmark(env, out_dir, include_debug_info):
39 target_dir = env.output_subdir("instrumentation_run")
47 _build_things_in(env, out_dir, what=["check-llvm", "check-clang"])
51 cmake = _get_cmake_invocation_for_bootstrap_from(env, out_dir, skip_tablegens=False)
56 _run_fresh_cmake(env, cmake, target_dir)
59 _build_things_in(env, target_dir, what=["all"])
127 class Env:
192 def _get_default_cmake_invocation(env):
194 cmake="cmake", maker=env.get_cmake_maker(), cmake_dir=env.llvm_dir
196 for key, value in env.get_default_cmake_args_kv():
201 def _get_cmake_invocation_for_bootstrap_from(env, out_dir, skip_tablegens=True):
203 cmake = _get_default_cmake_invocation(env)
215 if env.dry_run or os.path.exists(path):
225 def _build_things_in(env, target_dir, what):
226 cmd = env.get_make_command() + what
227 env.run_command(cmd, cwd=target_dir, check=True)
230 def _run_fresh_cmake(env, cmake, target_dir):
231 if not env.dry_run:
240 env.run_command(cmake_args, cwd=target_dir, check=True, silent_unless_error=True)
243 def _build_stage1_clang(env):
244 target_dir = env.output_subdir("stage1")
245 cmake = _get_default_cmake_invocation(env)
246 _run_fresh_cmake(env, cmake, target_dir)
247 _build_things_in(env, target_dir, what=["clang", "llvm-profdata", "profile"])
251 def _generate_instrumented_clang_profile(env, stage1_dir, profile_dir, output_file):
253 if env.dry_run:
262 env.run_command(cmd, check=True)
265 def _build_instrumented_clang(env, stage1_dir):
268 target_dir = os.path.join(env.output_dir, "instrumented")
269 cmake = _get_cmake_invocation_for_bootstrap_from(env, stage1_dir)
279 _run_fresh_cmake(env, cmake, target_dir)
280 _build_things_in(env, target_dir, what=["clang", "lld"])
286 def _build_optimized_clang(env, stage1_dir, profdata_file):
287 if not env.dry_run and not os.path.exists(profdata_file):
292 target_dir = os.path.join(env.output_dir, "optimized")
293 cmake = _get_cmake_invocation_for_bootstrap_from(env, stage1_dir)
299 _run_fresh_cmake(env, cmake, target_dir)
300 _build_things_in(env, target_dir, what=["clang"])
398 env = Env(
409 profile_location = os.path.join(env.output_dir, "pgo_profile.prof")
418 return env, result_args
453 env, args = _parse_args()
455 if not _looks_like_llvm_dir(env.llvm_dir):
456 _die("Looks like %s isn't an LLVM directory; please see --help" % env.llvm_dir)
457 if not env.has_llvm_subproject("clang"):
459 if not env.has_llvm_subproject("compiler-rt"):
467 stage1_out = _build_stage1_clang(env)
472 instrumented_out, profile_dir = _build_instrumented_clang(env, stage1_out)
474 _run_benchmark(env, instrumented_out, args.include_debug_info)
477 env, stage1_out, profile_dir, args.profile_location
483 optimized_out = _build_optimized_clang(env, stage1_out, args.profile_location)