cmd/link: change -strictdups checking to handle mix of flags

Update the recently-added '-strictdups' sanity checking to avoid
failing the link in cases where we have objects feeding into the link
with a mix of command line flags (and in particular some with "-N" and
some without). This scenario will trigger errors/warnings due to
inlinable functions and wrapper functions that have different sizes
due to presence or lack of optimization.

Update #31034.

Change-Id: I1dd9e37c2f9bea5da0ab82e32e6fc210aebf6a65
Reviewed-on: https://go-review.googlesource.com/c/go/+/169160
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
Than McIntosh 2019-03-26 12:02:36 -04:00
parent 697f4183e6
commit cacab64555
4 changed files with 27 additions and 5 deletions

View file

@ -200,6 +200,10 @@ var (
nerrors int
liveness int64
// See -strictdups command line flag.
checkStrictDups int // 0=off 1=warning 2=error
strictDupMsgCount int
)
var (
@ -283,6 +287,9 @@ func errorexit() {
if nerrors != 0 {
Exit(2)
}
if checkStrictDups > 1 && strictDupMsgCount > 0 {
Exit(2)
}
Exit(0)
}
@ -1745,7 +1752,8 @@ func ldobj(ctxt *Link, f *bio.Reader, lib *sym.Library, length int64, pn string,
default:
log.Fatalf("invalid -strictdups flag value %d", *FlagStrictDups)
}
objfile.Load(ctxt.Arch, ctxt.Syms, f, lib, eof-f.Offset(), pn, flags)
c := objfile.Load(ctxt.Arch, ctxt.Syms, f, lib, eof-f.Offset(), pn, flags)
strictDupMsgCount += c
addImports(ctxt, lib, pn)
return nil
}