Revert "Block CFI on static libraries"
This reverts commit f9abec0987
.
Reason for revert:
https://b.corp.google.com/issues/301444094
https://b.corp.google.com/issues/301443813
https://b.corp.google.com/issues/301437374
Change-Id: I6fd03e4d3c0930005178ad347f53156be8f15efc
This commit is contained in:
parent
f9abec0987
commit
85d55c2847
8 changed files with 26 additions and 70 deletions
|
@ -1296,42 +1296,6 @@ func (sla StringListAttribute) IsEmpty() bool {
|
||||||
return len(sla.Value) == 0 && !sla.HasConfigurableValues()
|
return len(sla.Value) == 0 && !sla.HasConfigurableValues()
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveFromAllConfigs removes all instances of the specified value from all configurations
|
|
||||||
// of the givenStringListAttribute
|
|
||||||
func (sla *StringListAttribute) RemoveFromAllConfigs(toRemove string) {
|
|
||||||
if removed, removalResult := removeFromList(toRemove, sla.Value); removed {
|
|
||||||
if len(removalResult) > 0 {
|
|
||||||
sla.Value = removalResult
|
|
||||||
} else {
|
|
||||||
sla.Value = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for axis, slsv := range sla.ConfigurableValues {
|
|
||||||
for config, sl := range slsv {
|
|
||||||
if removed, removalResult := removeFromList(toRemove, sl); removed {
|
|
||||||
if len(removalResult) > 0 {
|
|
||||||
sla.SetSelectValue(axis, config, removalResult)
|
|
||||||
} else {
|
|
||||||
sla.SetSelectValue(axis, config, nil)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func removeFromList(s string, list []string) (bool, []string) {
|
|
||||||
result := make([]string, 0, len(list))
|
|
||||||
var removed bool
|
|
||||||
for _, item := range list {
|
|
||||||
if item != s {
|
|
||||||
result = append(result, item)
|
|
||||||
} else {
|
|
||||||
removed = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return removed, result
|
|
||||||
}
|
|
||||||
|
|
||||||
type configurableStringLists map[ConfigurationAxis]stringListSelectValues
|
type configurableStringLists map[ConfigurationAxis]stringListSelectValues
|
||||||
|
|
||||||
func (csl configurableStringLists) Append(other configurableStringLists) {
|
func (csl configurableStringLists) Append(other configurableStringLists) {
|
||||||
|
|
|
@ -4785,6 +4785,7 @@ cc_library {
|
||||||
}`,
|
}`,
|
||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
||||||
|
"features": `["android_cfi"]`,
|
||||||
"local_includes": `["."]`,
|
"local_includes": `["."]`,
|
||||||
}),
|
}),
|
||||||
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
||||||
|
@ -4813,6 +4814,10 @@ cc_library {
|
||||||
}`,
|
}`,
|
||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
||||||
|
"features": `select({
|
||||||
|
"//build/bazel/platforms/os:android": ["android_cfi"],
|
||||||
|
"//conditions:default": [],
|
||||||
|
})`,
|
||||||
"local_includes": `["."]`,
|
"local_includes": `["."]`,
|
||||||
}),
|
}),
|
||||||
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
||||||
|
@ -4843,7 +4848,10 @@ cc_library {
|
||||||
}`,
|
}`,
|
||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
||||||
"features": `["android_cfi_assembly_support"]`,
|
"features": `[
|
||||||
|
"android_cfi",
|
||||||
|
"android_cfi_assembly_support",
|
||||||
|
]`,
|
||||||
"local_includes": `["."]`,
|
"local_includes": `["."]`,
|
||||||
}),
|
}),
|
||||||
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
||||||
|
|
|
@ -1522,7 +1522,7 @@ func TestCcLibrarySharedWithCfiAndCfiAssemblySupport(t *testing.T) {
|
||||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||||
Description: "cc_library_shared has correct features when cfi is enabled with cfi assembly support",
|
Description: "cc_library_shared has correct features when cfi is enabled with cfi assembly support",
|
||||||
Blueprint: `
|
Blueprint: `
|
||||||
cc_library_shared {
|
cc_library_static {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
sanitize: {
|
sanitize: {
|
||||||
cfi: true,
|
cfi: true,
|
||||||
|
@ -1532,7 +1532,7 @@ cc_library_shared {
|
||||||
},
|
},
|
||||||
}`,
|
}`,
|
||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
|
||||||
"features": `[
|
"features": `[
|
||||||
"android_cfi",
|
"android_cfi",
|
||||||
"android_cfi_assembly_support",
|
"android_cfi_assembly_support",
|
||||||
|
|
|
@ -2135,9 +2135,9 @@ cc_library_static {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCcLibraryStaticNoCfi(t *testing.T) {
|
func TestCcLibraryStaticWithCfi(t *testing.T) {
|
||||||
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
|
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
|
||||||
Description: "cc_library_static never explicitly enables CFI",
|
Description: "cc_library_static has correct features when cfi is enabled",
|
||||||
Blueprint: `
|
Blueprint: `
|
||||||
cc_library_static {
|
cc_library_static {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
|
@ -2147,6 +2147,7 @@ cc_library_static {
|
||||||
}`,
|
}`,
|
||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
|
MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
|
||||||
|
"features": `["android_cfi"]`,
|
||||||
"local_includes": `["."]`,
|
"local_includes": `["."]`,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -2155,7 +2156,7 @@ cc_library_static {
|
||||||
|
|
||||||
func TestCcLibraryStaticWithCfiOsSpecific(t *testing.T) {
|
func TestCcLibraryStaticWithCfiOsSpecific(t *testing.T) {
|
||||||
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
|
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
|
||||||
Description: "cc_library_static never explicitly enables CFI even for specific variants",
|
Description: "cc_library_static has correct features when cfi is enabled for specific variants",
|
||||||
Blueprint: `
|
Blueprint: `
|
||||||
cc_library_static {
|
cc_library_static {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
|
@ -2169,6 +2170,10 @@ cc_library_static {
|
||||||
}`,
|
}`,
|
||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
|
MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
|
||||||
|
"features": `select({
|
||||||
|
"//build/bazel/platforms/os:android": ["android_cfi"],
|
||||||
|
"//conditions:default": [],
|
||||||
|
})`,
|
||||||
"local_includes": `["."]`,
|
"local_includes": `["."]`,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -2177,7 +2182,7 @@ cc_library_static {
|
||||||
|
|
||||||
func TestCcLibraryStaticWithCfiAndCfiAssemblySupport(t *testing.T) {
|
func TestCcLibraryStaticWithCfiAndCfiAssemblySupport(t *testing.T) {
|
||||||
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
|
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
|
||||||
Description: "cc_library_static will specify cfi_assembly_support feature but not cfi feature",
|
Description: "cc_library_static has correct features when cfi is enabled with cfi_assembly_support",
|
||||||
Blueprint: `
|
Blueprint: `
|
||||||
cc_library_static {
|
cc_library_static {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
|
@ -2190,7 +2195,10 @@ cc_library_static {
|
||||||
}`,
|
}`,
|
||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
|
MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
|
||||||
"features": `["android_cfi_assembly_support"]`,
|
"features": `[
|
||||||
|
"android_cfi",
|
||||||
|
"android_cfi_assembly_support",
|
||||||
|
]`,
|
||||||
"local_includes": `["."]`,
|
"local_includes": `["."]`,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
|
@ -30,7 +30,6 @@ bootstrap_go_package {
|
||||||
"cc.go",
|
"cc.go",
|
||||||
"ccdeps.go",
|
"ccdeps.go",
|
||||||
"check.go",
|
"check.go",
|
||||||
"constants.go",
|
|
||||||
"coverage.go",
|
"coverage.go",
|
||||||
"gen.go",
|
"gen.go",
|
||||||
"generated_cc_library.go",
|
"generated_cc_library.go",
|
||||||
|
|
|
@ -1953,9 +1953,9 @@ func bp2buildSanitizerFeatures(ctx android.BazelConversionPathContext, m *Module
|
||||||
sanitizerCompilerInputs.SetSelectValue(bazel.SanitizersEnabledAxis, bazel.SanitizersEnabled, bazel.MakeLabelListFromTargetNames([]string{*blocklist}))
|
sanitizerCompilerInputs.SetSelectValue(bazel.SanitizersEnabledAxis, bazel.SanitizersEnabled, bazel.MakeLabelListFromTargetNames([]string{*blocklist}))
|
||||||
}
|
}
|
||||||
if sanitizerProps.Sanitize.Cfi != nil && !proptools.Bool(sanitizerProps.Sanitize.Cfi) {
|
if sanitizerProps.Sanitize.Cfi != nil && !proptools.Bool(sanitizerProps.Sanitize.Cfi) {
|
||||||
features = append(features, "-"+cfiFeatureName)
|
features = append(features, "-android_cfi")
|
||||||
} else if proptools.Bool(sanitizerProps.Sanitize.Cfi) {
|
} else if proptools.Bool(sanitizerProps.Sanitize.Cfi) {
|
||||||
features = append(features, cfiFeatureName)
|
features = append(features, "android_cfi")
|
||||||
if proptools.Bool(sanitizerProps.Sanitize.Config.Cfi_assembly_support) {
|
if proptools.Bool(sanitizerProps.Sanitize.Config.Cfi_assembly_support) {
|
||||||
features = append(features, "android_cfi_assembly_support")
|
features = append(features, "android_cfi_assembly_support")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
// Copyright 2016 Google Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package cc
|
|
||||||
|
|
||||||
var (
|
|
||||||
cfiFeatureName = "android_cfi"
|
|
||||||
)
|
|
|
@ -331,7 +331,6 @@ func libraryBp2Build(ctx android.TopDownMutatorContext, m *Module) {
|
||||||
sharedFeatures.DeduplicateAxesFromBase()
|
sharedFeatures.DeduplicateAxesFromBase()
|
||||||
staticFeatures := baseAttributes.features.Clone().Append(staticAttrs.Features)
|
staticFeatures := baseAttributes.features.Clone().Append(staticAttrs.Features)
|
||||||
staticFeatures.DeduplicateAxesFromBase()
|
staticFeatures.DeduplicateAxesFromBase()
|
||||||
staticFeatures.RemoveFromAllConfigs(cfiFeatureName)
|
|
||||||
|
|
||||||
staticCommonAttrs := staticOrSharedAttributes{
|
staticCommonAttrs := staticOrSharedAttributes{
|
||||||
Srcs: *srcs.Clone().Append(staticAttrs.Srcs),
|
Srcs: *srcs.Clone().Append(staticAttrs.Srcs),
|
||||||
|
@ -2947,9 +2946,6 @@ func sharedOrStaticLibraryBp2Build(ctx android.TopDownMutatorContext, module *Mo
|
||||||
|
|
||||||
features := baseAttributes.features.Clone().Append(libSharedOrStaticAttrs.Features)
|
features := baseAttributes.features.Clone().Append(libSharedOrStaticAttrs.Features)
|
||||||
features.DeduplicateAxesFromBase()
|
features.DeduplicateAxesFromBase()
|
||||||
if isStatic {
|
|
||||||
features.RemoveFromAllConfigs(cfiFeatureName)
|
|
||||||
}
|
|
||||||
|
|
||||||
commonAttrs := staticOrSharedAttributes{
|
commonAttrs := staticOrSharedAttributes{
|
||||||
Srcs: compilerAttrs.srcs,
|
Srcs: compilerAttrs.srcs,
|
||||||
|
|
Loading…
Reference in a new issue