Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- D:\depot_tools\chromium\src\build\config\coverage\BUILD.gn
- Comment out these lines as follows:
- # "-fcoverage-mapping",
- # "-mllvm",
- # "-limited-coverage-experimental=true",
- Modify the ldflag for the 64-bit clang_rt library to match your desired
- LLVM build location. For example:
- ldflags += [
- "D:/src_builds/llvm-monorepo/llvm-build-polly/lib/clang/9.0.0/lib/windows/clang_rt.profile-x86_64.lib"
- ]
- ----------------
- Edit Chromium's compiler config.
- D:\depot_tools\chromium\src\build\config\compiler\BUILD.gn
- Modify these lines around #1860 to instead set NOICF and NOREF:
- common_optimize_on_ldflags += [ "/OPT:NOICF" ] # Redundant COMDAT folding.
- common_optimize_on_ldflags += [ "/OPT:NOREF" ] # Remove unreferenced data.
- ----------------
- Edit the Windows build configuration.
- D:\depot_tools\chromium\src\build\config\win\BUILD.gn
- Modify these lines around #154 to instead set NOICF and NOREF:
- "/OPT:NOREF",
- "/OPT:NOICF",
- ----------------
- For your first stage PGO build, add the following argument to your build:
- use_clang_coverage = true
- Note, Thin/Full LTO is not needed for the first stage, so do not enable it.
- ----------------
- Set the following environment variable from the command line:
- set LLVM_PROFILE_FILE=code-%p.profraw
- ----------------
- Compile the build. Reordering likely will fail for chrome.exe, so just copy
- chrome.exe from the initialexe directory up to the build directory.
- copy D:\depot_tools\chromium\src\out\pgo\initialexe\chrome.exe
- D:\depot_tools\chromium\src\out\pgo\chrome.exe
- ----------------
- Go to the build directory, and profile the build as desired.
- chrome.exe ----no-sandbox
- ----------------
- Copy llvm-profdata.exe from your LLVM bin directory into the build
- directory, and merge the raw profile data files.
- llvm-profdata.exe merge -output=code.profdata code-*.profraw
- ----------------
- Edit Chromium's compiler config.
- D:\depot_tools\chromium\src\build\config\compiler\BUILD.gn
- Around line #291, locate cflags += [ "/X" ]. Add the following to the next
- line:
- cflags += [ "-fprofile-instr-use=D:/builds/pgo/code.profdata",
- "-Wno-profile-instr-unprofiled", "-Wno-error=profile-instr-out-of-date", ]
- Modify these lines around #1860 to restore ICF and REF:
- common_optimize_on_ldflags += [ "/OPT:ICF" ] # Redundant COMDAT folding.
- common_optimize_on_ldflags += [ "/OPT:REF" ] # Remove unreferenced data.
- ----------------
- Edit the Windows build configuration.
- D:\depot_tools\chromium\src\build\config\win\BUILD.gn
- Modify these lines around #154 to restore ICF and REF:
- "/OPT:REF",
- "/OPT:ICF",
- ----------------
- Modify the build arguments again. Disable the coverage argument.
- use_clang_coverage = false
- Enable the ThinLTO arguments if using LTO.
- use_thin_lto = true
- thin_lto_enable_optimizations = true
- ----------------
- Run the build process again. Enjoy the PGO build.... hopefully. :)
- ----------------
- Save the code.profdata file. It should be usable for upto a week or two (or
- more; YMMV) of build revisions without too much concern.
- Just remember to insert the profile use directive into the compiler config
- again when building.
- cflags += [
- "-fprofile-instr-use=D:/depot_tools/chromium/src/out/pgo/code.profdata",
- "-Wno-profile-instr-unprofiled", "-Wno-error=profile-instr-out-of-date", ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement