Build system support for LTO
authorkrollin@apple.com <krollin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Aug 2018 17:16:17 +0000 (17:16 +0000)
committerkrollin@apple.com <krollin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Aug 2018 17:16:17 +0000 (17:16 +0000)
commit87505643c3722883adc7666d360a98003690c969
tree0138781ae1762bc622f85d32b8bcfb894ff011ec
parent993b9d47bc322148f5ee04fb3acf8df759b1a4b0
Build system support for LTO
https://bugs.webkit.org/show_bug.cgi?id=187785
<rdar://problem/42353132>

Reviewed by Dan Bernstein.

.:

Add support for building WebKit with LTO (Link Time Optimization) on
macOS and iOS. Both variations are supported: "full" (which performs
all the optimizations it can regardless of the cost) and "thin" (which
sacrifices some optimizations in order to recover build time and
memory usage).

By default, LTO is disabled for Debug and Release builds, but is
enabled for Production builds. For Debug and Release builds, LTO is
controlled as follows:

- When using `make` from the command line, include
  WK_LTO_MODE={none,thin,full}. For example, `make WK_LTO_MODE=full
  release`. As when specifying debug/release, the LTO configuration
  information is written to the WebKitBuild directory and is used as
  the default on the next build if a new setting is not specified.

- When using `build-webkit`, include --lto-mode={none,thin,full} on
  the command line. For example, `build-webkit --lto-mode=full ...`.

- When using Xcode, create a configuration file called
  LocalOverrides.xcconfig at the root level of your WebKit checkout
  directory. Include within it a line that says:

    WK_LTO_MODE={none,thin,full}

  For example:

    WK_LTO_MODE=full

Note that LocalOverrides.xcconfig is included in the .gitignore file,
so you won't accidentally check your changes into source control.

Enabling LTO can greatly increase build times, especially when using
"full" LTO with 32GB or RAM or less. Following is a table of full
build times for a Release build on a fully decked-out 2017 iMac Pro:

    LTO     macOS      iOS
    -----  -------   -------
    None:   9m 11s   14m 11s
    Thin:  11m 44s   17m 30s
    Full:  21m 39s   28m 56s

Incremental times are affected even more greatly. The actual
optimization and compilation of LLVM bitcode is moved to the link
phase, meaning that the link phase, which previously took only
seconds, can now take many minutes. It's for this reason that LTO is
not enabled in Debug and Release builds, since incremental builds are
an integral part of those configurations. However, using the
mechanisms described above, developers can perform optional LTO builds
if needed to track down build or runtime issues in that configuration.

* .gitignore: Include LocalOverrides.xcconfig.
* Makefile.shared: Add support for WK_LTO_MODE on the command line.

Source/bmalloc:

Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
LTO.

* Configurations/Base.xcconfig:
* Configurations/DebugRelease.xcconfig:

Source/JavaScriptCore:

Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
LTO.

* Configurations/Base.xcconfig:
* Configurations/DebugRelease.xcconfig:

Source/ThirdParty/ANGLE:

Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
LTO.

* Configurations/Base.xcconfig:
* Configurations/DebugRelease.xcconfig:

Source/ThirdParty/libwebrtc:

Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
LTO.

* Configurations/Base.xcconfig:
* Configurations/DebugRelease.xcconfig:

Source/WebCore:

Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
LTO.

No new tests -- no new WebKit functionality.

* Configurations/Base.xcconfig:
* Configurations/DebugRelease.xcconfig:

Source/WebCore/PAL:

Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
LTO.

* Configurations/Base.xcconfig:
* Configurations/DebugRelease.xcconfig:

Source/WebInspectorUI:

Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
LTO.

* Configurations/Base.xcconfig:
* Configurations/DebugRelease.xcconfig:

Source/WebKit:

Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
LTO.

* Configurations/Base.xcconfig:
* Configurations/DebugRelease.xcconfig:

Source/WebKitLegacy/mac:

Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
LTO.

* Configurations/Base.xcconfig:
* Configurations/DebugRelease.xcconfig:

Source/WTF:

Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
LTO.

* Configurations/Base.xcconfig:
* Configurations/DebugRelease.xcconfig:

Tools:

Add tools/scripts support for controlling LTO builds.

* Scripts/build-webkit: Add --lto-mode={none,thin,full}.
* Scripts/set-webkit-configuration: Add support for saving LTO
configuration to WebKitBuild/LTO.
* Scripts/webkitdirs.pm: Add support for reading configuration from
WebKitBuild/LTO and providing it to xcodebuild.
(determineLTOMode):
(ltoMode):
(XcodeOptions):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235381 268f45cc-cd09-0410-ab3c-d52691b4dbfc
37 files changed:
.gitignore
ChangeLog
Makefile.shared
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/Configurations/Base.xcconfig
Source/JavaScriptCore/Configurations/DebugRelease.xcconfig
Source/ThirdParty/ANGLE/ChangeLog
Source/ThirdParty/ANGLE/Configurations/Base.xcconfig
Source/ThirdParty/ANGLE/Configurations/DebugRelease.xcconfig
Source/ThirdParty/libwebrtc/ChangeLog
Source/ThirdParty/libwebrtc/Configurations/Base.xcconfig
Source/ThirdParty/libwebrtc/Configurations/DebugRelease.xcconfig
Source/WTF/ChangeLog
Source/WTF/Configurations/Base.xcconfig
Source/WTF/Configurations/DebugRelease.xcconfig
Source/WebCore/ChangeLog
Source/WebCore/Configurations/Base.xcconfig
Source/WebCore/Configurations/DebugRelease.xcconfig
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/Configurations/Base.xcconfig
Source/WebCore/PAL/Configurations/DebugRelease.xcconfig
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Configurations/Base.xcconfig
Source/WebInspectorUI/Configurations/DebugRelease.xcconfig
Source/WebKit/ChangeLog
Source/WebKit/Configurations/Base.xcconfig
Source/WebKit/Configurations/DebugRelease.xcconfig
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/Configurations/Base.xcconfig
Source/WebKitLegacy/mac/Configurations/DebugRelease.xcconfig
Source/bmalloc/ChangeLog
Source/bmalloc/Configurations/Base.xcconfig
Source/bmalloc/Configurations/DebugRelease.xcconfig
Tools/ChangeLog
Tools/Scripts/build-webkit
Tools/Scripts/set-webkit-configuration
Tools/Scripts/webkitdirs.pm