diff options
Diffstat (limited to 'cc')
-rw-r--r-- | cc/cc.go | 4 | ||||
-rw-r--r-- | cc/config/riscv64_device.go | 8 | ||||
-rw-r--r-- | cc/prebuilt.go | 3 | ||||
-rw-r--r-- | cc/prebuilt_test.go | 155 | ||||
-rw-r--r-- | cc/stl.go | 12 |
5 files changed, 168 insertions, 14 deletions
@@ -3361,7 +3361,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { c.sabi.Properties.ReexportedIncludes, depExporterInfo.IncludeDirs.Strings()...) } - makeLibName := MakeLibName(ctx, c, ccDep, depName) + libDepTag.makeSuffix + makeLibName := MakeLibName(ctx, c, ccDep, ccDep.BaseModuleName()) + libDepTag.makeSuffix switch { case libDepTag.header(): c.Properties.AndroidMkHeaderLibs = append( @@ -3402,7 +3402,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { switch depTag { case runtimeDepTag: c.Properties.AndroidMkRuntimeLibs = append( - c.Properties.AndroidMkRuntimeLibs, MakeLibName(ctx, c, ccDep, depName)+libDepTag.makeSuffix) + c.Properties.AndroidMkRuntimeLibs, MakeLibName(ctx, c, ccDep, ccDep.BaseModuleName())+libDepTag.makeSuffix) // Record BaseLibName for snapshots. c.Properties.SnapshotRuntimeLibs = append(c.Properties.SnapshotRuntimeLibs, BaseLibName(depName)) case objDepTag: diff --git a/cc/config/riscv64_device.go b/cc/config/riscv64_device.go index deb922bd2..6a84fee9f 100644 --- a/cc/config/riscv64_device.go +++ b/cc/config/riscv64_device.go @@ -26,9 +26,7 @@ var ( // Help catch common 32/64-bit errors. "-Werror=implicit-function-declaration", "-march=rv64gcv_zba_zbb_zbs", - // Equivalent to "-munaligned-access", but our clang doesn't have that yet. - "-Xclang -target-feature -Xclang +unaligned-scalar-mem", - "-Xclang -target-feature -Xclang +unaligned-vector-mem", + "-munaligned-access", // Until https://gitlab.com/qemu-project/qemu/-/issues/1976 is fixed... "-mno-implicit-float", // (https://github.com/google/android-riscv64/issues/124) @@ -40,9 +38,7 @@ var ( riscv64Ldflags = []string{ "-Wl,--hash-style=gnu", "-march=rv64gcv_zba_zbb_zbs", - // Equivalent to "-munaligned-access", but our clang doesn't have that yet. - "-Xclang -target-feature -Xclang +unaligned-scalar-mem", - "-Xclang -target-feature -Xclang +unaligned-vector-mem", + "-munaligned-access", // We should change the default for this in clang, but for now... // (https://github.com/google/android-riscv64/issues/124) "-Wl,-mllvm -Wl,-jump-is-expensive=false", diff --git a/cc/prebuilt.go b/cc/prebuilt.go index 8f4b7df42..cbb5d58db 100644 --- a/cc/prebuilt.go +++ b/cc/prebuilt.go @@ -260,6 +260,9 @@ func (p *prebuiltLibraryLinker) nativeCoverage() bool { func (p *prebuiltLibraryLinker) disablePrebuilt() { p.properties.Srcs = nil + p.properties.Sanitized.None.Srcs = nil + p.properties.Sanitized.Address.Srcs = nil + p.properties.Sanitized.Hwaddress.Srcs = nil } // Implements versionedInterface diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go index 95fb7edfb..71b7e4369 100644 --- a/cc/prebuilt_test.go +++ b/cc/prebuilt_test.go @@ -595,6 +595,9 @@ func TestMultiplePrebuilts(t *testing.T) { libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Module() expectedDependency := ctx.ModuleForTests(tc.expectedDependencyName, "android_arm64_armv8-a_shared").Module() android.AssertBoolEquals(t, fmt.Sprintf("expected dependency from %s to %s\n", libfoo.Name(), tc.expectedDependencyName), true, hasDep(ctx, libfoo, expectedDependency)) + // check that LOCAL_SHARED_LIBRARIES contains libbar and not libbar.v<N> + entries := android.AndroidMkEntriesForTest(t, ctx, libfoo)[0] + android.AssertStringListContains(t, "Version should not be present in LOCAL_SHARED_LIBRARIES", entries.EntryMap["LOCAL_SHARED_LIBRARIES"], "libbar") // check installation rules // the selected soong module should be exported to make @@ -603,7 +606,157 @@ func TestMultiplePrebuilts(t *testing.T) { // check LOCAL_MODULE of the selected module name // the prebuilt should have the same LOCAL_MODULE when exported to make - entries := android.AndroidMkEntriesForTest(t, ctx, libbar)[0] + entries = android.AndroidMkEntriesForTest(t, ctx, libbar)[0] android.AssertStringEquals(t, "unexpected LOCAL_MODULE", "libbar", entries.EntryMap["LOCAL_MODULE"][0]) } } + +// Setting prefer on multiple prebuilts is an error, unless one of them is also listed in apex_contributions +func TestMultiplePrebuiltsPreferredUsingLegacyFlags(t *testing.T) { + bp := ` + // an rdep + cc_library { + name: "libfoo", + shared_libs: ["libbar"], + } + + // multiple variations of dep + // source + cc_library { + name: "libbar", + } + // prebuilt "v1" + cc_prebuilt_library_shared { + name: "libbar", + srcs: ["libbar.so"], + prefer: true, + } + // prebuilt "v2" + cc_prebuilt_library_shared { + name: "libbar.v2", + stem: "libbar", + source_module_name: "libbar", + srcs: ["libbar.so"], + prefer: true, + } + + // selectors + apex_contributions { + name: "myapex_contributions", + contents: [%v], + } + all_apex_contributions {name: "all_apex_contributions"} + ` + hasDep := func(ctx *android.TestContext, m android.Module, wantDep android.Module) bool { + t.Helper() + var found bool + ctx.VisitDirectDeps(m, func(dep blueprint.Module) { + if dep == wantDep { + found = true + } + }) + return found + } + + testCases := []struct { + desc string + selectedDependencyName string + expectedDependencyName string + expectedErr string + }{ + { + desc: "Multiple prebuilts have prefer: true", + expectedErr: "Multiple prebuilt modules prebuilt_libbar and prebuilt_libbar.v2 have been marked as preferred for this source module", + }, + { + desc: "Multiple prebuilts have prefer: true. The prebuilt listed in apex_contributions wins.", + selectedDependencyName: `"prebuilt_libbar"`, + expectedDependencyName: "prebuilt_libbar", + }, + } + + for _, tc := range testCases { + preparer := android.GroupFixturePreparers( + android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { + android.RegisterApexContributionsBuildComponents(ctx) + }), + android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.BuildFlags = map[string]string{ + "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions", + } + }), + ) + if tc.expectedErr != "" { + preparer = preparer.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(tc.expectedErr)) + } + + ctx := testPrebuilt(t, fmt.Sprintf(bp, tc.selectedDependencyName), map[string][]byte{ + "libbar.so": nil, + "crtx.o": nil, + }, preparer) + if tc.expectedErr != "" { + return // the fixture will assert that the excepted err has been raised + } + libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Module() + expectedDependency := ctx.ModuleForTests(tc.expectedDependencyName, "android_arm64_armv8-a_shared").Module() + android.AssertBoolEquals(t, fmt.Sprintf("expected dependency from %s to %s\n", libfoo.Name(), tc.expectedDependencyName), true, hasDep(ctx, libfoo, expectedDependency)) + } +} + +// If module sdk cannot provide a cc module variant (e.g. static), then the module variant from source should be used +func TestMissingVariantInModuleSdk(t *testing.T) { + bp := ` + // an rdep + cc_library { + name: "libfoo", + static_libs: ["libbar"], + } + + // source + cc_library { + name: "libbar", + } + // prebuilt + // libbar only exists as a shared library + cc_prebuilt_library_shared { + name: "libbar", + srcs: ["libbar.so"], + } + // selectors + apex_contributions { + name: "myapex_contributions", + contents: ["prebuilt_libbar"], + } + all_apex_contributions {name: "all_apex_contributions"} + ` + hasDep := func(ctx *android.TestContext, m android.Module, wantDep android.Module) bool { + t.Helper() + var found bool + ctx.VisitDirectDeps(m, func(dep blueprint.Module) { + if dep == wantDep { + found = true + } + }) + return found + } + + preparer := android.GroupFixturePreparers( + android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { + android.RegisterApexContributionsBuildComponents(ctx) + }), + android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.BuildFlags = map[string]string{ + "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions", + } + }), + ) + ctx := testPrebuilt(t, bp, map[string][]byte{ + "libbar.so": nil, + "crtx.o": nil, + }, preparer) + libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Module() + sourceLibBar := ctx.ModuleForTests("libbar", "android_arm64_armv8-a_static").Module() + // Even though the prebuilt is listed in apex_contributions, the prebuilt does not have a static variant. + // Therefore source of libbar should be used. + android.AssertBoolEquals(t, fmt.Sprintf("expected dependency from libfoo to source libbar"), true, hasDep(ctx, libfoo, sourceLibBar)) +} @@ -205,12 +205,14 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags { flags.extraLibFlags = append(flags.extraLibFlags, "-nostdlib++") if ctx.Windows() { flags.Local.CppFlags = append(flags.Local.CppFlags, - // Disable visiblity annotations since we're using static - // libc++. - "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS", - "-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS", + // These macros can also be defined by libc++'s __config + // or __config_site headers so define them the same way + // (i.e. to nothing). Disable visibility annotations since + // we're using static libc++. + "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=", + "-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS=", // Use Win32 threads in libc++. - "-D_LIBCPP_HAS_THREAD_API_WIN32") + "-D_LIBCPP_HAS_THREAD_API_WIN32=") } } case "libstdc++": |