Commit 4fb96ed6 authored by Reid Kleckner's avatar Reid Kleckner Committed by Commit Bot

Move logic for ThinLTO optimization level into non-is_win block

Avoids linker errors from LLD about -Wl, not being a recognized command
line flag.  This will fix the Windows CFI and ThinLTO FYI bots.

Factor out a variable for the optimization level so we need one less
conditional.

TBR=agreive@chromium.org, agrieve@chromium.org, gbiv@chromium.org, pcc@chromium.org

Bug: 807147
Change-Id: I8a928eaab93ec181ba057cdda4cb635389f30926
Reviewed-on: https://chromium-review.googlesource.com/1188879Reviewed-by: default avatarReid Kleckner <rnk@chromium.org>
Reviewed-by: default avatarGeorge Burgess <gbiv@chromium.org>
Reviewed-by: default avatarPeter Collingbourne <pcc@chromium.org>
Reviewed-by: default avataragrieve <agrieve@chromium.org>
Commit-Queue: Reid Kleckner <rnk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586083}
parent 48f30deb
...@@ -635,12 +635,18 @@ config("compiler") { ...@@ -635,12 +635,18 @@ config("compiler") {
cflags += [ "-flto=thin" ] cflags += [ "-flto=thin" ]
if (thin_lto_enable_optimizations) {
lto_opt_level = 2
} else {
lto_opt_level = 0
}
if (is_win) { if (is_win) {
# This is a straight translation of the non-Windows flags below, # This is a straight translation of the non-Windows flags below,
# except we do not use the ThinLTO cache, which leaks temporary # except we do not use the ThinLTO cache, which leaks temporary
# files on Windows (https://crbug.com/871962). # files on Windows (https://crbug.com/871962).
ldflags += [ ldflags += [
"/opt:lldlto=0", "/opt:lldlto=" + lto_opt_level,
"/opt:lldltojobs=8", "/opt:lldltojobs=8",
] ]
} else { } else {
...@@ -663,21 +669,19 @@ config("compiler") { ...@@ -663,21 +669,19 @@ config("compiler") {
} else { } else {
ldflags += [ "-Wl,-plugin-opt,jobs=8" ] ldflags += [ "-Wl,-plugin-opt,jobs=8" ]
} }
}
if (use_lld) { if (use_lld) {
if (thin_lto_enable_optimizations) { ldflags += [ "-Wl,--lto-O" + lto_opt_level ]
ldflags += [ "-Wl,--lto-O2" ] if (thin_lto_enable_optimizations) {
if (is_android) { if (is_android) {
# TODO(gbiv): We ideally shouldn't need to specify this; ThinLTO # TODO(gbiv): We ideally shouldn't need to specify this; ThinLTO
# should be able to better manage binary size increases on its own. # should be able to better manage binary size increases on its own.
ldflags += [ ldflags += [
"-Wl,-mllvm", "-Wl,-mllvm",
"-Wl,-import-instr-limit=5", "-Wl,-import-instr-limit=5",
] ]
}
} }
} else {
ldflags += [ "-Wl,--lto-O0" ]
} }
} }
......
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