Commit f8a60701 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

SuperSize: Enable LTO for caspian

Didn't meaningfully change runtime nor file size, but seems like a flag
we should be using.

Bug: None
Change-Id: I7e42cb4bac8036d97f6db61c4906c1ff6ae88e80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2040910
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarSamuel Huang <huangs@chromium.org>
Commit-Queue: Samuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741539}
parent 69b72d55
...@@ -15,19 +15,40 @@ index f89e7e831b79..ebfb4ba88b35 100644 ...@@ -15,19 +15,40 @@ index f89e7e831b79..ebfb4ba88b35 100644
# ============================================================================= # =============================================================================
# SOURCES FILTERS # SOURCES FILTERS
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index 0f91977e1352..acd5ab11f111 100644 index 912906e15e76..e00bf81e6b20 100644
--- a/build/config/compiler/BUILD.gn --- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn
@@ -1508,7 +1508,7 @@ config("default_warnings") { @@ -564,6 +564,19 @@ config("compiler") {
ldflags += [ "-stdlib=libc++" ]
}
+ if (is_wasm && is_official_build) {
+ cflags_c += [
+ "-s",
+ "WASM_OBJECT_FILES=0",
+ ]
+ ldflags += [
+ "-s",
+ "WASM_OBJECT_FILES=0",
+ "--llvm-lto",
+ "1",
+ ]
+ }
+
# Add flags for link-time optimization. These flags enable
# optimizations/transformations that require whole-program visibility at link
# time, so they need to be applied to all translation units, and we may end up
@@ -1507,7 +1520,8 @@ config("default_warnings") {
cflags += [ "-Wno-nonportable-include-path" ] cflags += [ "-Wno-nonportable-include-path" ]
} }
- if (current_toolchain == host_toolchain || !use_xcode_clang) { - if (current_toolchain == host_toolchain || !use_xcode_clang) {
+ if ((current_toolchain == host_toolchain || !use_xcode_clang) && !is_wasm) { + if ((current_toolchain == host_toolchain || !use_xcode_clang) &&
+ !is_wasm) {
# Flags NaCl (Clang 3.7) and Xcode 9.2 (Clang clang-900.0.39.2) do not # Flags NaCl (Clang 3.7) and Xcode 9.2 (Clang clang-900.0.39.2) do not
# recognize. # recognize.
cflags += [ cflags += [
@@ -2296,6 +2296,9 @@ config("symbols") { @@ -2303,6 +2317,9 @@ config("symbols") {
cflags += [ "-fno-standalone-debug" ] cflags += [ "-fno-standalone-debug" ]
} }
} }
...@@ -38,7 +59,7 @@ index 0f91977e1352..acd5ab11f111 100644 ...@@ -38,7 +59,7 @@ index 0f91977e1352..acd5ab11f111 100644
cflags = [] cflags = []
if (is_mac && enable_dsyms) { if (is_mac && enable_dsyms) {
diff --git a/build/toolchain/toolchain.gni b/build/toolchain/toolchain.gni diff --git a/build/toolchain/toolchain.gni b/build/toolchain/toolchain.gni
index 3edc9762907d..ab483e44a11c 100644 index 2b6f05231c63..134e9ee77107 100644
--- a/build/toolchain/toolchain.gni --- a/build/toolchain/toolchain.gni
+++ b/build/toolchain/toolchain.gni +++ b/build/toolchain/toolchain.gni
@@ -58,6 +58,9 @@ if (is_mac || is_ios) { @@ -58,6 +58,9 @@ if (is_mac || is_ios) {
...@@ -51,40 +72,98 @@ index 3edc9762907d..ab483e44a11c 100644 ...@@ -51,40 +72,98 @@ index 3edc9762907d..ab483e44a11c 100644
} else { } else {
assert(false, "Platform not supported") assert(false, "Platform not supported")
} }
diff --git a/build/toolchain/wasm/BUILD.gn b/build/toolchain/wasm/BUILD.gn diff --git a/tools/binary_size/libsupersize/caspian/wasmbuild.patch b/tools/binary_size/libsupersize/caspian/wasmbuild.patch
new file mode 100644 index 065bb27f795a..e69de29bb2d1 100644
index 000000000000..15bc7a4ea258 --- a/tools/binary_size/libsupersize/caspian/wasmbuild.patch
--- /dev/null +++ b/tools/binary_size/libsupersize/caspian/wasmbuild.patch
+++ b/build/toolchain/wasm/BUILD.gn @@ -1,90 +0,0 @@
@@ -0,0 +1,31 @@ -diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn
+# Copyright 2019 The Chromium Authors. All rights reserved. -index f89e7e831b79..ebfb4ba88b35 100644
+# Use of this source code is governed by a BSD-style license that can be ---- a/build/config/BUILDCONFIG.gn
+# found in the LICENSE file. -+++ b/build/config/BUILDCONFIG.gn
+ -@@ -291,9 +291,10 @@ is_ios = current_os == "ios"
+import("//build/toolchain/gcc_toolchain.gni") - is_linux = current_os == "chromeos" || current_os == "linux"
+ - is_mac = current_os == "mac"
+gcc_toolchain("wasm") { - is_nacl = current_os == "nacl"
+ cc = "emcc" -+is_wasm = current_os == "wasm"
+ cxx = "em++" - is_win = current_os == "win" || current_os == "winuwp"
+ nm = "emcc" -
+ ar = "emar" --is_posix = !is_win && !is_fuchsia
+ ld = cxx -+is_posix = !is_win && !is_fuchsia && !is_wasm
+ -
+ toolchain_args = { - # =============================================================================
+ current_cpu = "wasm" - # SOURCES FILTERS
+ current_os = "wasm" -diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
+ -index 0f91977e1352..acd5ab11f111 100644
+ is_clang = true ---- a/build/config/compiler/BUILD.gn
+ use_goma = false -+++ b/build/config/compiler/BUILD.gn
+ use_debug_fission = false -@@ -1508,7 +1508,7 @@ config("default_warnings") {
+ clang_use_chrome_plugins = false - cflags += [ "-Wno-nonportable-include-path" ]
+ use_allocator_shim = false - }
+ is_component_build = false -
+ } -- if (current_toolchain == host_toolchain || !use_xcode_clang) {
+ extra_ldflags = "-s BINARYEN_METHOD='native-wasm'" -+ if ((current_toolchain == host_toolchain || !use_xcode_clang) && !is_wasm) {
+ executable_extension = ".js" - # Flags NaCl (Clang 3.7) and Xcode 9.2 (Clang clang-900.0.39.2) do not
+ link_outputs = [ - # recognize.
+ "{{output_dir}}/{{target_output_name}}.wasm", - cflags += [
+ "{{output_dir}}/{{target_output_name}}.wasm.map", -@@ -2296,6 +2296,9 @@ config("symbols") {
+ ] - cflags += [ "-fno-standalone-debug" ]
+} - }
- }
-+ } else if (is_wasm) {
-+ cflags = [ "-g4" ]
-+ ldflags = [ "-g4" ]
- } else {
- cflags = []
- if (is_mac && enable_dsyms) {
-diff --git a/build/toolchain/toolchain.gni b/build/toolchain/toolchain.gni
-index 3edc9762907d..ab483e44a11c 100644
---- a/build/toolchain/toolchain.gni
-+++ b/build/toolchain/toolchain.gni
-@@ -58,6 +58,9 @@ if (is_mac || is_ios) {
- shlib_extension = ".so"
- } else if (is_win) {
- shlib_extension = ".dll"
-+} else if (is_wasm) {
-+ # WebAssembly does not stably support shared libraries. (as of Oct 2019)
-+ shlib_extension = ".wasm"
- } else {
- assert(false, "Platform not supported")
- }
-diff --git a/build/toolchain/wasm/BUILD.gn b/build/toolchain/wasm/BUILD.gn
-new file mode 100644
-index 000000000000..15bc7a4ea258
---- /dev/null
-+++ b/build/toolchain/wasm/BUILD.gn
-@@ -0,0 +1,31 @@
-+# Copyright 2019 The Chromium Authors. All rights reserved.
-+# Use of this source code is governed by a BSD-style license that can be
-+# found in the LICENSE file.
-+
-+import("//build/toolchain/gcc_toolchain.gni")
-+
-+gcc_toolchain("wasm") {
-+ cc = "emcc"
-+ cxx = "em++"
-+ nm = "emcc"
-+ ar = "emar"
-+ ld = cxx
-+
-+ toolchain_args = {
-+ current_cpu = "wasm"
-+ current_os = "wasm"
-+
-+ is_clang = true
-+ use_goma = false
-+ use_debug_fission = false
-+ clang_use_chrome_plugins = false
-+ use_allocator_shim = false
-+ is_component_build = false
-+ }
-+ extra_ldflags = "-s BINARYEN_METHOD='native-wasm'"
-+ executable_extension = ".js"
-+ link_outputs = [
-+ "{{output_dir}}/{{target_output_name}}.wasm",
-+ "{{output_dir}}/{{target_output_name}}.wasm.map",
-+ ]
-+}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment