bp2build: build static version of libstdc++.
This CL adds the ability to filter cc_library modules to only generate
their static variant of their shared variant isn't ready.
For example, the libstdc++ library is buildable as a static library,
which libc depends on. However, the shared variant of libstdc++ depends
on libc, which has to come later.
This CL introduces that abstraction to break up bp2build conversion into
more atomic steps to help with conversion.
Test: TH (bazel build //bionic/... incl. libstdc++'s static variant)
Bug: 186489250
Bug: 186822597
Change-Id: I3e2fe748e4e3d3b656760da4807f342d67c8f45f
diff --git a/android/bazel.go b/android/bazel.go
index 22d558f..9de016e 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -210,7 +210,6 @@
"libc_tzcode", // http://b/186822591, cc_library_static, localtime.c:84:46: error: expected expression
"libc_bionic_ndk", // http://b/186822256, cc_library_static, signal.cpp:186:52: error: ISO C++ requires field designators to be specified in declaration order
"libc_malloc_hooks", // http://b/187016307, cc_library, ld.lld: error: undefined symbol: __malloc_hook
- "libstdc++", // http://b/186822597, cc_library, ld.lld: error: undefined symbol: __errno
"libm", // http://b/183064661, cc_library, math.h:25:16: error: unexpected token in argument list
// http://b/186823769: Needs C++ STL support, includes from unconverted standard libraries in //external/libcxx
@@ -237,6 +236,12 @@
"libjemalloc5_unittest",
}
+ // Per-module denylist of cc_library modules to only generate the static
+ // variant if their shared variant isn't ready or buildable by Bazel.
+ bp2buildCcLibraryStaticOnlyList = []string{
+ "libstdc++", // http://b/186822597, cc_library, ld.lld: error: undefined symbol: __errno
+ }
+
// Per-module denylist to opt modules out of mixed builds. Such modules will
// still be generated via bp2build.
mixedBuildsDisabledList = []string{
@@ -250,6 +255,7 @@
// Used for quicker lookups
bp2buildDoNotWriteBuildFile = map[string]bool{}
bp2buildModuleDoNotConvert = map[string]bool{}
+ bp2buildCcLibraryStaticOnly = map[string]bool{}
mixedBuildsDisabled = map[string]bool{}
)
@@ -262,11 +268,19 @@
bp2buildModuleDoNotConvert[moduleName] = true
}
+ for _, moduleName := range bp2buildCcLibraryStaticOnlyList {
+ bp2buildCcLibraryStaticOnly[moduleName] = true
+ }
+
for _, moduleName := range mixedBuildsDisabledList {
mixedBuildsDisabled[moduleName] = true
}
}
+func GenerateCcLibraryStaticOnly(ctx BazelConversionPathContext) bool {
+ return bp2buildCcLibraryStaticOnly[ctx.Module().Name()]
+}
+
func ShouldWriteBuildFileForDir(dir string) bool {
if _, ok := bp2buildDoNotWriteBuildFile[dir]; ok {
return false
@@ -284,6 +298,12 @@
if len(b.GetBazelLabel(ctx, ctx.Module())) == 0 {
return false
}
+ if GenerateCcLibraryStaticOnly(ctx) {
+ // Don't use partially-converted cc_library targets in mixed builds,
+ // since mixed builds would generally rely on both static and shared
+ // variants of a cc_library.
+ return false
+ }
return !mixedBuildsDisabled[ctx.Module().Name()]
}