Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use thinlto and pgo for x86_64 windows release packaging #71067

Merged
merged 4 commits into from
Nov 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion llvm/utils/release/build_llvm_release.bat
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ set common_cmake_flags=^
-DCMAKE_CXX_FLAGS="-DLIBXML_STATIC" ^
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;compiler-rt;lldb;openmp"

set cmake_profile_flag=""

REM Preserve original path
set OLDPATH=%PATH%

Expand Down Expand Up @@ -261,9 +263,11 @@ set all_cmake_flags=^
-DCMAKE_RC=%stage0_bin_dir%/llvm-windres.exe
set cmake_flags=%all_cmake_flags:\=/%


mkdir build64
cd build64
cmake -GNinja %cmake_flags% ..\llvm-project\llvm || exit /b 1
call :do_generate_profile || exit /b 1
cmake -GNinja %cmake_flags% %cmake_profile_flag% ..\llvm-project\llvm || exit /b 1
ninja || ninja || ninja || exit /b 1
ninja check-llvm || ninja check-llvm || ninja check-llvm || exit /b 1
ninja check-clang || ninja check-clang || ninja check-clang || exit /b 1
Expand Down Expand Up @@ -388,8 +392,38 @@ ninja install || exit /b 1
set libxmldir=%cd%\install
set "libxmldir=%libxmldir:\=/%"
cd ..
exit /b 0

::==============================================================================
:: Generate a PGO profile.
::==============================================================================
:do_generate_profile
REM Build Clang with instrumentation.
mkdir instrument
cd instrument
cmake -GNinja %cmake_flags% -DLLVM_TARGETS_TO_BUILD=Native ^
-DLLVM_BUILD_INSTRUMENTED=IR ..\..\llvm-project\llvm || exit /b 1
ninja clang || ninja clang || ninja clang || exit /b 1
set instrumented_clang=%cd:\=/%/bin/clang-cl.exe
cd ..
REM Use that to build part of llvm to generate a profile.
mkdir train
cd train
cmake -GNinja %cmake_flags% ^
-DCMAKE_C_COMPILER=%instrumented_clang% ^
-DCMAKE_CXX_COMPILER=%instrumented_clang% ^
-DLLVM_ENABLE_PROJECTS=clang ^
-DLLVM_TARGETS_TO_BUILD=Native ^
..\..\llvm-project\llvm || exit /b 1
REM Drop profiles generated from running cmake; those are not representative.
del ..\instrument\profiles\*.profraw
ninja tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/Sema.cpp.obj
cd ..
set profile=%cd:\=/%/profile.profdata
%stage0_bin_dir%\llvm-profdata merge -output=%profile% instrument\profiles\*.profraw || exit /b 1
set cmake_profile_flag=-DLLVM_PROFDATA_FILE=%profile%
exit /b 0

::=============================================================================
:: Parse command line arguments.
:: The format for the arguments is:
Expand Down