Merge "Move gen_sorted_bss_symbols.sh to use LLVM binutils" am: 9d9e053964

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1659997

Change-Id: Id8c53b797052a0ed422e512872d7500ddda383da
This commit is contained in:
Yi Kong 2021-04-01 03:56:26 +00:00 committed by Automerger Merge Worker
commit dd19e029a5
2 changed files with 6 additions and 7 deletions

View File

@ -599,21 +599,20 @@ var (
_ = pctx.SourcePathVariable("genSortedBssSymbolsPath", "build/soong/scripts/gen_sorted_bss_symbols.sh") _ = pctx.SourcePathVariable("genSortedBssSymbolsPath", "build/soong/scripts/gen_sorted_bss_symbols.sh")
genSortedBssSymbols = pctx.AndroidStaticRule("gen_sorted_bss_symbols", genSortedBssSymbols = pctx.AndroidStaticRule("gen_sorted_bss_symbols",
blueprint.RuleParams{ blueprint.RuleParams{
Command: "CROSS_COMPILE=$crossCompile $genSortedBssSymbolsPath ${in} ${out}", Command: "CLANG_BIN=${clangBin} $genSortedBssSymbolsPath ${in} ${out}",
CommandDeps: []string{"$genSortedBssSymbolsPath", "${crossCompile}nm"}, CommandDeps: []string{"$genSortedBssSymbolsPath", "${clangBin}/llvm-nm"},
}, },
"crossCompile") "clangBin")
) )
func (linker *baseLinker) sortBssSymbolsBySize(ctx ModuleContext, in android.Path, symbolOrderingFile android.ModuleOutPath, flags builderFlags) string { func (linker *baseLinker) sortBssSymbolsBySize(ctx ModuleContext, in android.Path, symbolOrderingFile android.ModuleOutPath, flags builderFlags) string {
crossCompile := gccCmd(flags.toolchain, "")
ctx.Build(pctx, android.BuildParams{ ctx.Build(pctx, android.BuildParams{
Rule: genSortedBssSymbols, Rule: genSortedBssSymbols,
Description: "generate bss symbol order " + symbolOrderingFile.Base(), Description: "generate bss symbol order " + symbolOrderingFile.Base(),
Output: symbolOrderingFile, Output: symbolOrderingFile,
Input: in, Input: in,
Args: map[string]string{ Args: map[string]string{
"crossCompile": crossCompile, "clangBin": "${config.ClangBin}",
}, },
}) })
return "-Wl,--symbol-ordering-file," + symbolOrderingFile.String() return "-Wl,--symbol-ordering-file," + symbolOrderingFile.String()

View File

@ -18,11 +18,11 @@
# their sizes. # their sizes.
# Inputs: # Inputs:
# Environment: # Environment:
# CROSS_COMPILE: prefix added to nm tools # CLANG_BIN: path to the clang bin directory
# Arguments: # Arguments:
# $1: Input ELF file # $1: Input ELF file
# $2: Output symbol ordering file # $2: Output symbol ordering file
set -o pipefail set -o pipefail
${CROSS_COMPILE}nm --size-sort $1 | awk '{if ($2 == "b" || $2 == "B") print $3}' > $2 ${CLANG_BIN}/llvm-nm --size-sort $1 | awk '{if ($2 == "b" || $2 == "B") print $3}' > $2