Skip -Wl,--version-script on libclang_rt.* stubs (temp hack)

The checked-in libclang_rt.* prebuilts do not contain versioned symbols,
but the autogenerated map.txt file for these libraries contain versions
e.g.
LIBCLANG_RT_ASAN {
  global:
...
}
```

This causes a discrepancy between the symbols in the stubs and impl
variants of these libraries. After https://r.android.com/3236596 is
submitted and a new set of libclang_rt.* prebuilts are generated, this
discrepancy will go away.

For now, skip `-Wl,version-script` when generating the stub
variants of these libraries to prevent link errors at build time.

Test: lunch aosp_panther_hwasan-trunk_staging-userdebug && m crash_dump
Bug: 3222365
Change-Id: Ic1e06cb58ec33b761136ac325f191da7ac900151
This commit is contained in:
Spandan Das
2024-08-15 21:54:09 +00:00
parent c27dd3393c
commit 5922333d5c

View File

@@ -16,6 +16,7 @@ package cc
import ( import (
"path/filepath" "path/filepath"
"strings"
"github.com/google/blueprint/proptools" "github.com/google/blueprint/proptools"
@@ -118,6 +119,22 @@ func (p *prebuiltLibraryLinker) link(ctx ModuleContext,
// Stub variants will create a stub .so file from stub .c files // Stub variants will create a stub .so file from stub .c files
if p.buildStubs() && objs.objFiles != nil { if p.buildStubs() && objs.objFiles != nil {
// TODO (b/275273834): Make objs.objFiles == nil a hard error when the symbol files have been added to module sdk. // TODO (b/275273834): Make objs.objFiles == nil a hard error when the symbol files have been added to module sdk.
// The map.txt files of libclang_rt.* contain version information, but the checked in .so files do not.
// e.g. libclang_rt.* libs impl
// $ nm -D prebuilts/../libclang_rt.hwasan-aarch64-android.so
// __hwasan_init
// stubs generated from .map.txt
// $ nm -D out/soong/.intermediates/../<stubs>/libclang_rt.hwasan-aarch64-android.so
// __hwasan_init@@LIBCLANG_RT_ASAN
// Special-case libclang_rt.* libs to account for this discrepancy.
// TODO (spandandas): Remove this special case https://r.android.com/3236596 has been submitted, and a new set of map.txt
// files of libclang_rt.* libs have been generated.
if strings.Contains(ctx.ModuleName(), "libclang_rt.") {
p.versionScriptPath = android.OptionalPathForPath(nil)
}
return p.linkShared(ctx, flags, deps, objs) return p.linkShared(ctx, flags, deps, objs)
} }