From 30bcb3bd283ac992e7b1e8848fd450ad560b4122 Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Mon, 17 Apr 2017 13:08:03 -0700 Subject: [PATCH] Save time delocating when not using archive inputs. If all the inputs are given as assembly files then we can skip rewriting symbols for the first file. If this file is bcm.s (i.e. the large compiler output), this can save a few seconds of build time. Change-Id: I4e4ea114acb86cd93e831b23b58f8c3401bc711c Reviewed-on: https://boringssl-review.googlesource.com/15149 Reviewed-by: Adam Langley --- crypto/fipsmodule/delocate.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/crypto/fipsmodule/delocate.go b/crypto/fipsmodule/delocate.go index c208041f..ebf93323 100644 --- a/crypto/fipsmodule/delocate.go +++ b/crypto/fipsmodule/delocate.go @@ -413,13 +413,28 @@ func asLines(lines []string, path string, uniqueId int) ([]string, error) { } defer asFile.Close() - var contents []string - // localSymbols maps from the symbol name used in the input, to a // unique symbol name. localSymbols := make(map[string]string) scanner := bufio.NewScanner(asFile) + var contents []string + + if len(lines) == 0 { + // If this is the first assembly file, don't rewrite symbols. + // Only all-but-one file needs to be rewritten and so time can + // be saved by putting the (large) bcm.s first. + for scanner.Scan() { + lines = append(lines, scanner.Text()) + } + + if err := scanner.Err(); err != nil { + return nil, err + } + + return lines, nil + } + for scanner.Scan() { line := scanner.Text() trimmed := strings.TrimSpace(line) @@ -431,7 +446,7 @@ func asLines(lines []string, path string, uniqueId int) ([]string, error) { continue } - contents = append(contents, scanner.Text()) + contents = append(contents, line) } if err := scanner.Err(); err != nil { return nil, err