From 0ead79bd11ef745446382970acfc00b4ac034ecc Mon Sep 17 00:00:00 2001 From: Jingwen Chen Date: Mon, 28 Nov 2022 22:44:35 +0000 Subject: [PATCH] Revert "bp2build conversion for Sanitize.Integer_overflow" Revert submission 2277186-ubsan_bp2build Reason for revert: b/260630869 broke mixed_droid Reverted Changes: Idd9b33e53:bp2build conversion for Sanitize.Integer_overflow I0d636e439:Add Sanitizer libs up the dependency tree If113de7bc:Introduce toolchain features for sanitizers Change-Id: Idf7e7b62f6fb6d4ff92341cc4c9c4b7426b70951 --- bp2build/cc_binary_conversion_test.go | 79 ------------- bp2build/cc_library_conversion_test.go | 110 ------------------ bp2build/cc_library_shared_conversion_test.go | 82 ------------- bp2build/cc_library_static_conversion_test.go | 82 ------------- cc/bp2build.go | 21 +--- 5 files changed, 2 insertions(+), 372 deletions(-) diff --git a/bp2build/cc_binary_conversion_test.go b/bp2build/cc_binary_conversion_test.go index 68dc383ff..8aa2c3ecb 100644 --- a/bp2build/cc_binary_conversion_test.go +++ b/bp2build/cc_binary_conversion_test.go @@ -789,82 +789,3 @@ func TestCcBinaryWithSyspropSrcsSomeConfigs(t *testing.T) { }, }) } - -func TestCcBinaryWithIntegerOverflowProperty(t *testing.T) { - runCcBinaryTestCase(t, ccBinaryBp2buildTestCase{ - description: "cc_binary with integer overflow property specified", - blueprint: ` -{rule_name} { - name: "foo", - sanitize: { - integer_overflow: true, - }, -}`, - targets: []testBazelTarget{ - {"cc_binary", "foo", AttrNameToString{ - "local_includes": `["."]`, - "features": `["ubsan_integer_overflow"]`, - }}, - }, - }) -} - -func TestCcBinaryWithMiscUndefinedProperty(t *testing.T) { - runCcBinaryTestCase(t, ccBinaryBp2buildTestCase{ - description: "cc_binary with miscellaneous properties specified", - blueprint: ` -{rule_name} { - name: "foo", - sanitize: { - misc_undefined: ["undefined", "nullability"], - }, -}`, - targets: []testBazelTarget{ - {"cc_binary", "foo", AttrNameToString{ - "local_includes": `["."]`, - "features": `[ - "ubsan_undefined", - "ubsan_nullability", - ]`, - }}, - }, - }) -} - -func TestCcBinaryWithUBSanPropertiesArchSpecific(t *testing.T) { - runCcBinaryTestCase(t, ccBinaryBp2buildTestCase{ - description: "cc_binary has correct feature select when UBSan props are specified in arch specific blocks", - blueprint: ` -{rule_name} { - name: "foo", - sanitize: { - misc_undefined: ["undefined", "nullability"], - }, - target: { - android: { - sanitize: { - misc_undefined: ["alignment"], - }, - }, - linux_glibc: { - sanitize: { - integer_overflow: true, - }, - }, - }, -}`, - targets: []testBazelTarget{ - {"cc_binary", "foo", AttrNameToString{ - "local_includes": `["."]`, - "features": `[ - "ubsan_undefined", - "ubsan_nullability", - ] + select({ - "//build/bazel/platforms/os:android": ["ubsan_alignment"], - "//build/bazel/platforms/os:linux": ["ubsan_integer_overflow"], - "//conditions:default": [], - })`, - }}, - }, - }) -} diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go index bca8c030b..4c86374b5 100644 --- a/bp2build/cc_library_conversion_test.go +++ b/bp2build/cc_library_conversion_test.go @@ -3543,113 +3543,3 @@ cc_library_static { }, }) } - -func TestCcLibraryWithIntegerOverflowProperty(t *testing.T) { - runCcLibraryTestCase(t, Bp2buildTestCase{ - Description: "cc_library has correct features when integer_overflow property is provided", - ModuleTypeUnderTest: "cc_library", - ModuleTypeUnderTestFactory: cc.LibraryFactory, - Blueprint: ` -cc_library { - name: "foo", - sanitize: { - integer_overflow: true, - }, -} -`, - ExpectedBazelTargets: []string{ - MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{ - "features": `["ubsan_integer_overflow"]`, - "local_includes": `["."]`, - }), - MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ - "features": `["ubsan_integer_overflow"]`, - "local_includes": `["."]`, - }), - }, - }) -} - -func TestCcLibraryWithMiscUndefinedProperty(t *testing.T) { - runCcLibraryTestCase(t, Bp2buildTestCase{ - Description: "cc_library has correct features when misc_undefined property is provided", - ModuleTypeUnderTest: "cc_library", - ModuleTypeUnderTestFactory: cc.LibraryFactory, - Blueprint: ` -cc_library { - name: "foo", - sanitize: { - misc_undefined: ["undefined", "nullability"], - }, -} -`, - ExpectedBazelTargets: []string{ - MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{ - "features": `[ - "ubsan_undefined", - "ubsan_nullability", - ]`, - "local_includes": `["."]`, - }), - MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ - "features": `[ - "ubsan_undefined", - "ubsan_nullability", - ]`, - "local_includes": `["."]`, - }), - }, - }) -} - -func TestCcLibraryWithUBSanPropertiesArchSpecific(t *testing.T) { - runCcLibraryTestCase(t, Bp2buildTestCase{ - Description: "cc_library has correct feature select when UBSan props are specified in arch specific blocks", - ModuleTypeUnderTest: "cc_library", - ModuleTypeUnderTestFactory: cc.LibraryFactory, - Blueprint: ` -cc_library { - name: "foo", - sanitize: { - misc_undefined: ["undefined", "nullability"], - }, - target: { - android: { - sanitize: { - misc_undefined: ["alignment"], - }, - }, - linux_glibc: { - sanitize: { - integer_overflow: true, - }, - }, - }, -} -`, - ExpectedBazelTargets: []string{ - MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{ - "features": `[ - "ubsan_undefined", - "ubsan_nullability", - ] + select({ - "//build/bazel/platforms/os:android": ["ubsan_alignment"], - "//build/bazel/platforms/os:linux": ["ubsan_integer_overflow"], - "//conditions:default": [], - })`, - "local_includes": `["."]`, - }), - MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ - "features": `[ - "ubsan_undefined", - "ubsan_nullability", - ] + select({ - "//build/bazel/platforms/os:android": ["ubsan_alignment"], - "//build/bazel/platforms/os:linux": ["ubsan_integer_overflow"], - "//conditions:default": [], - })`, - "local_includes": `["."]`, - }), - }, - }) -} diff --git a/bp2build/cc_library_shared_conversion_test.go b/bp2build/cc_library_shared_conversion_test.go index 8ef7d16fa..b86f60778 100644 --- a/bp2build/cc_library_shared_conversion_test.go +++ b/bp2build/cc_library_shared_conversion_test.go @@ -845,85 +845,3 @@ cc_library_shared { }, }) } - -func TestCcLibrarySharedWithIntegerOverflowProperty(t *testing.T) { - runCcLibrarySharedTestCase(t, Bp2buildTestCase{ - Description: "cc_library_shared has correct features when integer_overflow property is provided", - Blueprint: ` -cc_library_shared { - name: "foo", - sanitize: { - integer_overflow: true, - }, -} -`, - ExpectedBazelTargets: []string{ - MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ - "features": `["ubsan_integer_overflow"]`, - "local_includes": `["."]`, - }), - }, - }) -} - -func TestCcLibrarySharedWithMiscUndefinedProperty(t *testing.T) { - runCcLibrarySharedTestCase(t, Bp2buildTestCase{ - Description: "cc_library_shared has correct features when misc_undefined property is provided", - Blueprint: ` -cc_library_shared { - name: "foo", - sanitize: { - misc_undefined: ["undefined", "nullability"], - }, -} -`, - ExpectedBazelTargets: []string{ - MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ - "features": `[ - "ubsan_undefined", - "ubsan_nullability", - ]`, - "local_includes": `["."]`, - }), - }, - }) -} - -func TestCcLibrarySharedWithUBSanPropertiesArchSpecific(t *testing.T) { - runCcLibrarySharedTestCase(t, Bp2buildTestCase{ - Description: "cc_library_shared has correct feature select when UBSan props are specified in arch specific blocks", - Blueprint: ` -cc_library_shared { - name: "foo", - sanitize: { - misc_undefined: ["undefined", "nullability"], - }, - target: { - android: { - sanitize: { - misc_undefined: ["alignment"], - }, - }, - linux_glibc: { - sanitize: { - integer_overflow: true, - }, - }, - }, -} -`, - ExpectedBazelTargets: []string{ - MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ - "features": `[ - "ubsan_undefined", - "ubsan_nullability", - ] + select({ - "//build/bazel/platforms/os:android": ["ubsan_alignment"], - "//build/bazel/platforms/os:linux": ["ubsan_integer_overflow"], - "//conditions:default": [], - })`, - "local_includes": `["."]`, - }), - }, - }) -} diff --git a/bp2build/cc_library_static_conversion_test.go b/bp2build/cc_library_static_conversion_test.go index cac7f9b5e..b47d1f1f1 100644 --- a/bp2build/cc_library_static_conversion_test.go +++ b/bp2build/cc_library_static_conversion_test.go @@ -1723,85 +1723,3 @@ cc_library_static { }, }) } - -func TestCcLibraryStaticWithIntegerOverflowProperty(t *testing.T) { - runCcLibraryStaticTestCase(t, Bp2buildTestCase{ - Description: "cc_library_static has correct features when integer_overflow property is provided", - Blueprint: ` -cc_library_static { - name: "foo", - sanitize: { - integer_overflow: true, - }, -} -`, - ExpectedBazelTargets: []string{ - MakeBazelTarget("cc_library_static", "foo", AttrNameToString{ - "features": `["ubsan_integer_overflow"]`, - "local_includes": `["."]`, - }), - }, - }) -} - -func TestCcLibraryStaticWithMiscUndefinedProperty(t *testing.T) { - runCcLibraryStaticTestCase(t, Bp2buildTestCase{ - Description: "cc_library_static has correct features when misc_undefined property is provided", - Blueprint: ` -cc_library_static { - name: "foo", - sanitize: { - misc_undefined: ["undefined", "nullability"], - }, -} -`, - ExpectedBazelTargets: []string{ - MakeBazelTarget("cc_library_static", "foo", AttrNameToString{ - "features": `[ - "ubsan_undefined", - "ubsan_nullability", - ]`, - "local_includes": `["."]`, - }), - }, - }) -} - -func TestCcLibraryStaticWithUBSanPropertiesArchSpecific(t *testing.T) { - runCcLibraryStaticTestCase(t, Bp2buildTestCase{ - Description: "cc_library_static has correct feature select when UBSan props are specified in arch specific blocks", - Blueprint: ` -cc_library_static { - name: "foo", - sanitize: { - misc_undefined: ["undefined", "nullability"], - }, - target: { - android: { - sanitize: { - misc_undefined: ["alignment"], - }, - }, - linux_glibc: { - sanitize: { - integer_overflow: true, - }, - }, - }, -} -`, - ExpectedBazelTargets: []string{ - MakeBazelTarget("cc_library_static", "foo", AttrNameToString{ - "features": `[ - "ubsan_undefined", - "ubsan_nullability", - ] + select({ - "//build/bazel/platforms/os:android": ["ubsan_alignment"], - "//build/bazel/platforms/os:linux": ["ubsan_integer_overflow"], - "//conditions:default": [], - })`, - "local_includes": `["."]`, - }), - }, - }) -} diff --git a/cc/bp2build.go b/cc/bp2build.go index d41aa0057..6caa85422 100644 --- a/cc/bp2build.go +++ b/cc/bp2build.go @@ -341,7 +341,7 @@ type baseAttributes struct { compilerAttributes linkerAttributes - // A combination of compilerAttributes.features and linkerAttributes.features, as well as sanitizer features + // A combination of compilerAttributes.features and linkerAttributes.features features bazel.StringListAttribute protoDependency *bazel.LabelAttribute aidlDependency *bazel.LabelAttribute @@ -781,7 +781,7 @@ func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module) (&linkerAttrs).wholeArchiveDeps.Add(bp2buildCcSysprop(ctx, module.Name(), module.Properties.Min_sdk_version, compilerAttrs.syspropSrcs)) } - features := compilerAttrs.features.Clone().Append(linkerAttrs.features).Append(bp2buildSanitizerFeatures(ctx, module)) + features := compilerAttrs.features.Clone().Append(linkerAttrs.features) features.DeduplicateAxesFromBase() return baseAttributes{ @@ -1364,20 +1364,3 @@ func bp2buildBinaryLinkerProps(ctx android.BazelConversionPathContext, m *Module return attrs } - -func bp2buildSanitizerFeatures(ctx android.BazelConversionPathContext, m *Module) bazel.StringListAttribute { - sanitizerFeatures := bazel.StringListAttribute{} - bp2BuildPropParseHelper(ctx, m, &SanitizeProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) { - var features []string - if sanitizerProps, ok := props.(*SanitizeProperties); ok { - if sanitizerProps.Sanitize.Integer_overflow != nil && *sanitizerProps.Sanitize.Integer_overflow { - features = append(features, "ubsan_integer_overflow") - } - for _, sanitizer := range sanitizerProps.Sanitize.Misc_undefined { - features = append(features, "ubsan_"+sanitizer) - } - sanitizerFeatures.SetSelectValue(axis, config, features) - } - }) - return sanitizerFeatures -}