convert hidden visibility flag to feature
in bp2build. The context here is that `-fvisibility=default` should
only be added for CFI if `-fvisibility=hidden` is not already
specified. This will be achieved using toolchain features. Note
that Soong itself never adds `-fvisibility=hidden`. This is only
ever added in the `cflags` property of a bp file.
Bug: 261733820
Test: Unit tests
Change-Id: Ib821e8c30a9cd03d2929b4bd2e771bec7b33fa66
diff --git a/cc/library.go b/cc/library.go
index 172ca64..1daeeff 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -311,6 +311,11 @@
asFlags = bazel.MakeStringListAttribute(nil)
}
+ sharedFeatures := baseAttributes.features.Clone().Append(sharedAttrs.Features)
+ sharedFeatures.DeduplicateAxesFromBase()
+ staticFeatures := baseAttributes.features.Clone().Append(staticAttrs.Features)
+ staticFeatures.DeduplicateAxesFromBase()
+
staticCommonAttrs := staticOrSharedAttributes{
Srcs: *srcs.Clone().Append(staticAttrs.Srcs),
Srcs_c: *compilerAttrs.cSrcs.Clone().Append(staticAttrs.Srcs_c),
@@ -366,7 +371,7 @@
Cpp_std: compilerAttrs.cppStd,
C_std: compilerAttrs.cStd,
- Features: baseAttributes.features,
+ Features: *staticFeatures,
}
sharedTargetAttrs := &bazelCcLibrarySharedAttributes{
@@ -390,7 +395,7 @@
Additional_linker_inputs: linkerAttrs.additionalLinkerInputs,
Strip: stripAttrsFromLinkerAttrs(&linkerAttrs),
- Features: baseAttributes.features,
+ Features: *sharedFeatures,
bazelCcHeaderAbiCheckerAttributes: bp2buildParseAbiCheckerProps(ctx, m),
Fdo_profile: compilerAttrs.fdoProfile,
@@ -2881,6 +2886,9 @@
asFlags = bazel.MakeStringListAttribute(nil)
}
+ features := baseAttributes.features.Clone().Append(libSharedOrStaticAttrs.Features)
+ features.DeduplicateAxesFromBase()
+
commonAttrs := staticOrSharedAttributes{
Srcs: compilerAttrs.srcs,
Srcs_c: compilerAttrs.cSrcs,
@@ -2922,7 +2930,7 @@
Conlyflags: compilerAttrs.conlyFlags,
Asflags: asFlags,
- Features: baseAttributes.features,
+ Features: *features,
}
} else {
commonAttrs.Dynamic_deps.Add(baseAttributes.protoDependency)
@@ -2951,7 +2959,7 @@
Strip: stripAttrsFromLinkerAttrs(&linkerAttrs),
- Features: baseAttributes.features,
+ Features: *features,
Suffix: compilerAttrs.suffix,