Remove no_default_compiler_flags property
no_default_compiler_flags is only used by the crt* modules,
is unnecessary, and causes problems when necessary flags like
-no-canonical-prefixes are not passed. Remove the property.
Use useVndk() instead of noDefaultCompilerFlags() to determine
if adding libc as a dependency is necessary and won't cause a
circular dependency.
Bug: 68719465
Test: m checkbuild
Change-Id: Iea1a082dc701dfeab211049a22f7066257347b80
diff --git a/cc/linker.go b/cc/linker.go
index d5727aa..fae5542 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -201,39 +201,37 @@
hod = "Device"
}
- if !ctx.noDefaultCompilerFlags() {
- flags.LdFlags = append(flags.LdFlags, fmt.Sprintf("${config.%sGlobalLdflags}", hod))
- 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")
+ flags.LdFlags = append(flags.LdFlags, fmt.Sprintf("${config.%sGlobalLdflags}", hod))
+ 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")
+ }
- if flags.Clang {
- flags.LdFlags = append(flags.LdFlags, toolchain.ClangLdflags())
- } else {
- flags.LdFlags = append(flags.LdFlags, toolchain.Ldflags())
- }
+ if flags.Clang {
+ flags.LdFlags = append(flags.LdFlags, toolchain.ClangLdflags())
+ } else {
+ flags.LdFlags = append(flags.LdFlags, toolchain.Ldflags())
+ }
- if !ctx.toolchain().Bionic() {
- CheckBadHostLdlibs(ctx, "host_ldlibs", linker.Properties.Host_ldlibs)
+ if !ctx.toolchain().Bionic() {
+ CheckBadHostLdlibs(ctx, "host_ldlibs", linker.Properties.Host_ldlibs)
- flags.LdFlags = append(flags.LdFlags, linker.Properties.Host_ldlibs...)
+ flags.LdFlags = append(flags.LdFlags, linker.Properties.Host_ldlibs...)
- if !ctx.Windows() {
- // Add -ldl, -lpthread, -lm and -lrt to host builds to match the default behavior of device
- // builds
- flags.LdFlags = append(flags.LdFlags,
- "-ldl",
- "-lpthread",
- "-lm",
- )
- if !ctx.Darwin() {
- flags.LdFlags = append(flags.LdFlags, "-lrt")
- }
+ if !ctx.Windows() {
+ // Add -ldl, -lpthread, -lm and -lrt to host builds to match the default behavior of device
+ // builds
+ flags.LdFlags = append(flags.LdFlags,
+ "-ldl",
+ "-lpthread",
+ "-lm",
+ )
+ if !ctx.Darwin() {
+ flags.LdFlags = append(flags.LdFlags, "-lrt")
}
}
}