Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. D:\depot_tools\chromium\src\build\config\coverage\BUILD.gn
  2.  
  3. Comment out these lines as follows:
  4.  
  5. # "-fcoverage-mapping",
  6.  
  7. # "-mllvm",
  8. # "-limited-coverage-experimental=true",
  9.  
  10. Modify the ldflag for the 64-bit clang_rt library to match your desired
  11. LLVM build location. For example:
  12.  
  13. ldflags += [
  14. "D:/src_builds/llvm-monorepo/llvm-build-polly/lib/clang/9.0.0/lib/windows/clang_rt.profile-x86_64.lib"
  15. ]
  16.  
  17. ----------------
  18.  
  19. Edit Chromium's compiler config.
  20.  
  21. D:\depot_tools\chromium\src\build\config\compiler\BUILD.gn
  22.  
  23. Modify these lines around #1860 to instead set NOICF and NOREF:
  24.  
  25. common_optimize_on_ldflags += [ "/OPT:NOICF" ] # Redundant COMDAT folding.
  26. common_optimize_on_ldflags += [ "/OPT:NOREF" ] # Remove unreferenced data.
  27.  
  28. ----------------
  29.  
  30. Edit the Windows build configuration.
  31.  
  32. D:\depot_tools\chromium\src\build\config\win\BUILD.gn
  33.  
  34. Modify these lines around #154 to instead set NOICF and NOREF:
  35.  
  36. "/OPT:NOREF",
  37. "/OPT:NOICF",
  38.  
  39. ----------------
  40.  
  41. For your first stage PGO build, add the following argument to your build:
  42.  
  43. use_clang_coverage = true
  44.  
  45. Note, Thin/Full LTO is not needed for the first stage, so do not enable it.
  46.  
  47. ----------------
  48.  
  49. Set the following environment variable from the command line:
  50.  
  51. set LLVM_PROFILE_FILE=code-%p.profraw
  52.  
  53. ----------------
  54.  
  55. Compile the build. Reordering likely will fail for chrome.exe, so just copy
  56. chrome.exe from the initialexe directory up to the build directory.
  57.  
  58. copy D:\depot_tools\chromium\src\out\pgo\initialexe\chrome.exe
  59. D:\depot_tools\chromium\src\out\pgo\chrome.exe
  60.  
  61. ----------------
  62.  
  63. Go to the build directory, and profile the build as desired.
  64.  
  65. chrome.exe ----no-sandbox
  66.  
  67. ----------------
  68.  
  69. Copy llvm-profdata.exe from your LLVM bin directory into the build
  70. directory, and merge the raw profile data files.
  71.  
  72. llvm-profdata.exe merge -output=code.profdata code-*.profraw
  73.  
  74. ----------------
  75.  
  76. Edit Chromium's compiler config.
  77.  
  78. D:\depot_tools\chromium\src\build\config\compiler\BUILD.gn
  79.  
  80. Around line #291, locate cflags += [ "/X" ]. Add the following to the next
  81. line:
  82.  
  83. cflags += [ "-fprofile-instr-use=D:/builds/pgo/code.profdata",
  84. "-Wno-profile-instr-unprofiled", "-Wno-error=profile-instr-out-of-date", ]
  85.  
  86. Modify these lines around #1860 to restore ICF and REF:
  87.  
  88. common_optimize_on_ldflags += [ "/OPT:ICF" ] # Redundant COMDAT folding.
  89. common_optimize_on_ldflags += [ "/OPT:REF" ] # Remove unreferenced data.
  90.  
  91. ----------------
  92.  
  93. Edit the Windows build configuration.
  94.  
  95. D:\depot_tools\chromium\src\build\config\win\BUILD.gn
  96.  
  97. Modify these lines around #154 to restore ICF and REF:
  98.  
  99. "/OPT:REF",
  100. "/OPT:ICF",
  101.  
  102. ----------------
  103.  
  104. Modify the build arguments again. Disable the coverage argument.
  105.  
  106. use_clang_coverage = false
  107.  
  108. Enable the ThinLTO arguments if using LTO.
  109.  
  110. use_thin_lto = true
  111. thin_lto_enable_optimizations = true
  112.  
  113. ----------------
  114.  
  115. Run the build process again. Enjoy the PGO build.... hopefully. :)
  116.  
  117. ----------------
  118.  
  119. Save the code.profdata file. It should be usable for upto a week or two (or
  120. more; YMMV) of build revisions without too much concern.
  121.  
  122. Just remember to insert the profile use directive into the compiler config
  123. again when building.
  124.  
  125. cflags += [
  126. "-fprofile-instr-use=D:/depot_tools/chromium/src/out/pgo/code.profdata",
  127. "-Wno-profile-instr-unprofiled", "-Wno-error=profile-instr-out-of-date", ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement