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
This commit is contained in:
9
cc/cc.go
9
cc/cc.go
@@ -159,10 +159,6 @@ type BaseProperties struct {
|
|||||||
// Minimum sdk version supported when compiling against the ndk
|
// Minimum sdk version supported when compiling against the ndk
|
||||||
Sdk_version string
|
Sdk_version string
|
||||||
|
|
||||||
// don't insert default compiler flags into asflags, cflags,
|
|
||||||
// cppflags, conlyflags, ldflags, or include_dirs
|
|
||||||
No_default_compiler_flags *bool
|
|
||||||
|
|
||||||
AndroidMkSharedLibs []string `blueprint:"mutated"`
|
AndroidMkSharedLibs []string `blueprint:"mutated"`
|
||||||
HideFromMake bool `blueprint:"mutated"`
|
HideFromMake bool `blueprint:"mutated"`
|
||||||
PreventInstall bool `blueprint:"mutated"`
|
PreventInstall bool `blueprint:"mutated"`
|
||||||
@@ -199,7 +195,6 @@ type ModuleContextIntf interface {
|
|||||||
staticBinary() bool
|
staticBinary() bool
|
||||||
clang() bool
|
clang() bool
|
||||||
toolchain() config.Toolchain
|
toolchain() config.Toolchain
|
||||||
noDefaultCompilerFlags() bool
|
|
||||||
useSdk() bool
|
useSdk() bool
|
||||||
sdkVersion() string
|
sdkVersion() string
|
||||||
useVndk() bool
|
useVndk() bool
|
||||||
@@ -452,10 +447,6 @@ func (ctx *moduleContextImpl) staticBinary() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *moduleContextImpl) noDefaultCompilerFlags() bool {
|
|
||||||
return Bool(ctx.mod.Properties.No_default_compiler_flags)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ctx *moduleContextImpl) useSdk() bool {
|
func (ctx *moduleContextImpl) useSdk() bool {
|
||||||
if ctx.ctx.Device() && !ctx.useVndk() {
|
if ctx.ctx.Device() && !ctx.useVndk() {
|
||||||
return ctx.mod.Properties.Sdk_version != ""
|
return ctx.mod.Properties.Sdk_version != ""
|
||||||
|
@@ -232,16 +232,14 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
|
|||||||
flags.YasmFlags = append(flags.YasmFlags, f)
|
flags.YasmFlags = append(flags.YasmFlags, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ctx.noDefaultCompilerFlags() {
|
flags.GlobalFlags = append(flags.GlobalFlags, "-I"+android.PathForModuleSrc(ctx).String())
|
||||||
flags.GlobalFlags = append(flags.GlobalFlags, "-I"+android.PathForModuleSrc(ctx).String())
|
flags.YasmFlags = append(flags.YasmFlags, "-I"+android.PathForModuleSrc(ctx).String())
|
||||||
flags.YasmFlags = append(flags.YasmFlags, "-I"+android.PathForModuleSrc(ctx).String())
|
|
||||||
|
|
||||||
if !(ctx.useSdk() || ctx.useVndk()) || ctx.Host() {
|
if !(ctx.useSdk() || ctx.useVndk()) || ctx.Host() {
|
||||||
flags.SystemIncludeFlags = append(flags.SystemIncludeFlags,
|
flags.SystemIncludeFlags = append(flags.SystemIncludeFlags,
|
||||||
"${config.CommonGlobalIncludes}",
|
"${config.CommonGlobalIncludes}",
|
||||||
tc.IncludeFlags(),
|
tc.IncludeFlags(),
|
||||||
"${config.CommonNativehelperInclude}")
|
"${config.CommonNativehelperInclude}")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.useSdk() {
|
if ctx.useSdk() {
|
||||||
@@ -318,48 +316,46 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
|
|||||||
hod = "Device"
|
hod = "Device"
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ctx.noDefaultCompilerFlags() {
|
flags.GlobalFlags = append(flags.GlobalFlags, instructionSetFlags)
|
||||||
flags.GlobalFlags = append(flags.GlobalFlags, instructionSetFlags)
|
flags.ConlyFlags = append([]string{"${config.CommonGlobalConlyflags}"}, flags.ConlyFlags...)
|
||||||
flags.ConlyFlags = append([]string{"${config.CommonGlobalConlyflags}"}, flags.ConlyFlags...)
|
|
||||||
|
|
||||||
if flags.Clang {
|
if flags.Clang {
|
||||||
flags.AsFlags = append(flags.AsFlags, tc.ClangAsflags())
|
flags.AsFlags = append(flags.AsFlags, tc.ClangAsflags())
|
||||||
flags.CppFlags = append([]string{"${config.CommonClangGlobalCppflags}"}, flags.CppFlags...)
|
flags.CppFlags = append([]string{"${config.CommonClangGlobalCppflags}"}, flags.CppFlags...)
|
||||||
flags.GlobalFlags = append(flags.GlobalFlags,
|
flags.GlobalFlags = append(flags.GlobalFlags,
|
||||||
tc.ClangCflags(),
|
tc.ClangCflags(),
|
||||||
"${config.CommonClangGlobalCflags}",
|
"${config.CommonClangGlobalCflags}",
|
||||||
fmt.Sprintf("${config.%sClangGlobalCflags}", hod))
|
fmt.Sprintf("${config.%sClangGlobalCflags}", hod))
|
||||||
} else {
|
} else {
|
||||||
flags.CppFlags = append([]string{"${config.CommonGlobalCppflags}"}, flags.CppFlags...)
|
flags.CppFlags = append([]string{"${config.CommonGlobalCppflags}"}, flags.CppFlags...)
|
||||||
flags.GlobalFlags = append(flags.GlobalFlags,
|
flags.GlobalFlags = append(flags.GlobalFlags,
|
||||||
tc.Cflags(),
|
tc.Cflags(),
|
||||||
"${config.CommonGlobalCflags}",
|
"${config.CommonGlobalCflags}",
|
||||||
fmt.Sprintf("${config.%sGlobalCflags}", hod))
|
fmt.Sprintf("${config.%sGlobalCflags}", hod))
|
||||||
}
|
|
||||||
|
|
||||||
if Bool(ctx.AConfig().ProductVariables.Brillo) {
|
|
||||||
flags.GlobalFlags = append(flags.GlobalFlags, "-D__BRILLO__")
|
|
||||||
}
|
|
||||||
|
|
||||||
if ctx.Device() {
|
|
||||||
if Bool(compiler.Properties.Rtti) {
|
|
||||||
flags.CppFlags = append(flags.CppFlags, "-frtti")
|
|
||||||
} else {
|
|
||||||
flags.CppFlags = append(flags.CppFlags, "-fno-rtti")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
flags.AsFlags = append(flags.AsFlags, "-D__ASSEMBLY__")
|
|
||||||
|
|
||||||
if flags.Clang {
|
|
||||||
flags.CppFlags = append(flags.CppFlags, tc.ClangCppflags())
|
|
||||||
} else {
|
|
||||||
flags.CppFlags = append(flags.CppFlags, tc.Cppflags())
|
|
||||||
}
|
|
||||||
|
|
||||||
flags.YasmFlags = append(flags.YasmFlags, tc.YasmFlags())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if Bool(ctx.AConfig().ProductVariables.Brillo) {
|
||||||
|
flags.GlobalFlags = append(flags.GlobalFlags, "-D__BRILLO__")
|
||||||
|
}
|
||||||
|
|
||||||
|
if ctx.Device() {
|
||||||
|
if Bool(compiler.Properties.Rtti) {
|
||||||
|
flags.CppFlags = append(flags.CppFlags, "-frtti")
|
||||||
|
} else {
|
||||||
|
flags.CppFlags = append(flags.CppFlags, "-fno-rtti")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flags.AsFlags = append(flags.AsFlags, "-D__ASSEMBLY__")
|
||||||
|
|
||||||
|
if flags.Clang {
|
||||||
|
flags.CppFlags = append(flags.CppFlags, tc.ClangCppflags())
|
||||||
|
} else {
|
||||||
|
flags.CppFlags = append(flags.CppFlags, tc.Cppflags())
|
||||||
|
}
|
||||||
|
|
||||||
|
flags.YasmFlags = append(flags.YasmFlags, tc.YasmFlags())
|
||||||
|
|
||||||
if flags.Clang {
|
if flags.Clang {
|
||||||
flags.GlobalFlags = append(flags.GlobalFlags, tc.ToolchainClangCflags())
|
flags.GlobalFlags = append(flags.GlobalFlags, tc.ToolchainClangCflags())
|
||||||
} else {
|
} else {
|
||||||
|
54
cc/linker.go
54
cc/linker.go
@@ -201,39 +201,37 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
|||||||
hod = "Device"
|
hod = "Device"
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ctx.noDefaultCompilerFlags() {
|
flags.LdFlags = append(flags.LdFlags, fmt.Sprintf("${config.%sGlobalLdflags}", hod))
|
||||||
flags.LdFlags = append(flags.LdFlags, fmt.Sprintf("${config.%sGlobalLdflags}", hod))
|
if Bool(linker.Properties.Allow_undefined_symbols) {
|
||||||
if Bool(linker.Properties.Allow_undefined_symbols) {
|
if ctx.Darwin() {
|
||||||
if ctx.Darwin() {
|
// darwin defaults to treating undefined symbols as errors
|
||||||
// darwin defaults to treating undefined symbols as errors
|
flags.LdFlags = append(flags.LdFlags, "-Wl,-undefined,dynamic_lookup")
|
||||||
flags.LdFlags = append(flags.LdFlags, "-Wl,-undefined,dynamic_lookup")
|
|
||||||
}
|
|
||||||
} else if !ctx.Darwin() {
|
|
||||||
flags.LdFlags = append(flags.LdFlags, "-Wl,--no-undefined")
|
|
||||||
}
|
}
|
||||||
|
} else if !ctx.Darwin() {
|
||||||
|
flags.LdFlags = append(flags.LdFlags, "-Wl,--no-undefined")
|
||||||
|
}
|
||||||
|
|
||||||
if flags.Clang {
|
if flags.Clang {
|
||||||
flags.LdFlags = append(flags.LdFlags, toolchain.ClangLdflags())
|
flags.LdFlags = append(flags.LdFlags, toolchain.ClangLdflags())
|
||||||
} else {
|
} else {
|
||||||
flags.LdFlags = append(flags.LdFlags, toolchain.Ldflags())
|
flags.LdFlags = append(flags.LdFlags, toolchain.Ldflags())
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ctx.toolchain().Bionic() {
|
if !ctx.toolchain().Bionic() {
|
||||||
CheckBadHostLdlibs(ctx, "host_ldlibs", linker.Properties.Host_ldlibs)
|
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() {
|
if !ctx.Windows() {
|
||||||
// Add -ldl, -lpthread, -lm and -lrt to host builds to match the default behavior of device
|
// Add -ldl, -lpthread, -lm and -lrt to host builds to match the default behavior of device
|
||||||
// builds
|
// builds
|
||||||
flags.LdFlags = append(flags.LdFlags,
|
flags.LdFlags = append(flags.LdFlags,
|
||||||
"-ldl",
|
"-ldl",
|
||||||
"-lpthread",
|
"-lpthread",
|
||||||
"-lm",
|
"-lm",
|
||||||
)
|
)
|
||||||
if !ctx.Darwin() {
|
if !ctx.Darwin() {
|
||||||
flags.LdFlags = append(flags.LdFlags, "-lrt")
|
flags.LdFlags = append(flags.LdFlags, "-lrt")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -53,7 +53,7 @@ func (object *objectLinker) linkerProps() []interface{} {
|
|||||||
func (*objectLinker) linkerInit(ctx BaseModuleContext) {}
|
func (*objectLinker) linkerInit(ctx BaseModuleContext) {}
|
||||||
|
|
||||||
func (object *objectLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
func (object *objectLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
||||||
if !ctx.noDefaultCompilerFlags() && ctx.toolchain().Bionic() {
|
if ctx.useVndk() && ctx.toolchain().Bionic() {
|
||||||
// Needed for VNDK builds where bionic headers aren't automatically added.
|
// Needed for VNDK builds where bionic headers aren't automatically added.
|
||||||
deps.LateSharedLibs = append(deps.LateSharedLibs, "libc")
|
deps.LateSharedLibs = append(deps.LateSharedLibs, "libc")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user