aboutsummaryrefslogtreecommitdiffstats
path: root/cc/linker.go
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2018-12-03 15:25:46 -0800
committerDan Willemsen <dwillemsen@google.com>2018-12-03 15:38:39 -0800
commit3a26eefdbefefa20c43f88cc011ce2406f691caf (patch)
tree6fb3e7cdc36381faa6bb72906b55d566990386d7 /cc/linker.go
parent5b46a085d767a4a2d2e181421d5aec4fcc9eacd8 (diff)
downloadbuild_soong-3a26eefdbefefa20c43f88cc011ce2406f691caf.tar.gz
build_soong-3a26eefdbefefa20c43f88cc011ce2406f691caf.tar.bz2
build_soong-3a26eefdbefefa20c43f88cc011ce2406f691caf.zip
Apply system_shared_libs to static libraries
Even though we aren't doing any linking for static libraries, the default libraries (libc, libm, libdl) are now exporting headers, so we should be using those for both static and shared libraries (especially when re-using objects between the two). Without this we've been in a state where a cc_library will compile differently than a cc_library_shared, as we'd re-use the compilation units from the static variant in the shared library. This does require marking many of libc's dependencies as not using libc with system_shared_libs, otherwise we run into dependency loops. Test: treehugger Change-Id: Ie42edc5184f315f998db953594e425214b810e0e
Diffstat (limited to 'cc/linker.go')
-rw-r--r--cc/linker.go49
1 files changed, 24 insertions, 25 deletions
diff --git a/cc/linker.go b/cc/linker.go
index 3c516906..854dfc57 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -49,7 +49,7 @@ type BaseLinkerProperties struct {
// list of system libraries that will be dynamically linked to
// shared library and executable modules. If unset, generally defaults to libc,
// libm, and libdl. Set to [] to prevent linking against the defaults.
- System_shared_libs []string
+ System_shared_libs []string `android:"arch_variant"`
// allow the module to contain undefined symbols. By default,
// modules cannot contain undefined symbols that are not satisified by their immediate
@@ -237,35 +237,34 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.LateStaticLibs = append(deps.LateStaticLibs, "libgcc")
}
- if !ctx.static() {
- systemSharedLibs := linker.Properties.System_shared_libs
- if systemSharedLibs == nil {
- systemSharedLibs = []string{"libc", "libm", "libdl"}
- }
+ var systemSharedLibs []string
+ if !ctx.useSdk() && !ctx.useVndk() {
+ systemSharedLibs = linker.Properties.System_shared_libs
+ }
+ if systemSharedLibs == nil {
+ systemSharedLibs = []string{"libc", "libm", "libdl"}
+ }
- if inList("libdl", deps.SharedLibs) {
- // If system_shared_libs has libc but not libdl, make sure shared_libs does not
- // have libdl to avoid loading libdl before libc.
- if inList("libc", systemSharedLibs) {
- if !inList("libdl", systemSharedLibs) {
- ctx.PropertyErrorf("shared_libs",
- "libdl must be in system_shared_libs, not shared_libs")
- }
- _, deps.SharedLibs = removeFromList("libdl", deps.SharedLibs)
+ if inList("libdl", deps.SharedLibs) {
+ // If system_shared_libs has libc but not libdl, make sure shared_libs does not
+ // have libdl to avoid loading libdl before libc.
+ if inList("libc", systemSharedLibs) {
+ if !inList("libdl", systemSharedLibs) {
+ ctx.PropertyErrorf("shared_libs",
+ "libdl must be in system_shared_libs, not shared_libs")
}
+ _, deps.SharedLibs = removeFromList("libdl", deps.SharedLibs)
}
+ }
- // If libc and libdl are both in system_shared_libs make sure libd comes after libc
- // to avoid loading libdl before libc.
- if inList("libdl", systemSharedLibs) && inList("libc", systemSharedLibs) &&
- indexList("libdl", systemSharedLibs) < indexList("libc", systemSharedLibs) {
- ctx.PropertyErrorf("system_shared_libs", "libdl must be after libc")
- }
-
- deps.LateSharedLibs = append(deps.LateSharedLibs, systemSharedLibs...)
- } else if ctx.useSdk() || ctx.useVndk() {
- deps.LateSharedLibs = append(deps.LateSharedLibs, "libc", "libm", "libdl")
+ // If libc and libdl are both in system_shared_libs make sure libdl comes after libc
+ // to avoid loading libdl before libc.
+ if inList("libdl", systemSharedLibs) && inList("libc", systemSharedLibs) &&
+ indexList("libdl", systemSharedLibs) < indexList("libc", systemSharedLibs) {
+ ctx.PropertyErrorf("system_shared_libs", "libdl must be after libc")
}
+
+ deps.LateSharedLibs = append(deps.LateSharedLibs, systemSharedLibs...)
}
if ctx.Windows() {