Fix llvm-ar error caused by using lto and sanitizer together

LLVM-AR does not allow passing --plugin options more than once. The
--plugin ARFLAGS that lto want to add, may already exist if sanitizer is
also turned on.

Fixed this by adding a new bool Flags.ArGoldPlugin. Set this variable to
true whenever LLVM gold plugin is needed for ArFlags. In function
TransformObjToStaticLib(), add this option to arFlags using global value
${config.LLVMGoldPlugin} if the bool value is true.

Bug: http://b/73160350
Test: build the image with make and succeeded.

Change-Id: I62785829b0a4b663225926e4aed98defc1b6da2c
(cherry picked from commit 4917049f6e)
This commit is contained in:
Zhizhou Yang
2018-02-08 18:32:11 -08:00
committed by Yi Kong
parent 3bb5f2f2fa
commit 51be632b95
5 changed files with 8 additions and 3 deletions

View File

@@ -86,7 +86,7 @@ func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags {
// https://github.com/android-ndk/ndk/issues/498.
flags.LdFlags = append(flags.LdFlags, "-Wl,-plugin-opt,-emulated-tls")
}
flags.ArFlags = append(flags.ArFlags, " --plugin ${config.LLVMGoldPlugin}")
flags.ArGoldPlugin = true
}
return flags
}