Prevent clang from using the x18 register on arm64.

This is achieved via the compiler flag -ffixed-x18 for non-LTO builds
and the linker flag -plugin-opt -mattr=+reserve-x18 for LTO builds.

This change should be reverted once we upgrade past LLVM r340889
which does this by default on Android.

Bug: 112907825
Bug: 111759196
Change-Id: I05473ddbb98319d87d442425b4d715647eae3a38
This commit is contained in:
Peter Collingbourne
2018-10-24 16:09:47 -07:00
parent ddfcd42b25
commit 98d8580c3a
3 changed files with 19 additions and 0 deletions

View File

@@ -113,6 +113,13 @@ func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags {
flags.LdFlags = append(flags.LdFlags, "-Wl,-plugin-opt,-inline-threshold=0")
flags.LdFlags = append(flags.LdFlags, "-Wl,-plugin-opt,-unroll-threshold=0")
}
if ctx.Arch().ArchType == android.Arm64 {
// Prevent use of x18 register on arm64.
// TODO(pcc): Remove this flag once we upgrade past LLVM r340889
// which does this by default on Android.
flags.LdFlags = append(flags.LdFlags, "-Wl,-plugin-opt,-mattr=+reserve-x18")
}
}
return flags
}