Bug 1915571 - Move mac and windows clang stage 2 build to cross-compiles. r=firefox-build-system-reviewers,sergesanspaille

By doing so, we don't really need a stage 1 clang for mac and windows
(with the downside that the final PGOed clang becomes the
clang-toolchain artifact on those platforms), and cross-compiling stage
2 is much faster as a cross-compile, leaving only stage 3 to be native.

While here, for the one build type that still does stage 2 and 3 in one
task, we actually prefer taking the llvm-profdata from stage 1, as it
doesn't contain profile instrumentation (it should actually have been
this way since the beginning).

Differential Revision: https://phabricator.services.mozilla.com/D220654
This commit is contained in:
Mike Hommey
2024-10-04 20:26:33 +00:00
parent a7fe8cd3ce
commit ac439e0399
7 changed files with 157 additions and 72 deletions

View File

@@ -799,12 +799,16 @@ def main():
assertions,
target,
targets,
is_final_stage=(stages == 2),
is_final_stage=(stages == 2 and not pgo),
profile="gen" if pgo else None,
)
if stages >= 3 and skip_stages < 3:
stage3_dir = build_dir + "/stage3"
if pgo:
profiles_dir = build_dir + "/profiles"
mkdir_p(profiles_dir)
os.environ["LLVM_PROFILE_FILE"] = profiles_dir + "/%m.profraw"
stage3_inst_dir = stage3_dir + "/" + package_name
final_stage_dir = stage3_dir
if skip_stages < 2:
@@ -826,14 +830,16 @@ def main():
assertions,
target,
targets,
(stages == 3),
is_final_stage=(stages == 3 and not pgo),
)
if pgo:
llvm_profdata = stage2_inst_dir + "/bin/llvm-profdata%s" % exe_ext
del os.environ["LLVM_PROFILE_FILE"]
if skip_stages < 1:
llvm_profdata = stage1_inst_dir + "/bin/llvm-profdata%s" % exe_ext
else:
llvm_profdata = get_tool(config, "llvm-profdata")
merge_cmd = [llvm_profdata, "merge", "-o", "merged.profdata"]
profraw_files = glob.glob(
os.path.join(stage2_dir, "build", "profiles", "*.profraw")
)
profraw_files = glob.glob(os.path.join(profiles_dir, "*.profraw"))
run_in(stage3_dir, merge_cmd + profraw_files)
if stages == 3:
mkdir_p(upload_dir)
@@ -869,7 +875,7 @@ def main():
assertions,
target,
targets,
(stages == 4),
is_final_stage=(stages == 4),
profile=profile,
)