diff options
author | Ronald Oussoren <ronaldoussoren@mac.com> | 2021-05-03 03:43:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-03 03:43:52 (GMT) |
commit | e08059edef3be07ada3058d68ad2c9cc13b7418e (patch) | |
tree | fa3a6f9250e42fb495f46458ed5ba936ed2e5010 /Mac | |
parent | 8c598dbb9483bcfcb88fc579ebf27821d8861465 (diff) | |
download | cpython-e08059edef3be07ada3058d68ad2c9cc13b7418e.zip cpython-e08059edef3be07ada3058d68ad2c9cc13b7418e.tar.gz cpython-e08059edef3be07ada3058d68ad2c9cc13b7418e.tar.bz2 |
bpo-42235: [macOS] Use LTO/PGO in build-installer.py with new enough compilers (GH-23079)
With recent enough compilers we can build binaries with
LTO/PGO on macOS. This patch enables this when building on
macOS 10.15 or later (Xcode 11 or later).
Diffstat (limited to 'Mac')
-rwxr-xr-x | Mac/BuildScript/build-installer.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py index 540b5a0..ff62096 100755 --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -436,6 +436,14 @@ def library_recipes(): return result +def compilerCanOptimize(): + """ + Return True iff the default Xcode version can use PGO and LTO + """ + # bpo-42235: The version check is pretty conservative, can be + # adjusted after testing + mac_ver = tuple(map(int, platform.mac_ver()[0].split('.'))) + return mac_ver >= (10, 15) # Instructions for building packages inside the .mpkg. def pkg_recipes(): @@ -1176,6 +1184,7 @@ def buildPython(): "%s " "%s " "%s " + "%s " "LDFLAGS='-g -L%s/libraries/usr/local/lib' " "CFLAGS='-g -I%s/libraries/usr/local/include' 2>&1"%( shellQuote(os.path.join(SRCDIR, 'configure')), @@ -1188,6 +1197,7 @@ def buildPython(): shellQuote(WORKDIR)[1:-1],))[internalTk()], (' ', "--with-tcltk-libs='-L%s/libraries/usr/local/lib -ltcl8.6 -ltk8.6'"%( shellQuote(WORKDIR)[1:-1],))[internalTk()], + (' ', "--enable-optimizations --with-lto")[compilerCanOptimize()], shellQuote(WORKDIR)[1:-1], shellQuote(WORKDIR)[1:-1])) |