Commit bf8b9821 authored by Reid Kleckner's avatar Reid Kleckner Committed by Commit Bot

Explicitly pass linker /OPT and other flags implied by /PROFILE

LLD currently ignores /PROFILE, so it does not enable /OPT:ICF and
/OPT:REF for chrome_elf.dll. chrome_elf_import_unittests checks that the
linker strips dead dependencies on user32.dll and shell32.dll, so it
currently fails when chrome_elf.dll is linked with LLD.

I will fix this bug in upstream LLD, but in the meantime this will fix
the issue. This change also seens like it is more explicit and reduces
gn complexity, so maybe we should leave it like this after the LLD fix.

R=brucedawson@chromium.org, thakis@chromium.org

Bug: chromium:827075
Change-Id: Icd2a09aab031b7ff07738892c12a5de1ec9936b9
Reviewed-on: https://chromium-review.googlesource.com/986694
Commit-Queue: Reid Kleckner <rnk@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547105}
parent 062470b4
......@@ -115,25 +115,27 @@ config("compiler") {
cflags += [ "/Brepro" ]
}
# TODO(siggi): Is this of any use anymore?
# /PROFILE ensures that the PDB file contains FIXUP information (growing the
# PDB file by about 5%) but does not otherwise alter the output binary. It is
# enabled opportunistically for builds where it is not prohibited (not
# supported when incrementally linking, or using /debug:fastlink).
if (!is_debug && !is_component_build) {
if (is_win_fastlink && !use_lld) {
# /PROFILE implies the following linker flags. Therefore if we are
# skipping /PROFILE because it is incompatible with /DEBUG:FASTLINK
# we should explicitly add these flags in order to avoid unintended
# consequences such as larger binaries.
ldflags = [
"/OPT:REF",
"/OPT:ICF",
"/INCREMENTAL:NO",
"/FIXED:NO",
]
# Enable standard linker optimizations like GC (/OPT:REF) and ICF in static
# release builds. These are implied by /PROFILE below, but /PROFILE is
# incompatible with /debug:fastlink and LLD ignores it as of this writing.
# Release builds always want these optimizations, so enable them explicitly.
ldflags = [
"/OPT:REF",
"/OPT:ICF",
"/INCREMENTAL:NO",
"/FIXED:NO",
]
# TODO(siggi): Is this of any use anymore?
# /PROFILE ensures that the PDB file contains FIXUP information (growing the
# PDB file by about 5%) but does not otherwise alter the output binary. It
# is enabled opportunistically for builds where it is not prohibited (not
# supported when incrementally linking, or using /debug:fastlink).
if (!is_win_fastlink) {
ldflags += [ "/PROFILE" ]
} else {
ldflags = [ "/PROFILE" ]
assert(!is_syzyasan, "fastlink is incompatible with SyzyASan")
}
}
......
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