From d8e780df697c7ba52c2062ddcf17438cd9cb1959 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 28 Apr 2015 17:39:43 -0700 Subject: [PATCH] cc: make static or shared cflags apply to all source files Make static or shared cflags properties apply to all source files, not just the source files defined in the static or shared block. Needed for libunwind, which passes -DUNW_ADDITIONAL_PREFIX to source files for the static library, but not for the shared library. Change-Id: I3cd88cc1099e505eeee077c697db00de22a8b03a --- cc/cc.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cc/cc.go b/cc/cc.go index df5fc575c..5d6e124e8 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -1028,6 +1028,12 @@ func (c *CCLibrary) flags(ctx common.AndroidModuleContext, flags CCFlags) CCFlag flags.CFlags = append(flags.CFlags, "-fPIC") + if c.static() { + flags.CFlags = append(flags.CFlags, c.LibraryProperties.Static.Cflags...) + } else { + flags.CFlags = append(flags.CFlags, c.LibraryProperties.Shared.Cflags...) + } + if !c.static() { libName := ctx.ModuleName() // GCC for Android assumes that -shared means -Bsymbolic, use -Wl,-shared instead @@ -1053,7 +1059,6 @@ func (c *CCLibrary) compileStaticLibrary(ctx common.AndroidModuleContext, flags CCFlags, deps CCDeps, objFiles []string) { staticFlags := flags - staticFlags.CFlags = append(staticFlags.CFlags, c.LibraryProperties.Static.Cflags...) objFilesStatic := c.customCompileObjs(ctx, staticFlags, common.DeviceStaticLibrary, c.LibraryProperties.Static.Srcs) @@ -1076,7 +1081,6 @@ func (c *CCLibrary) compileSharedLibrary(ctx common.AndroidModuleContext, flags CCFlags, deps CCDeps, objFiles []string) { sharedFlags := flags - sharedFlags.CFlags = append(sharedFlags.CFlags, c.LibraryProperties.Shared.Cflags...) objFilesShared := c.customCompileObjs(ctx, sharedFlags, common.DeviceSharedLibrary, c.LibraryProperties.Shared.Srcs)