Don't pass -Wl,--no-undefined to host targets
Host builds were compiling without -Wl,--no-undefined because of an ASAN issue. Pass -Wl,--no-undefined for host builds unless sanitzers are enabled. Also fix LOCAL_ALLOW_UNDEFINED_SYMBOLS on darwin, where disallowing undefined symbols is the default. Test: m -j host Test: m -j SANITIZE_HOST=address host Bug: 32305815 Change-Id: Ia4bb305a50b1c1048b119f75726d52f82e21438c
This commit is contained in:
@@ -150,7 +150,12 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
||||
toolchain := ctx.toolchain()
|
||||
|
||||
if !ctx.noDefaultCompilerFlags() {
|
||||
if ctx.Device() && !Bool(linker.Properties.Allow_undefined_symbols) {
|
||||
if Bool(linker.Properties.Allow_undefined_symbols) {
|
||||
if ctx.Darwin() {
|
||||
// darwin defaults to treating undefined symbols as errors
|
||||
flags.LdFlags = append(flags.LdFlags, "-Wl,-undefined,dynamic_lookup")
|
||||
}
|
||||
} else if !ctx.Darwin() {
|
||||
flags.LdFlags = append(flags.LdFlags, "-Wl,--no-undefined")
|
||||
}
|
||||
|
||||
|
@@ -255,6 +255,9 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
|
||||
// libraries needed with -fsanitize=address. http://b/18650275 (WAI)
|
||||
flags.LdFlags = append(flags.LdFlags, "-lm", "-lpthread")
|
||||
flags.LdFlags = append(flags.LdFlags, "-Wl,--no-as-needed")
|
||||
// Host ASAN only links symbols in the final executable, so
|
||||
// there will always be undefined symbols in intermediate libraries.
|
||||
_, flags.LdFlags = removeFromList("-Wl,--no-undefined", flags.LdFlags)
|
||||
} else {
|
||||
flags.CFlags = append(flags.CFlags, "-mllvm", "-asan-globals=0")
|
||||
flags.DynamicLinker = "/system/bin/linker_asan"
|
||||
|
Reference in New Issue
Block a user