Title: [235381] trunk
Revision
235381
Author
krol...@apple.com
Date
2018-08-27 10:16:17 -0700 (Mon, 27 Aug 2018)

Log Message

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/_javascript_Core:

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):

Modified Paths

Diff

Modified: trunk/.gitignore (235380 => 235381)


--- trunk/.gitignore	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/.gitignore	2018-08-27 17:16:17 UTC (rev 235381)
@@ -48,3 +48,6 @@
 
 # Ignore YouCompleteMe symlinks
 .ycm_extra_conf.py
+
+# Local overrides configuration files
+LocalOverrides.xcconfig

Modified: trunk/ChangeLog (235380 => 235381)


--- trunk/ChangeLog	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/ChangeLog	2018-08-27 17:16:17 UTC (rev 235381)
@@ -1,3 +1,65 @@
+2018-08-27  Keith Rollin  <krol...@apple.com>
+
+        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.
+
 2018-08-27  Michael Catanzaro  <mcatanz...@igalia.com>
 
         Unreviewed, bump WPE/GTK version numbers

Modified: trunk/Makefile.shared (235380 => 235381)


--- trunk/Makefile.shared	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Makefile.shared	2018-08-27 17:16:17 UTC (rev 235381)
@@ -56,6 +56,14 @@
 endif
 endif
 
+ifeq ($(WK_LTO_MODE),full)
+WK_LTO_OPTION=--lto-mode=full
+else ifeq ($(WK_LTO_MODE),thin)
+WK_LTO_OPTION=--lto-mode=thin
+else ifeq ($(WK_LTO_MODE),none)
+WK_LTO_OPTION=--lto-mode=none
+endif
+
 export DSYMUTIL_NUM_THREADS = $(shell sysctl -n hw.activecpu)
 
 # Run xcodebuild with the same PATH with which the Xcode IDE runs, to mitigate unnecessary rebuilds due to PATH differences.
@@ -66,15 +74,15 @@
 	( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
 
 debug d development dev develop: force
-	$(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION)
+	$(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $(WK_LTO_OPTION)
 	( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
 
 release r deployment dep deploy: force
-	$(SCRIPTS_PATH)/set-webkit-configuration --release $(ASAN_OPTION)
+	$(SCRIPTS_PATH)/set-webkit-configuration --release $(ASAN_OPTION) $(WK_LTO_OPTION)
 	( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
 
 analyze:
-	$(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION)
+	$(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $(WK_LTO_OPTION)
 ifndef PATH_TO_SCAN_BUILD
 	( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) RUN_CLANG_STATIC_ANALYZER=YES | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
 else

Modified: trunk/Source/_javascript_Core/ChangeLog (235380 => 235381)


--- trunk/Source/_javascript_Core/ChangeLog	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-08-27 17:16:17 UTC (rev 235381)
@@ -1,3 +1,17 @@
+2018-08-27  Keith Rollin  <krol...@apple.com>
+
+        Build system support for LTO
+        https://bugs.webkit.org/show_bug.cgi?id=187785
+        <rdar://problem/42353132>
+
+        Reviewed by Dan Bernstein.
+
+        Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
+        LTO.
+
+        * Configurations/Base.xcconfig:
+        * Configurations/DebugRelease.xcconfig:
+
 2018-08-27  Patrick Griffis  <pgrif...@igalia.com>
 
         [GTK][JSC] Add warn_unused_result attribute to some APIs

Modified: trunk/Source/_javascript_Core/Configurations/Base.xcconfig (235380 => 235381)


--- trunk/Source/_javascript_Core/Configurations/Base.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/_javascript_Core/Configurations/Base.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -178,3 +178,18 @@
 WK_COCOA_TOUCH_appletvos = cocoatouch;
 WK_COCOA_TOUCH_appletvsimulator = cocoatouch;
 WK_IS_COCOA_TOUCH = $(WK_NOT_$(WK_EMPTY_$(WK_COCOA_TOUCH)));
+
+LLVM_LTO = $(WK_LLVM_LTO_$(WK_XCODE_SUPPORTS_LTO));
+WK_LLVM_LTO_NO = NO;
+WK_LLVM_LTO_YES = $(WK_USER_LTO_MODE);
+
+WK_XCODE_SUPPORTS_LTO = $(WK_NOT_$(WK_XCODE_VERSION_BEFORE_9_$(XCODE_VERSION_MAJOR)));
+WK_XCODE_VERSION_BEFORE_9_0800 = YES;
+WK_XCODE_VERSION_BEFORE_9_0700 = YES;
+
+WK_USER_LTO_MODE = $(WK_USER_LTO_MODE_$(WK_LTO_MODE));
+WK_USER_LTO_MODE_full = NO; // Disable LTO for _javascript_ due to <rdar://problem/24543547>
+WK_USER_LTO_MODE_thin = NO; // Disable LTO for _javascript_ due to <rdar://problem/24543547>
+WK_USER_LTO_MODE_none = NO;
+WK_USER_LTO_MODE_ = $(WK_DEFAULT_LTO_MODE);
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_full);

Modified: trunk/Source/_javascript_Core/Configurations/DebugRelease.xcconfig (235380 => 235381)


--- trunk/Source/_javascript_Core/Configurations/DebugRelease.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/_javascript_Core/Configurations/DebugRelease.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -22,6 +22,7 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
 #include "Base.xcconfig"
+#include? "../../../LocalOverrides.xcconfig"
 
 ARCHS = $(ARCHS_STANDARD_32_64_BIT);
 
@@ -44,5 +45,7 @@
 
 WK_RELOCATABLE_FRAMEWORKS = YES;
 
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_none);
+
 WK_CCACHE_DIR = $(SRCROOT)/../../Tools/ccache;
 #include "../../../Tools/ccache/ccache.xcconfig"

Modified: trunk/Source/ThirdParty/ANGLE/ChangeLog (235380 => 235381)


--- trunk/Source/ThirdParty/ANGLE/ChangeLog	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/ThirdParty/ANGLE/ChangeLog	2018-08-27 17:16:17 UTC (rev 235381)
@@ -1,3 +1,17 @@
+2018-08-27  Keith Rollin  <krol...@apple.com>
+
+        Build system support for LTO
+        https://bugs.webkit.org/show_bug.cgi?id=187785
+        <rdar://problem/42353132>
+
+        Reviewed by Dan Bernstein.
+
+        Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
+        LTO.
+
+        * Configurations/Base.xcconfig:
+        * Configurations/DebugRelease.xcconfig:
+
 2018-08-03  Alex Christensen  <achristen...@webkit.org>
 
         Fix spelling of "overridden"

Modified: trunk/Source/ThirdParty/ANGLE/Configurations/Base.xcconfig (235380 => 235381)


--- trunk/Source/ThirdParty/ANGLE/Configurations/Base.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/ThirdParty/ANGLE/Configurations/Base.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -81,3 +81,18 @@
 WK_PLATFORM_NAME = $(WK_PLATFORM_NAME_USE_ALTERNATE_FRAMEWORKS_DIR_$(WK_USE_ALTERNATE_FRAMEWORKS_DIR));
 WK_PLATFORM_NAME_USE_ALTERNATE_FRAMEWORKS_DIR_YES = iosmac;
 WK_PLATFORM_NAME_USE_ALTERNATE_FRAMEWORKS_DIR_NO = $(PLATFORM_NAME);
+
+LLVM_LTO = $(WK_LLVM_LTO_$(WK_XCODE_SUPPORTS_LTO));
+WK_LLVM_LTO_NO = NO;
+WK_LLVM_LTO_YES = $(WK_USER_LTO_MODE);
+
+WK_XCODE_SUPPORTS_LTO = $(WK_NOT_$(WK_XCODE_VERSION_BEFORE_9_$(XCODE_VERSION_MAJOR)));
+WK_XCODE_VERSION_BEFORE_9_0800 = YES;
+WK_XCODE_VERSION_BEFORE_9_0700 = YES;
+
+WK_USER_LTO_MODE = $(WK_USER_LTO_MODE_$(WK_LTO_MODE));
+WK_USER_LTO_MODE_full = YES;
+WK_USER_LTO_MODE_thin = YES_THIN;
+WK_USER_LTO_MODE_none = NO;
+WK_USER_LTO_MODE_ = $(WK_DEFAULT_LTO_MODE);
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_full);

Modified: trunk/Source/ThirdParty/ANGLE/Configurations/DebugRelease.xcconfig (235380 => 235381)


--- trunk/Source/ThirdParty/ANGLE/Configurations/DebugRelease.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/ThirdParty/ANGLE/Configurations/DebugRelease.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -1,4 +1,5 @@
 #include "Base.xcconfig"
+#include? "../../../../LocalOverrides.xcconfig"
 
 ARCHS = $(ARCHS_STANDARD_32_64_BIT);
 
@@ -19,5 +20,7 @@
 SDKROOT_ = macosx;
 SDKROOT_YES = macosx.internal;
 
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_none);
+
 WK_CCACHE_DIR = $(SRCROOT)/../../../Tools/ccache;
 #include "../../../../Tools/ccache/ccache.xcconfig"

Modified: trunk/Source/ThirdParty/libwebrtc/ChangeLog (235380 => 235381)


--- trunk/Source/ThirdParty/libwebrtc/ChangeLog	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/ThirdParty/libwebrtc/ChangeLog	2018-08-27 17:16:17 UTC (rev 235381)
@@ -1,3 +1,17 @@
+2018-08-27  Keith Rollin  <krol...@apple.com>
+
+        Build system support for LTO
+        https://bugs.webkit.org/show_bug.cgi?id=187785
+        <rdar://problem/42353132>
+
+        Reviewed by Dan Bernstein.
+
+        Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
+        LTO.
+
+        * Configurations/Base.xcconfig:
+        * Configurations/DebugRelease.xcconfig:
+
 2018-08-23  youenn fablet  <youe...@gmail.com>
 
         Remove libwebrtc unneeded .exe file.

Modified: trunk/Source/ThirdParty/libwebrtc/Configurations/Base.xcconfig (235380 => 235381)


--- trunk/Source/ThirdParty/libwebrtc/Configurations/Base.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/ThirdParty/libwebrtc/Configurations/Base.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -103,3 +103,18 @@
 
 WK_OVERRIDE_FRAMEWORKS_DIR = $(WK_OVERRIDE_FRAMEWORKS_DIR_USE_STAGING_INSTALL_PATH_$(USE_STAGING_INSTALL_PATH));
 WK_OVERRIDE_FRAMEWORKS_DIR_USE_STAGING_INSTALL_PATH_YES = $(SYSTEM_LIBRARY_DIR)/StagedFrameworks/Safari;
+
+LLVM_LTO = $(WK_LLVM_LTO_$(WK_XCODE_SUPPORTS_LTO));
+WK_LLVM_LTO_NO = NO;
+WK_LLVM_LTO_YES = $(WK_USER_LTO_MODE);
+
+WK_XCODE_SUPPORTS_LTO = $(WK_NOT_$(WK_XCODE_VERSION_BEFORE_9_$(XCODE_VERSION_MAJOR)));
+WK_XCODE_VERSION_BEFORE_9_0800 = YES;
+WK_XCODE_VERSION_BEFORE_9_0700 = YES;
+
+WK_USER_LTO_MODE = $(WK_USER_LTO_MODE_$(WK_LTO_MODE));
+WK_USER_LTO_MODE_full = YES;
+WK_USER_LTO_MODE_thin = YES_THIN;
+WK_USER_LTO_MODE_none = NO;
+WK_USER_LTO_MODE_ = $(WK_DEFAULT_LTO_MODE);
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_full);

Modified: trunk/Source/ThirdParty/libwebrtc/Configurations/DebugRelease.xcconfig (235380 => 235381)


--- trunk/Source/ThirdParty/libwebrtc/Configurations/DebugRelease.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/ThirdParty/libwebrtc/Configurations/DebugRelease.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -1,4 +1,5 @@
 #include "Base.xcconfig"
+#include? "../../../../LocalOverrides.xcconfig"
 
 ARCHS = $(ARCHS_STANDARD_32_64_BIT);
 
@@ -21,5 +22,7 @@
 
 WK_RELOCATABLE_FRAMEWORKS = YES;
 
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_none);
+
 WK_CCACHE_DIR = $(SRCROOT)/../../../Tools/ccache;
 #include "../../../../Tools/ccache/ccache.xcconfig"

Modified: trunk/Source/WTF/ChangeLog (235380 => 235381)


--- trunk/Source/WTF/ChangeLog	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WTF/ChangeLog	2018-08-27 17:16:17 UTC (rev 235381)
@@ -1,3 +1,17 @@
+2018-08-27  Keith Rollin  <krol...@apple.com>
+
+        Build system support for LTO
+        https://bugs.webkit.org/show_bug.cgi?id=187785
+        <rdar://problem/42353132>
+
+        Reviewed by Dan Bernstein.
+
+        Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
+        LTO.
+
+        * Configurations/Base.xcconfig:
+        * Configurations/DebugRelease.xcconfig:
+
 2018-08-25  Yusuke Suzuki  <yusukesuz...@slowstart.org>
 
         Shrink size of XMLHttpRequest

Modified: trunk/Source/WTF/Configurations/Base.xcconfig (235380 => 235381)


--- trunk/Source/WTF/Configurations/Base.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WTF/Configurations/Base.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -145,3 +145,18 @@
 WK_PLATFORM_NAME = $(WK_PLATFORM_NAME_USE_ALTERNATE_FRAMEWORKS_DIR_$(WK_USE_ALTERNATE_FRAMEWORKS_DIR));
 WK_PLATFORM_NAME_USE_ALTERNATE_FRAMEWORKS_DIR_YES = iosmac;
 WK_PLATFORM_NAME_USE_ALTERNATE_FRAMEWORKS_DIR_NO = $(PLATFORM_NAME);
+
+LLVM_LTO = $(WK_LLVM_LTO_$(WK_XCODE_SUPPORTS_LTO));
+WK_LLVM_LTO_NO = NO;
+WK_LLVM_LTO_YES = $(WK_USER_LTO_MODE);
+
+WK_XCODE_SUPPORTS_LTO = $(WK_NOT_$(WK_XCODE_VERSION_BEFORE_9_$(XCODE_VERSION_MAJOR)));
+WK_XCODE_VERSION_BEFORE_9_0800 = YES;
+WK_XCODE_VERSION_BEFORE_9_0700 = YES;
+
+WK_USER_LTO_MODE = $(WK_USER_LTO_MODE_$(WK_LTO_MODE));
+WK_USER_LTO_MODE_full = YES;
+WK_USER_LTO_MODE_thin = YES_THIN;
+WK_USER_LTO_MODE_none = NO;
+WK_USER_LTO_MODE_ = $(WK_DEFAULT_LTO_MODE);
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_full);

Modified: trunk/Source/WTF/Configurations/DebugRelease.xcconfig (235380 => 235381)


--- trunk/Source/WTF/Configurations/DebugRelease.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WTF/Configurations/DebugRelease.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -22,6 +22,7 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
 #include "Base.xcconfig"
+#include? "../../../LocalOverrides.xcconfig"
 
 ARCHS = $(ARCHS_STANDARD_32_64_BIT);
 _ONLY_ACTIVE_ARCH_ = YES;
@@ -41,5 +42,7 @@
 SDKROOT_ = macosx;
 SDKROOT_YES = macosx.internal;
 
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_none);
+
 WK_CCACHE_DIR = $(SRCROOT)/../../Tools/ccache;
 #include "../../../Tools/ccache/ccache.xcconfig"

Modified: trunk/Source/WebCore/ChangeLog (235380 => 235381)


--- trunk/Source/WebCore/ChangeLog	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WebCore/ChangeLog	2018-08-27 17:16:17 UTC (rev 235381)
@@ -1,3 +1,19 @@
+2018-08-27  Keith Rollin  <krol...@apple.com>
+
+        Build system support for LTO
+        https://bugs.webkit.org/show_bug.cgi?id=187785
+        <rdar://problem/42353132>
+
+        Reviewed by Dan Bernstein.
+
+        Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
+        LTO.
+
+        No new tests -- no new WebKit functionality.
+
+        * Configurations/Base.xcconfig:
+        * Configurations/DebugRelease.xcconfig:
+
 2018-08-27  Daniel Bates  <daba...@apple.com>
 
         [iOS] Make color of spelling dots match UIKit

Modified: trunk/Source/WebCore/Configurations/Base.xcconfig (235380 => 235381)


--- trunk/Source/WebCore/Configurations/Base.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WebCore/Configurations/Base.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -145,3 +145,26 @@
 WK_COCOA_TOUCH_appletvos = cocoatouch;
 WK_COCOA_TOUCH_appletvsimulator = cocoatouch;
 WK_IS_COCOA_TOUCH = $(WK_NOT_$(WK_EMPTY_$(WK_COCOA_TOUCH)));
+
+// Attempting to build WebCore with full LTO for i386 results in the following
+// linker error, so we drop down to "thin" for that architecture if we were to
+// otherwise attempt to use "full".
+//
+// LLVM ERROR: Section too large, can't encode r_address (0x1000216) into 24 bits of scattered relocation entry.
+// clang: error: linker command failed with exit code 1 (use -v to see invocation)
+
+LLVM_LTO = $(WK_LLVM_LTO_$(WK_XCODE_SUPPORTS_LTO));
+WK_LLVM_LTO_NO = NO;
+WK_LLVM_LTO_YES = $(WK_USER_LTO_MODE);
+
+WK_XCODE_SUPPORTS_LTO = $(WK_NOT_$(WK_XCODE_VERSION_BEFORE_9_$(XCODE_VERSION_MAJOR)));
+WK_XCODE_VERSION_BEFORE_9_0800 = YES;
+WK_XCODE_VERSION_BEFORE_9_0700 = YES;
+
+WK_USER_LTO_MODE = $(WK_USER_LTO_MODE_$(WK_LTO_MODE));
+WK_USER_LTO_MODE_full[arch=i386] = $(WK_USER_LTO_MODE_thin);
+WK_USER_LTO_MODE_full = YES;
+WK_USER_LTO_MODE_thin = YES_THIN;
+WK_USER_LTO_MODE_none = NO;
+WK_USER_LTO_MODE_ = $(WK_DEFAULT_LTO_MODE);
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_full);

Modified: trunk/Source/WebCore/Configurations/DebugRelease.xcconfig (235380 => 235381)


--- trunk/Source/WebCore/Configurations/DebugRelease.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WebCore/Configurations/DebugRelease.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -22,6 +22,7 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "Base.xcconfig"
+#include? "../../../LocalOverrides.xcconfig"
 
 ARCHS = $(ARCHS_STANDARD_32_64_BIT);
 
@@ -44,5 +45,7 @@
 
 WK_RELOCATABLE_FRAMEWORKS = YES;
 
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_none);
+
 WK_CCACHE_DIR = $(SRCROOT)/../../Tools/ccache;
 #include "../../../Tools/ccache/ccache.xcconfig"

Modified: trunk/Source/WebCore/PAL/ChangeLog (235380 => 235381)


--- trunk/Source/WebCore/PAL/ChangeLog	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WebCore/PAL/ChangeLog	2018-08-27 17:16:17 UTC (rev 235381)
@@ -1,3 +1,17 @@
+2018-08-27  Keith Rollin  <krol...@apple.com>
+
+        Build system support for LTO
+        https://bugs.webkit.org/show_bug.cgi?id=187785
+        <rdar://problem/42353132>
+
+        Reviewed by Dan Bernstein.
+
+        Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
+        LTO.
+
+        * Configurations/Base.xcconfig:
+        * Configurations/DebugRelease.xcconfig:
+
 2018-08-26  Andy Estes  <aes...@apple.com>
 
         [Apple Pay] Introduce new values for -apple-pay-button-type

Modified: trunk/Source/WebCore/PAL/Configurations/Base.xcconfig (235380 => 235381)


--- trunk/Source/WebCore/PAL/Configurations/Base.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WebCore/PAL/Configurations/Base.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -142,3 +142,26 @@
 WK_COCOA_TOUCH_appletvos = cocoatouch;
 WK_COCOA_TOUCH_appletvsimulator = cocoatouch;
 WK_IS_COCOA_TOUCH = $(WK_NOT_$(WK_EMPTY_$(WK_COCOA_TOUCH)));
+
+// Attempting to build WebCore with full LTO for i386 results in the following
+// linker error, so we drop down to "thin" for that architecture if we were to
+// otherwise attempt to use "full".
+//
+// LLVM ERROR: Section too large, can't encode r_address (0x1000216) into 24 bits of scattered relocation entry.
+// clang: error: linker command failed with exit code 1 (use -v to see invocation)
+
+LLVM_LTO = $(WK_LLVM_LTO_$(WK_XCODE_SUPPORTS_LTO));
+WK_LLVM_LTO_NO = NO;
+WK_LLVM_LTO_YES = $(WK_USER_LTO_MODE);
+
+WK_XCODE_SUPPORTS_LTO = $(WK_NOT_$(WK_XCODE_VERSION_BEFORE_9_$(XCODE_VERSION_MAJOR)));
+WK_XCODE_VERSION_BEFORE_9_0800 = YES;
+WK_XCODE_VERSION_BEFORE_9_0700 = YES;
+
+WK_USER_LTO_MODE = $(WK_USER_LTO_MODE_$(WK_LTO_MODE));
+WK_USER_LTO_MODE_full[arch=i386] = $(WK_USER_LTO_MODE_thin);
+WK_USER_LTO_MODE_full = YES;
+WK_USER_LTO_MODE_thin = YES_THIN;
+WK_USER_LTO_MODE_none = NO;
+WK_USER_LTO_MODE_ = $(WK_DEFAULT_LTO_MODE);
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_full);

Modified: trunk/Source/WebCore/PAL/Configurations/DebugRelease.xcconfig (235380 => 235381)


--- trunk/Source/WebCore/PAL/Configurations/DebugRelease.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WebCore/PAL/Configurations/DebugRelease.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -22,6 +22,7 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "Base.xcconfig"
+#include? "../../../../LocalOverrides.xcconfig"
 
 ARCHS = $(ARCHS_STANDARD_32_64_BIT);
 
@@ -44,5 +45,7 @@
 
 WK_RELOCATABLE_FRAMEWORKS = YES;
 
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_none);
+
 WK_CCACHE_DIR = $(SRCROOT)/../../../Tools/ccache;
 #include "../../../../Tools/ccache/ccache.xcconfig"

Modified: trunk/Source/WebInspectorUI/ChangeLog (235380 => 235381)


--- trunk/Source/WebInspectorUI/ChangeLog	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WebInspectorUI/ChangeLog	2018-08-27 17:16:17 UTC (rev 235381)
@@ -1,3 +1,17 @@
+2018-08-27  Keith Rollin  <krol...@apple.com>
+
+        Build system support for LTO
+        https://bugs.webkit.org/show_bug.cgi?id=187785
+        <rdar://problem/42353132>
+
+        Reviewed by Dan Bernstein.
+
+        Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
+        LTO.
+
+        * Configurations/Base.xcconfig:
+        * Configurations/DebugRelease.xcconfig:
+
 2018-08-27  Devin Rousso  <drou...@apple.com>
 
         Web Inspector: REGRESSION: virtualized TreeOutline is empty when filtering

Modified: trunk/Source/WebInspectorUI/Configurations/Base.xcconfig (235380 => 235381)


--- trunk/Source/WebInspectorUI/Configurations/Base.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WebInspectorUI/Configurations/Base.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -106,3 +106,18 @@
 WK_COCOA_TOUCH_appletvos = cocoatouch;
 WK_COCOA_TOUCH_appletvsimulator = cocoatouch;
 WK_IS_COCOA_TOUCH = $(WK_NOT_$(WK_EMPTY_$(WK_COCOA_TOUCH)));
+
+LLVM_LTO = $(WK_LLVM_LTO_$(WK_XCODE_SUPPORTS_LTO));
+WK_LLVM_LTO_NO = NO;
+WK_LLVM_LTO_YES = $(WK_USER_LTO_MODE);
+
+WK_XCODE_SUPPORTS_LTO = $(WK_NOT_$(WK_XCODE_VERSION_BEFORE_9_$(XCODE_VERSION_MAJOR)));
+WK_XCODE_VERSION_BEFORE_9_0800 = YES;
+WK_XCODE_VERSION_BEFORE_9_0700 = YES;
+
+WK_USER_LTO_MODE = $(WK_USER_LTO_MODE_$(WK_LTO_MODE));
+WK_USER_LTO_MODE_full = YES;
+WK_USER_LTO_MODE_thin = YES_THIN;
+WK_USER_LTO_MODE_none = NO;
+WK_USER_LTO_MODE_ = $(WK_DEFAULT_LTO_MODE);
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_full);

Modified: trunk/Source/WebInspectorUI/Configurations/DebugRelease.xcconfig (235380 => 235381)


--- trunk/Source/WebInspectorUI/Configurations/DebugRelease.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WebInspectorUI/Configurations/DebugRelease.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -1,4 +1,5 @@
 #include "Base.xcconfig"
+#include? "../../../LocalOverrides.xcconfig"
 
 ARCHS = $(ARCHS_STANDARD_32_64_BIT);
 
@@ -23,3 +24,5 @@
 
 COMBINE_INSPECTOR_RESOURCES = NO;
 COMBINE_TEST_RESOURCES = YES;
+
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_none);

Modified: trunk/Source/WebKit/ChangeLog (235380 => 235381)


--- trunk/Source/WebKit/ChangeLog	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WebKit/ChangeLog	2018-08-27 17:16:17 UTC (rev 235381)
@@ -1,3 +1,17 @@
+2018-08-27  Keith Rollin  <krol...@apple.com>
+
+        Build system support for LTO
+        https://bugs.webkit.org/show_bug.cgi?id=187785
+        <rdar://problem/42353132>
+
+        Reviewed by Dan Bernstein.
+
+        Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
+        LTO.
+
+        * Configurations/Base.xcconfig:
+        * Configurations/DebugRelease.xcconfig:
+
 2018-08-27  Daniel Bates  <daba...@apple.com>
 
         Remove extern variable and simplify state initialization in TextCheckerMac.mm

Modified: trunk/Source/WebKit/Configurations/Base.xcconfig (235380 => 235381)


--- trunk/Source/WebKit/Configurations/Base.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WebKit/Configurations/Base.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -159,3 +159,18 @@
 WK_MACOS_WEAK_FRAMEWORK_ = -weak_framework
 
 WK_USE_RESTRICTED_ENTITLEMENTS = $(USE_INTERNAL_SDK);
+
+LLVM_LTO = $(WK_LLVM_LTO_$(WK_XCODE_SUPPORTS_LTO));
+WK_LLVM_LTO_NO = NO;
+WK_LLVM_LTO_YES = $(WK_USER_LTO_MODE);
+
+WK_XCODE_SUPPORTS_LTO = $(WK_NOT_$(WK_XCODE_VERSION_BEFORE_9_$(XCODE_VERSION_MAJOR)));
+WK_XCODE_VERSION_BEFORE_9_0800 = YES;
+WK_XCODE_VERSION_BEFORE_9_0700 = YES;
+
+WK_USER_LTO_MODE = $(WK_USER_LTO_MODE_$(WK_LTO_MODE));
+WK_USER_LTO_MODE_full = YES;
+WK_USER_LTO_MODE_thin = YES_THIN;
+WK_USER_LTO_MODE_none = NO;
+WK_USER_LTO_MODE_ = $(WK_DEFAULT_LTO_MODE);
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_full);

Modified: trunk/Source/WebKit/Configurations/DebugRelease.xcconfig (235380 => 235381)


--- trunk/Source/WebKit/Configurations/DebugRelease.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WebKit/Configurations/DebugRelease.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -22,6 +22,7 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
 #include "Base.xcconfig"
+#include? "../../../LocalOverrides.xcconfig"
 
 ARCHS = $(ARCHS_STANDARD_32_64_BIT);
 
@@ -55,5 +56,7 @@
 WK_WEBCONTENT_SERVICE_NEEDS_XPC_DOMAIN_EXTENSION_ENTITLEMENT = NO;
 WK_WEBCONTENT_SERVICE_NEEDS_VERSIONED_FRAMEWORK_PATH_LDFLAG[sdk=macosx*] = YES;
 
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_none);
+
 WK_CCACHE_DIR = $(SRCROOT)/../../Tools/ccache;
 #include "../../../Tools/ccache/ccache.xcconfig"

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (235380 => 235381)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2018-08-27 17:16:17 UTC (rev 235381)
@@ -1,3 +1,17 @@
+2018-08-27  Keith Rollin  <krol...@apple.com>
+
+        Build system support for LTO
+        https://bugs.webkit.org/show_bug.cgi?id=187785
+        <rdar://problem/42353132>
+
+        Reviewed by Dan Bernstein.
+
+        Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
+        LTO.
+
+        * Configurations/Base.xcconfig:
+        * Configurations/DebugRelease.xcconfig:
+
 2018-08-24  Ryosuke Niwa  <rn...@webkit.org>
 
         Pass in IsComposed flag to Event constructors

Modified: trunk/Source/WebKitLegacy/mac/Configurations/Base.xcconfig (235380 => 235381)


--- trunk/Source/WebKitLegacy/mac/Configurations/Base.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WebKitLegacy/mac/Configurations/Base.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -143,3 +143,18 @@
 WK_COCOA_TOUCH_appletvos = cocoatouch;
 WK_COCOA_TOUCH_appletvsimulator = cocoatouch;
 WK_IS_COCOA_TOUCH = $(WK_NOT_$(WK_EMPTY_$(WK_COCOA_TOUCH)));
+
+LLVM_LTO = $(WK_LLVM_LTO_$(WK_XCODE_SUPPORTS_LTO));
+WK_LLVM_LTO_NO = NO;
+WK_LLVM_LTO_YES = $(WK_USER_LTO_MODE);
+
+WK_XCODE_SUPPORTS_LTO = $(WK_NOT_$(WK_XCODE_VERSION_BEFORE_9_$(XCODE_VERSION_MAJOR)));
+WK_XCODE_VERSION_BEFORE_9_0800 = YES;
+WK_XCODE_VERSION_BEFORE_9_0700 = YES;
+
+WK_USER_LTO_MODE = $(WK_USER_LTO_MODE_$(WK_LTO_MODE));
+WK_USER_LTO_MODE_full = YES;
+WK_USER_LTO_MODE_thin = YES_THIN;
+WK_USER_LTO_MODE_none = NO;
+WK_USER_LTO_MODE_ = $(WK_DEFAULT_LTO_MODE);
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_full);

Modified: trunk/Source/WebKitLegacy/mac/Configurations/DebugRelease.xcconfig (235380 => 235381)


--- trunk/Source/WebKitLegacy/mac/Configurations/DebugRelease.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/WebKitLegacy/mac/Configurations/DebugRelease.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -22,6 +22,7 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
 #include "Base.xcconfig"
+#include? "../../../../LocalOverrides.xcconfig"
 
 ARCHS = $(ARCHS_STANDARD_32_64_BIT);
 
@@ -44,5 +45,7 @@
 
 WK_RELOCATABLE_FRAMEWORKS = YES;
 
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_none);
+
 WK_CCACHE_DIR = $(SRCROOT)/../../Tools/ccache;
 #include "../../../../Tools/ccache/ccache.xcconfig"

Modified: trunk/Source/bmalloc/ChangeLog (235380 => 235381)


--- trunk/Source/bmalloc/ChangeLog	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/bmalloc/ChangeLog	2018-08-27 17:16:17 UTC (rev 235381)
@@ -1,3 +1,17 @@
+2018-08-27  Keith Rollin  <krol...@apple.com>
+
+        Build system support for LTO
+        https://bugs.webkit.org/show_bug.cgi?id=187785
+        <rdar://problem/42353132>
+
+        Reviewed by Dan Bernstein.
+
+        Update Base.xcconfig and DebugRelease.xcconfig to optionally enable
+        LTO.
+
+        * Configurations/Base.xcconfig:
+        * Configurations/DebugRelease.xcconfig:
+
 2018-08-16  Tomas Popela  <tpop...@redhat.com>
 
         bmalloc: Coverity scan issues

Modified: trunk/Source/bmalloc/Configurations/Base.xcconfig (235380 => 235381)


--- trunk/Source/bmalloc/Configurations/Base.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/bmalloc/Configurations/Base.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -137,3 +137,18 @@
 WK_PLATFORM_NAME = $(WK_PLATFORM_NAME_USE_ALTERNATE_FRAMEWORKS_DIR_$(WK_USE_ALTERNATE_FRAMEWORKS_DIR));
 WK_PLATFORM_NAME_USE_ALTERNATE_FRAMEWORKS_DIR_YES = iosmac;
 WK_PLATFORM_NAME_USE_ALTERNATE_FRAMEWORKS_DIR_NO = $(PLATFORM_NAME);
+
+LLVM_LTO = $(WK_LLVM_LTO_$(WK_XCODE_SUPPORTS_LTO));
+WK_LLVM_LTO_NO = NO;
+WK_LLVM_LTO_YES = $(WK_USER_LTO_MODE);
+
+WK_XCODE_SUPPORTS_LTO = $(WK_NOT_$(WK_XCODE_VERSION_BEFORE_9_$(XCODE_VERSION_MAJOR)));
+WK_XCODE_VERSION_BEFORE_9_0800 = YES;
+WK_XCODE_VERSION_BEFORE_9_0700 = YES;
+
+WK_USER_LTO_MODE = $(WK_USER_LTO_MODE_$(WK_LTO_MODE));
+WK_USER_LTO_MODE_full = YES;
+WK_USER_LTO_MODE_thin = YES_THIN;
+WK_USER_LTO_MODE_none = NO;
+WK_USER_LTO_MODE_ = $(WK_DEFAULT_LTO_MODE);
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_full);

Modified: trunk/Source/bmalloc/Configurations/DebugRelease.xcconfig (235380 => 235381)


--- trunk/Source/bmalloc/Configurations/DebugRelease.xcconfig	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Source/bmalloc/Configurations/DebugRelease.xcconfig	2018-08-27 17:16:17 UTC (rev 235381)
@@ -22,6 +22,7 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
 #include "Base.xcconfig"
+#include? "../../../LocalOverrides.xcconfig"
 
 ARCHS = $(ARCHS_STANDARD_32_64_BIT);
 _ONLY_ACTIVE_ARCH_ = YES;
@@ -41,5 +42,7 @@
 SDKROOT_ = macosx;
 SDKROOT_YES = macosx.internal;
 
+WK_DEFAULT_LTO_MODE = $(WK_USER_LTO_MODE_none);
+
 WK_CCACHE_DIR = $(SRCROOT)/../../Tools/ccache;
 #include "../../../Tools/ccache/ccache.xcconfig"

Modified: trunk/Tools/ChangeLog (235380 => 235381)


--- trunk/Tools/ChangeLog	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Tools/ChangeLog	2018-08-27 17:16:17 UTC (rev 235381)
@@ -1,3 +1,22 @@
+2018-08-27  Keith Rollin  <krol...@apple.com>
+
+        Build system support for LTO
+        https://bugs.webkit.org/show_bug.cgi?id=187785
+        <rdar://problem/42353132>
+
+        Reviewed by Dan Bernstein.
+
+        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):
+
 2018-08-27  Daniel Bates  <daba...@apple.com>
 
         lldb-webkit: Pretty-print OptionSet

Modified: trunk/Tools/Scripts/build-webkit (235380 => 235381)


--- trunk/Tools/Scripts/build-webkit	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Tools/Scripts/build-webkit	2018-08-27 17:16:17 UTC (rev 235381)
@@ -72,6 +72,7 @@
 my $coverageSupport = 0;
 my $shouldRunStaticAnalyzer = 0;
 my $noExperimentalFeatures = 0;
+my $ltoMode = "default";
 my $startTime = time();
 my $archs32bit = 0;
 my $skipLibraryUpdate = 0;
@@ -113,6 +114,7 @@
   --simulator                       DEPRECATED alias of --ios-simulator
   --coverage                        Enable code coverage support (Mac only)
   --analyze                         Enable static anaylsis (iOS and Mac only)
+  --lto-mode=<mode>                 Set Link Time Optimization mode (full, thin, or none) (Xcode only)
 
   --gtk                             Build the GTK+ port
   --wpe                             Build the WPE port
@@ -149,6 +151,7 @@
     'coverage' => \$coverageSupport,
     'analyze' => \$shouldRunStaticAnalyzer,
     'no-experimental-features' => \$noExperimentalFeatures,
+    'lto-mode=s' => \$ltoMode,
     'skip-library-update' => \$skipLibraryUpdate,
     'use-ccache!' => \$useCCache,
 );
@@ -331,6 +334,7 @@
         my @local_options = @options;
         push @local_options, XcodeCoverageSupportOptions() if $coverageSupport;
         push @local_options, XcodeStaticAnalyzerOption() if $shouldRunStaticAnalyzer;
+        push @local_options, "WK_LTO_MODE=$ltoMode" if ($ltoMode ne "default");
         my $projectPath = $project =~ /gtest/ ? "xcode/gtest" : $project;
         $result = buildXCodeProject($projectPath, $clean, @local_options, @ARGV);
 

Modified: trunk/Tools/Scripts/set-webkit-configuration (235380 => 235381)


--- trunk/Tools/Scripts/set-webkit-configuration	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Tools/Scripts/set-webkit-configuration	2018-08-27 17:16:17 UTC (rev 235381)
@@ -38,6 +38,7 @@
   --32-bit                Set the default architecture to 32-bit
   --64-bit                Set the default architecture to 64-bit
   --[no-]asan             Enable or disable clang address sanitizer
+  --lto-mode=<mode>       Set LTO mode: full, thin, or none
   --debug                 Set the default configuration to debug
   --release               Set the default configuration to release
   --reset                 Reset configurations
@@ -47,6 +48,10 @@
 my $architecture = passedArchitecture();
 my $enableASAN = checkForArgumentAndRemoveFromARGV("--asan");
 my $disableASAN = checkForArgumentAndRemoveFromARGV("--no-asan");
+my $ltoMode;
+if (!checkForArgumentAndRemoveFromARGVGettingValue("--lto-mode", \$ltoMode)) {
+    $ltoMode="";
+}
 
 if (!$architecture) {
     # Handle --64-bit explicitly here, as we don't want our other scripts to accept it
@@ -66,14 +71,20 @@
     unlink "$baseProductDir/Configuration";
     unlink "$baseProductDir/Architecture";
     unlink "$baseProductDir/ASan";
+    unlink "$baseProductDir/LTO";
     exit 0;
 }
 
-if (!$configuration && !$architecture && !$enableASAN && !$disableASAN || ($enableASAN && $disableASAN)) {
+if ((!$configuration && !$architecture && !$enableASAN && !$disableASAN && !$ltoMode) || ($enableASAN && $disableASAN)) {
     print STDERR $usage;
     exit 1;
 }
 
+if ($ltoMode && $ltoMode ne "full" && $ltoMode ne "thin" && $ltoMode ne "none") {
+    print STDERR $usage;
+    exit 1;
+}
+
 if ($configuration) {
     open CONFIGURATION, ">", "$baseProductDir/Configuration" or die;
     print CONFIGURATION $configuration;
@@ -97,3 +108,9 @@
 } elsif ($disableASAN) {
     unlink "$baseProductDir/ASan";
 }
+
+if ($ltoMode) {
+    open LTO, ">", "$baseProductDir/LTO" or die;
+    print LTO "$ltoMode";
+    close LTO;
+}

Modified: trunk/Tools/Scripts/webkitdirs.pm (235380 => 235381)


--- trunk/Tools/Scripts/webkitdirs.pm	2018-08-27 17:10:55 UTC (rev 235380)
+++ trunk/Tools/Scripts/webkitdirs.pm	2018-08-27 17:16:17 UTC (rev 235381)
@@ -129,6 +129,7 @@
 
 my $architecture;
 my $asanIsEnabled;
+my $ltoMode;
 my $numberOfCPUs;
 my $maxCPULoad;
 my $baseProductDir;
@@ -422,6 +423,18 @@
     }
 }
 
+sub determineLTOMode
+{
+    return if defined $ltoMode;
+    determineBaseProductDir();
+
+    if (open LTO, "$baseProductDir/LTO") {
+        $ltoMode = <LTO>;
+        close LTO;
+        chomp $ltoMode;
+    }
+}
+
 sub determineNumberOfCPUs
 {
     return if defined $numberOfCPUs;
@@ -844,6 +857,12 @@
     return $asanIsEnabled;
 }
 
+sub ltoMode()
+{
+    determineLTOMode();
+    return $ltoMode;
+}
+
 sub configurationForVisualStudio()
 {
     determineConfigurationForVisualStudio();
@@ -886,6 +905,7 @@
     determineConfiguration();
     determineArchitecture();
     determineASanIsEnabled();
+    determineLTOMode();
     determineXcodeSDK();
 
     my @options;
@@ -893,6 +913,7 @@
     push @options, "-UseSanitizedBuildSystemEnvironment=YES";
     push @options, ("-configuration", $configuration);
     push @options, ("-xcconfig", sourceDir() . "/Tools/asan/asan.xcconfig", "ASAN_IGNORE=" . sourceDir() . "/Tools/asan/webkit-asan-ignore.txt") if $asanIsEnabled;
+    push @options, "WK_LTO_MODE=$ltoMode" if $ltoMode;
     push @options, @baseProductDirOption;
     push @options, "ARCHS=$architecture" if $architecture;
     push @options, "SDKROOT=$xcodeSDK" if $xcodeSDK;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to