Merge "bp2build: build static version of libstdc++." am: ee4e7fe76f
am: 5603f8daac
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1693386 Change-Id: I242da21208061c29082b3a7079a0594f0dfecf31
This commit is contained in:
@@ -210,7 +210,6 @@ var (
|
|||||||
"libc_tzcode", // http://b/186822591, cc_library_static, localtime.c:84:46: error: expected expression
|
"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_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
|
"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
|
"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
|
// http://b/186823769: Needs C++ STL support, includes from unconverted standard libraries in //external/libcxx
|
||||||
@@ -237,6 +236,12 @@ var (
|
|||||||
"libjemalloc5_unittest",
|
"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
|
// Per-module denylist to opt modules out of mixed builds. Such modules will
|
||||||
// still be generated via bp2build.
|
// still be generated via bp2build.
|
||||||
mixedBuildsDisabledList = []string{
|
mixedBuildsDisabledList = []string{
|
||||||
@@ -251,6 +256,7 @@ var (
|
|||||||
// Used for quicker lookups
|
// Used for quicker lookups
|
||||||
bp2buildDoNotWriteBuildFile = map[string]bool{}
|
bp2buildDoNotWriteBuildFile = map[string]bool{}
|
||||||
bp2buildModuleDoNotConvert = map[string]bool{}
|
bp2buildModuleDoNotConvert = map[string]bool{}
|
||||||
|
bp2buildCcLibraryStaticOnly = map[string]bool{}
|
||||||
mixedBuildsDisabled = map[string]bool{}
|
mixedBuildsDisabled = map[string]bool{}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -263,11 +269,19 @@ func init() {
|
|||||||
bp2buildModuleDoNotConvert[moduleName] = true
|
bp2buildModuleDoNotConvert[moduleName] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, moduleName := range bp2buildCcLibraryStaticOnlyList {
|
||||||
|
bp2buildCcLibraryStaticOnly[moduleName] = true
|
||||||
|
}
|
||||||
|
|
||||||
for _, moduleName := range mixedBuildsDisabledList {
|
for _, moduleName := range mixedBuildsDisabledList {
|
||||||
mixedBuildsDisabled[moduleName] = true
|
mixedBuildsDisabled[moduleName] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GenerateCcLibraryStaticOnly(ctx BazelConversionPathContext) bool {
|
||||||
|
return bp2buildCcLibraryStaticOnly[ctx.Module().Name()]
|
||||||
|
}
|
||||||
|
|
||||||
func ShouldWriteBuildFileForDir(dir string) bool {
|
func ShouldWriteBuildFileForDir(dir string) bool {
|
||||||
if _, ok := bp2buildDoNotWriteBuildFile[dir]; ok {
|
if _, ok := bp2buildDoNotWriteBuildFile[dir]; ok {
|
||||||
return false
|
return false
|
||||||
@@ -285,6 +299,12 @@ func (b *BazelModuleBase) MixedBuildsEnabled(ctx BazelConversionPathContext) boo
|
|||||||
if len(b.GetBazelLabel(ctx, ctx.Module())) == 0 {
|
if len(b.GetBazelLabel(ctx, ctx.Module())) == 0 {
|
||||||
return false
|
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()]
|
return !mixedBuildsDisabled[ctx.Module().Name()]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -259,6 +259,14 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For some cc_library modules, their static variants are ready to be
|
||||||
|
// converted, but not their shared variants. For these modules, delegate to
|
||||||
|
// the cc_library_static bp2build converter temporarily instead.
|
||||||
|
if android.GenerateCcLibraryStaticOnly(ctx) {
|
||||||
|
ccLibraryStaticBp2BuildInternal(ctx, m)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
sharedAttrs := bp2BuildParseSharedProps(ctx, m)
|
sharedAttrs := bp2BuildParseSharedProps(ctx, m)
|
||||||
staticAttrs := bp2BuildParseStaticProps(ctx, m)
|
staticAttrs := bp2BuildParseStaticProps(ctx, m)
|
||||||
compilerAttrs := bp2BuildParseCompilerProps(ctx, m)
|
compilerAttrs := bp2BuildParseCompilerProps(ctx, m)
|
||||||
@@ -2205,6 +2213,28 @@ func BazelCcLibraryStaticFactory() android.Module {
|
|||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ccLibraryStaticBp2BuildInternal(ctx android.TopDownMutatorContext, module *Module) {
|
||||||
|
compilerAttrs := bp2BuildParseCompilerProps(ctx, module)
|
||||||
|
linkerAttrs := bp2BuildParseLinkerProps(ctx, module)
|
||||||
|
exportedIncludes := bp2BuildParseExportedIncludes(ctx, module)
|
||||||
|
|
||||||
|
attrs := &bazelCcLibraryStaticAttributes{
|
||||||
|
Copts: compilerAttrs.copts,
|
||||||
|
Srcs: compilerAttrs.srcs,
|
||||||
|
Deps: linkerAttrs.deps,
|
||||||
|
Linkopts: linkerAttrs.linkopts,
|
||||||
|
Linkstatic: true,
|
||||||
|
Includes: exportedIncludes,
|
||||||
|
}
|
||||||
|
|
||||||
|
props := bazel.BazelTargetModuleProperties{
|
||||||
|
Rule_class: "cc_library_static",
|
||||||
|
Bzl_load_location: "//build/bazel/rules:cc_library_static.bzl",
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.CreateBazelTargetModule(BazelCcLibraryStaticFactory, module.Name(), props, attrs)
|
||||||
|
}
|
||||||
|
|
||||||
func CcLibraryStaticBp2Build(ctx android.TopDownMutatorContext) {
|
func CcLibraryStaticBp2Build(ctx android.TopDownMutatorContext) {
|
||||||
module, ok := ctx.Module().(*Module)
|
module, ok := ctx.Module().(*Module)
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -2218,24 +2248,7 @@ func CcLibraryStaticBp2Build(ctx android.TopDownMutatorContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
compilerAttrs := bp2BuildParseCompilerProps(ctx, module)
|
ccLibraryStaticBp2BuildInternal(ctx, module)
|
||||||
linkerAttrs := bp2BuildParseLinkerProps(ctx, module)
|
|
||||||
exportedIncludes := bp2BuildParseExportedIncludes(ctx, module)
|
|
||||||
|
|
||||||
attrs := &bazelCcLibraryStaticAttributes{
|
|
||||||
Copts: compilerAttrs.copts,
|
|
||||||
Srcs: compilerAttrs.srcs,
|
|
||||||
Deps: linkerAttrs.deps,
|
|
||||||
Linkstatic: true,
|
|
||||||
Includes: exportedIncludes,
|
|
||||||
}
|
|
||||||
|
|
||||||
props := bazel.BazelTargetModuleProperties{
|
|
||||||
Rule_class: "cc_library_static",
|
|
||||||
Bzl_load_location: "//build/bazel/rules:cc_library_static.bzl",
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.CreateBazelTargetModule(BazelCcLibraryStaticFactory, module.Name(), props, attrs)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *bazelCcLibraryStatic) Name() string {
|
func (m *bazelCcLibraryStatic) Name() string {
|
||||||
|
Reference in New Issue
Block a user