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
diff --git a/cc/linker.go b/cc/linker.go
index 399074d..0923338 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -150,7 +150,12 @@
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")
}