Merge "Update version_script to be handled as linkopt" am: 51da93381c
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1844461 Change-Id: I7740552854fc3056d94092dafd4b79fd0470571a
This commit is contained in:
@@ -803,8 +803,9 @@ cc_library {
|
|||||||
blueprint: soongCcLibraryPreamble,
|
blueprint: soongCcLibraryPreamble,
|
||||||
expectedBazelTargets: []string{`cc_library(
|
expectedBazelTargets: []string{`cc_library(
|
||||||
name = "a",
|
name = "a",
|
||||||
|
additional_linker_inputs = ["v.map"],
|
||||||
|
linkopts = ["-Wl,--version-script,$(location v.map)"],
|
||||||
srcs = ["a.cpp"],
|
srcs = ["a.cpp"],
|
||||||
version_script = "v.map",
|
|
||||||
)`},
|
)`},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -838,12 +839,17 @@ cc_library {
|
|||||||
blueprint: soongCcLibraryPreamble,
|
blueprint: soongCcLibraryPreamble,
|
||||||
expectedBazelTargets: []string{`cc_library(
|
expectedBazelTargets: []string{`cc_library(
|
||||||
name = "a",
|
name = "a",
|
||||||
srcs = ["a.cpp"],
|
additional_linker_inputs = select({
|
||||||
version_script = select({
|
"//build/bazel/platforms/arch:arm": ["arm.map"],
|
||||||
"//build/bazel/platforms/arch:arm": "arm.map",
|
"//build/bazel/platforms/arch:arm64": ["arm64.map"],
|
||||||
"//build/bazel/platforms/arch:arm64": "arm64.map",
|
"//conditions:default": [],
|
||||||
"//conditions:default": None,
|
|
||||||
}),
|
}),
|
||||||
|
linkopts = select({
|
||||||
|
"//build/bazel/platforms/arch:arm": ["-Wl,--version-script,$(location arm.map)"],
|
||||||
|
"//build/bazel/platforms/arch:arm64": ["-Wl,--version-script,$(location arm64.map)"],
|
||||||
|
"//conditions:default": [],
|
||||||
|
}),
|
||||||
|
srcs = ["a.cpp"],
|
||||||
)`},
|
)`},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1010,39 +1016,6 @@ func TestCcLibraryCppFlagsGoesIntoCopts(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCcLibraryLabelAttributeGetTargetProperties(t *testing.T) {
|
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
|
||||||
description: "cc_library GetTargetProperties on a LabelAttribute",
|
|
||||||
moduleTypeUnderTest: "cc_library",
|
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcLibraryPreamble + `
|
|
||||||
cc_library {
|
|
||||||
name: "a",
|
|
||||||
srcs: ["a.cpp"],
|
|
||||||
target: {
|
|
||||||
android_arm: {
|
|
||||||
version_script: "android_arm.map",
|
|
||||||
},
|
|
||||||
linux_bionic_arm64: {
|
|
||||||
version_script: "linux_bionic_arm64.map",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
include_build_directory: false,
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
expectedBazelTargets: []string{`cc_library(
|
|
||||||
name = "a",
|
|
||||||
srcs = ["a.cpp"],
|
|
||||||
version_script = select({
|
|
||||||
"//build/bazel/platforms/os_arch:android_arm": "android_arm.map",
|
|
||||||
"//build/bazel/platforms/os_arch:linux_bionic_arm64": "linux_bionic_arm64.map",
|
|
||||||
"//conditions:default": None,
|
|
||||||
}),
|
|
||||||
)`},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCcLibraryExcludeLibs(t *testing.T) {
|
func TestCcLibraryExcludeLibs(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
|
@@ -361,7 +361,8 @@ cc_library_shared {
|
|||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{`cc_library_shared(
|
expectedBazelTargets: []string{`cc_library_shared(
|
||||||
name = "foo_shared",
|
name = "foo_shared",
|
||||||
version_script = "version_script",
|
additional_linker_inputs = ["version_script"],
|
||||||
|
linkopts = ["-Wl,--version-script,$(location version_script)"],
|
||||||
)`},
|
)`},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
package cc
|
package cc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -397,7 +398,7 @@ type linkerAttributes struct {
|
|||||||
linkCrt bazel.BoolAttribute
|
linkCrt bazel.BoolAttribute
|
||||||
useLibcrt bazel.BoolAttribute
|
useLibcrt bazel.BoolAttribute
|
||||||
linkopts bazel.StringListAttribute
|
linkopts bazel.StringListAttribute
|
||||||
versionScript bazel.LabelAttribute
|
additionalLinkerInputs bazel.LabelListAttribute
|
||||||
stripKeepSymbols bazel.BoolAttribute
|
stripKeepSymbols bazel.BoolAttribute
|
||||||
stripKeepSymbolsAndDebugFrame bazel.BoolAttribute
|
stripKeepSymbolsAndDebugFrame bazel.BoolAttribute
|
||||||
stripKeepSymbolsList bazel.StringListAttribute
|
stripKeepSymbolsList bazel.StringListAttribute
|
||||||
@@ -420,8 +421,8 @@ func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module)
|
|||||||
systemSharedDeps := bazel.LabelListAttribute{ForceSpecifyEmptyList: true}
|
systemSharedDeps := bazel.LabelListAttribute{ForceSpecifyEmptyList: true}
|
||||||
|
|
||||||
var linkopts bazel.StringListAttribute
|
var linkopts bazel.StringListAttribute
|
||||||
var versionScript bazel.LabelAttribute
|
|
||||||
var linkCrt bazel.BoolAttribute
|
var linkCrt bazel.BoolAttribute
|
||||||
|
var additionalLinkerInputs bazel.LabelListAttribute
|
||||||
var useLibcrt bazel.BoolAttribute
|
var useLibcrt bazel.BoolAttribute
|
||||||
|
|
||||||
var stripKeepSymbols bazel.BoolAttribute
|
var stripKeepSymbols bazel.BoolAttribute
|
||||||
@@ -482,7 +483,6 @@ func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module)
|
|||||||
headerDeps.SetSelectValue(axis, config, hDeps.export)
|
headerDeps.SetSelectValue(axis, config, hDeps.export)
|
||||||
implementationHeaderDeps.SetSelectValue(axis, config, hDeps.implementation)
|
implementationHeaderDeps.SetSelectValue(axis, config, hDeps.implementation)
|
||||||
|
|
||||||
linkopts.SetSelectValue(axis, config, baseLinkerProps.Ldflags)
|
|
||||||
if !BoolDefault(baseLinkerProps.Pack_relocations, packRelocationsDefault) {
|
if !BoolDefault(baseLinkerProps.Pack_relocations, packRelocationsDefault) {
|
||||||
axisFeatures = append(axisFeatures, "disable_pack_relocations")
|
axisFeatures = append(axisFeatures, "disable_pack_relocations")
|
||||||
}
|
}
|
||||||
@@ -491,9 +491,16 @@ func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module)
|
|||||||
axisFeatures = append(axisFeatures, "-no_undefined_symbols")
|
axisFeatures = append(axisFeatures, "-no_undefined_symbols")
|
||||||
}
|
}
|
||||||
|
|
||||||
if baseLinkerProps.Version_script != nil {
|
var linkerFlags []string
|
||||||
versionScript.SetSelectValue(axis, config, android.BazelLabelForModuleSrcSingle(ctx, *baseLinkerProps.Version_script))
|
if len(baseLinkerProps.Ldflags) > 0 {
|
||||||
|
linkerFlags = append(linkerFlags, baseLinkerProps.Ldflags...)
|
||||||
}
|
}
|
||||||
|
if baseLinkerProps.Version_script != nil {
|
||||||
|
label := android.BazelLabelForModuleSrcSingle(ctx, *baseLinkerProps.Version_script)
|
||||||
|
additionalLinkerInputs.SetSelectValue(axis, config, bazel.LabelList{Includes: []bazel.Label{label}})
|
||||||
|
linkerFlags = append(linkerFlags, fmt.Sprintf("-Wl,--version-script,$(location %s)", label.Label))
|
||||||
|
}
|
||||||
|
linkopts.SetSelectValue(axis, config, linkerFlags)
|
||||||
useLibcrt.SetSelectValue(axis, config, baseLinkerProps.libCrt())
|
useLibcrt.SetSelectValue(axis, config, baseLinkerProps.libCrt())
|
||||||
|
|
||||||
// it's very unlikely for nocrt to be arch variant, so bp2build doesn't support it.
|
// it's very unlikely for nocrt to be arch variant, so bp2build doesn't support it.
|
||||||
@@ -585,10 +592,10 @@ func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module)
|
|||||||
wholeArchiveDeps: wholeArchiveDeps,
|
wholeArchiveDeps: wholeArchiveDeps,
|
||||||
systemDynamicDeps: systemSharedDeps,
|
systemDynamicDeps: systemSharedDeps,
|
||||||
|
|
||||||
linkCrt: linkCrt,
|
linkCrt: linkCrt,
|
||||||
linkopts: linkopts,
|
linkopts: linkopts,
|
||||||
useLibcrt: useLibcrt,
|
useLibcrt: useLibcrt,
|
||||||
versionScript: versionScript,
|
additionalLinkerInputs: additionalLinkerInputs,
|
||||||
|
|
||||||
// Strip properties
|
// Strip properties
|
||||||
stripKeepSymbols: stripKeepSymbols,
|
stripKeepSymbols: stripKeepSymbols,
|
||||||
|
@@ -253,8 +253,8 @@ type bazelCcLibraryAttributes struct {
|
|||||||
Cpp_std *string
|
Cpp_std *string
|
||||||
|
|
||||||
// This is shared only.
|
// This is shared only.
|
||||||
Version_script bazel.LabelAttribute
|
Link_crt bazel.BoolAttribute
|
||||||
Link_crt bazel.BoolAttribute
|
Additional_linker_inputs bazel.LabelListAttribute
|
||||||
|
|
||||||
// Common properties shared between both shared and static variants.
|
// Common properties shared between both shared and static variants.
|
||||||
Shared staticOrSharedAttributes
|
Shared staticOrSharedAttributes
|
||||||
@@ -332,7 +332,7 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) {
|
|||||||
Stl: compilerAttrs.stl,
|
Stl: compilerAttrs.stl,
|
||||||
Cpp_std: compilerAttrs.cppStd,
|
Cpp_std: compilerAttrs.cppStd,
|
||||||
|
|
||||||
Version_script: linkerAttrs.versionScript,
|
Additional_linker_inputs: linkerAttrs.additionalLinkerInputs,
|
||||||
|
|
||||||
Strip: stripAttributes{
|
Strip: stripAttributes{
|
||||||
Keep_symbols: linkerAttrs.stripKeepSymbols,
|
Keep_symbols: linkerAttrs.stripKeepSymbols,
|
||||||
@@ -2402,7 +2402,6 @@ func ccSharedOrStaticBp2BuildMutatorInternal(ctx android.TopDownMutatorContext,
|
|||||||
attrs = &bazelCcLibraryStaticAttributes{
|
attrs = &bazelCcLibraryStaticAttributes{
|
||||||
staticOrSharedAttributes: commonAttrs,
|
staticOrSharedAttributes: commonAttrs,
|
||||||
|
|
||||||
Linkopts: linkerAttrs.linkopts,
|
|
||||||
Use_libcrt: linkerAttrs.useLibcrt,
|
Use_libcrt: linkerAttrs.useLibcrt,
|
||||||
Rtti: compilerAttrs.rtti,
|
Rtti: compilerAttrs.rtti,
|
||||||
Stl: compilerAttrs.stl,
|
Stl: compilerAttrs.stl,
|
||||||
@@ -2433,11 +2432,11 @@ func ccSharedOrStaticBp2BuildMutatorInternal(ctx android.TopDownMutatorContext,
|
|||||||
Stl: compilerAttrs.stl,
|
Stl: compilerAttrs.stl,
|
||||||
Cpp_std: compilerAttrs.cppStd,
|
Cpp_std: compilerAttrs.cppStd,
|
||||||
|
|
||||||
Export_includes: exportedIncludes.Includes,
|
Export_includes: exportedIncludes.Includes,
|
||||||
Export_system_includes: exportedIncludes.SystemIncludes,
|
Export_system_includes: exportedIncludes.SystemIncludes,
|
||||||
Local_includes: compilerAttrs.localIncludes,
|
Local_includes: compilerAttrs.localIncludes,
|
||||||
Absolute_includes: compilerAttrs.absoluteIncludes,
|
Absolute_includes: compilerAttrs.absoluteIncludes,
|
||||||
Version_script: linkerAttrs.versionScript,
|
Additional_linker_inputs: linkerAttrs.additionalLinkerInputs,
|
||||||
|
|
||||||
Strip: stripAttributes{
|
Strip: stripAttributes{
|
||||||
Keep_symbols: linkerAttrs.stripKeepSymbols,
|
Keep_symbols: linkerAttrs.stripKeepSymbols,
|
||||||
@@ -2463,7 +2462,6 @@ func ccSharedOrStaticBp2BuildMutatorInternal(ctx android.TopDownMutatorContext,
|
|||||||
type bazelCcLibraryStaticAttributes struct {
|
type bazelCcLibraryStaticAttributes struct {
|
||||||
staticOrSharedAttributes
|
staticOrSharedAttributes
|
||||||
|
|
||||||
Linkopts bazel.StringListAttribute
|
|
||||||
Use_libcrt bazel.BoolAttribute
|
Use_libcrt bazel.BoolAttribute
|
||||||
Rtti bazel.BoolAttribute
|
Rtti bazel.BoolAttribute
|
||||||
Stl *string
|
Stl *string
|
||||||
@@ -2503,8 +2501,8 @@ type bazelCcLibrarySharedAttributes struct {
|
|||||||
Absolute_includes bazel.StringListAttribute
|
Absolute_includes bazel.StringListAttribute
|
||||||
Hdrs bazel.LabelListAttribute
|
Hdrs bazel.LabelListAttribute
|
||||||
|
|
||||||
Strip stripAttributes
|
Strip stripAttributes
|
||||||
Version_script bazel.LabelAttribute
|
Additional_linker_inputs bazel.LabelListAttribute
|
||||||
|
|
||||||
Cppflags bazel.StringListAttribute
|
Cppflags bazel.StringListAttribute
|
||||||
Conlyflags bazel.StringListAttribute
|
Conlyflags bazel.StringListAttribute
|
||||||
|
Reference in New Issue
Block a user