Turn on IBC and enforce PGO in official and release builds. (#22843)
authorJeremy Koritzinsky <jkoritzinsky@gmail.com>
Fri, 1 Mar 2019 16:48:49 +0000 (08:48 -0800)
committerGitHub <noreply@github.com>
Fri, 1 Mar 2019 16:48:49 +0000 (08:48 -0800)
* Enable pgocheck to run on python 3.

* Enable IBC optimizations in official builds and enforce PGO in release builds on platforms where pgocheck.py works.

* Only enable IBC on Windows x64/x86.

eng/build-job.yml
src/scripts/pgocheck.py

index d14ffc1..8f4fa5d 100644 (file)
@@ -72,9 +72,21 @@ jobs:
         value: $(buildConfigUpper)
     - name: officialBuildIdArg
       value: ''
+    - name: ibcOptimizeArg
+      value: ''
     - ${{ if and(eq(variables['System.TeamProject'], 'internal'), ne(variables['Build.Reason'], 'PullRequest')) }}:
       - name: officialBuildIdArg
         value: '-officialbuildid=$(Build.BuildNumber)'
+      # IBCMerge is currently Windows-only and x86/x64-only
+      - ${{ if and(eq(parameters.osGroup, 'Windows_NT'), or(eq(parameters.archType, 'x64'), eq(parameters.archType, 'x86'))) }}:
+        - name: ibcOptimizeArg
+          value: '-ibcoptimize'
+    - name: enforcePgoArg
+      value: ''
+    # The EnforcePGO script is only supported on Windows and is not supported on arm or arm64.
+    - ${{ if and(eq(parameters.buildConfig, 'Release'), and(eq(parameters.osGroup, 'Windows_NT'), not(or(eq(parameters.archType, 'arm64'), eq(parameters.archType, 'arm'))))) }}:
+      - name: enforcePgoArg
+        value: '-enforcepgo'
 
     steps:
 
@@ -100,8 +112,7 @@ jobs:
             # Once we are using Arcade, use DotNetCoreSdkDir instead, as we do below.
             DotNetBootstrapCliTarPath: /dotnet-sdk-freebsd-x64.tar
     - ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
-      # TODO: IBCOptimize? EnforcePGO? file logging parameters?
-      - script: set __TestIntermediateDir=int&&build.cmd $(buildConfig) $(archType) -skiptests -skipbuildpackages $(officialBuildIdArg)
+      - script: set __TestIntermediateDir=int&&build.cmd $(buildConfig) $(archType) -skiptests -skipbuildpackages $(officialBuildIdArg) $(ibcOptimizeArg) $(enforcePgoArg)
         displayName: Build product
 
     # Sign on Windows
index d408e6e..39cb0f2 100644 (file)
@@ -26,7 +26,9 @@ pgo_pattern_str = r'coffgrp(?:\s+[0-9A-F]+){4}\s+\((\S*)\)'
 pgo_pattern = re.compile(pgo_pattern_str)
 
 def was_compiled_with_pgo(filename):
-    headers = subprocess.check_output(["link", "/dump", "/headers", filename])
+    # When running on Python 3, check_output returns a bytes object, which we need to
+    # decode to a string object.
+    headers = subprocess.check_output(["link", "/dump", "/headers", filename]).decode('utf-8')
     
     match = pgo_pattern.search(headers)