Work around LLVM bug where TLS not emulated in LTO mode
In LTO mode the backend constructs a target exclusively from command line flags, without opportunity to accept code gen arguments from Clang. Clang does not currently pass the -emulated-tls parameter for Android, even though it defaults to emulated TLS for Android in non-LTO builds. Until this is fixed upstream, we can explicitly specify that the LTO output for Android should use emulated TLS. Test: build libandroid with LTO, verified that it uses __emutls_get_address rather than __tls_get_addr. Change-Id: I18acac41aac885fc6635fbd55f96ba7c845eb5e7
This commit is contained in:
@@ -64,6 +64,11 @@ func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags {
|
||||
if Bool(lto.Properties.Lto) {
|
||||
flags.CFlags = append(flags.CFlags, "-flto")
|
||||
flags.LdFlags = append(flags.LdFlags, "-flto")
|
||||
if ctx.Device() {
|
||||
// Work around bug in Clang that doesn't pass correct emulated
|
||||
// TLS option to target
|
||||
flags.LdFlags = append(flags.LdFlags, "-Wl,-plugin-opt,-emulated-tls")
|
||||
}
|
||||
flags.ArFlags = append(flags.ArFlags, " --plugin ${config.LLVMGoldPlugin}")
|
||||
}
|
||||
return flags
|
||||
|
Reference in New Issue
Block a user