aboutsummaryrefslogtreecommitdiffstats
path: root/cc/cc.go
diff options
context:
space:
mode:
authorJiyong Park <jiyong@google.com>2017-10-12 23:05:00 +0900
committerJiyong Park <jiyong@google.com>2017-10-13 14:36:12 +0900
commit6a43f047772ab30e89eb7cb5346a08db889a2e7b (patch)
tree1907830ef7c5b3a45c78ae39047564b49ba93395 /cc/cc.go
parent432a2d4033cd3e78dc4f1b63295e281bbb4f89b4 (diff)
downloadbuild_soong-6a43f047772ab30e89eb7cb5346a08db889a2e7b.tar.gz
build_soong-6a43f047772ab30e89eb7cb5346a08db889a2e7b.tar.bz2
build_soong-6a43f047772ab30e89eb7cb5346a08db889a2e7b.zip
Squash vendor sources before linkageMutator runs
linkageMutator removes srcs property of the shared variant of a lib in order to reuse *.o files compiled for the static variant also to the shared variant. However, this causes problem when vendor-specific srcs are specified in target: {vendor: {srcs: ["..."]}}. For example, let's assume cc_library { name: "libfoo", srcs: ["foo.c"], target: { vendor: { srcs: ["bar.c"], }, }, } Then, static_vendor: inputs = foo.o, bar.o shared_vendor: inputs = foo.o (from static_vendor), bar.o (from static_vendor), bar.o So, bar.o is included twice and this causes multiple symbol definition error. In order to handle the problem, vendor mutator is applied before the linkage mutator and the vendor-specific srcs are squashed in the vendor mutator. Bug: 67731122 Test: build Test: cc_test.go Change-Id: I2a5390295dddfc41260e9b6f02746908cdf47228
Diffstat (limited to 'cc/cc.go')
-rw-r--r--cc/cc.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/cc/cc.go b/cc/cc.go
index 0404cfb5..4c02e9e2 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -34,9 +34,9 @@ func init() {
android.RegisterModuleType("cc_defaults", defaultsFactory)
android.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
+ ctx.BottomUp("image", vendorMutator).Parallel()
ctx.BottomUp("link", linkageMutator).Parallel()
ctx.BottomUp("vndk", vndkMutator).Parallel()
- ctx.BottomUp("image", vendorMutator).Parallel()
ctx.BottomUp("ndk_api", ndkApiMutator).Parallel()
ctx.BottomUp("test_per_src", testPerSrcMutator).Parallel()
ctx.BottomUp("begin", beginMutator).Parallel()
@@ -1297,6 +1297,16 @@ const (
vendorMode = "vendor"
)
+func squashVendorSrcs(m *Module) {
+ if lib, ok := m.compiler.(*libraryDecorator); ok {
+ lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
+ lib.baseCompiler.Properties.Target.Vendor.Srcs...)
+
+ lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
+ lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs...)
+ }
+}
+
func vendorMutator(mctx android.BottomUpMutatorContext) {
if mctx.Os() != android.Android {
return
@@ -1352,11 +1362,15 @@ func vendorMutator(mctx android.BottomUpMutatorContext) {
// This will be available in both /system and /vendor
// or a /system directory that is available to vendor.
mod := mctx.CreateVariations(coreMode, vendorMode)
- mod[1].(*Module).Properties.UseVndk = true
+ vendor := mod[1].(*Module)
+ vendor.Properties.UseVndk = true
+ squashVendorSrcs(vendor)
} else if mctx.Vendor() && m.Properties.Sdk_version == "" {
// This will be available in /vendor only
mod := mctx.CreateVariations(vendorMode)
- mod[0].(*Module).Properties.UseVndk = true
+ vendor := mod[0].(*Module)
+ vendor.Properties.UseVndk = true
+ squashVendorSrcs(vendor)
} else {
// This is either in /system (or similar: /data), or is a
// modules built with the NDK. Modules built with the NDK