Add LTO support to soong
Enabling the lto property for a module builds that module and all static dependencies with LTO. LTO (link-time optimization) allows the compiler to optimize and generate code for the entire module at link time, rather than per-compilation unit. LTO is required for Clang CFI and other whole-program optimization techniques. LTO also allows cross-compilation unit optimizations that should result in faster and smaller code, at the expense of additional compilation time. Test: make -j12 libc with lto: true for libc Change-Id: Ib8baefedf60e02701d44673a7c473e0845730101
This commit is contained in:
@@ -16,6 +16,7 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"android/soong/android"
|
||||
@@ -149,6 +150,11 @@ func init() {
|
||||
return ClangDefaultShortVersion, nil
|
||||
})
|
||||
pctx.StaticVariable("ClangAsanLibDir", "${ClangPath}/lib64/clang/${ClangShortVersion}/lib/linux")
|
||||
if runtime.GOOS == "darwin" {
|
||||
pctx.StaticVariable("LLVMGoldPlugin", "${ClangPath}/lib64/LLVMgold.dylib")
|
||||
} else {
|
||||
pctx.StaticVariable("LLVMGoldPlugin", "${ClangPath}/lib64/LLVMgold.so")
|
||||
}
|
||||
|
||||
// These are tied to the version of LLVM directly in external/llvm, so they might trail the host prebuilts
|
||||
// being used for the rest of the build process.
|
||||
|
Reference in New Issue
Block a user