diff options
| author | 2022-10-20 21:53:58 +0000 | |
|---|---|---|
| committer | 2022-10-20 21:53:58 +0000 | |
| commit | 7c376043e00ceeefaac82f7d31ba4130f7c59cd6 (patch) | |
| tree | 48e41272e94a6ed9b13ba017924642431c37ccb4 | |
| parent | 6b89a133b3d717029f271e7d2e90de580c9a18c9 (diff) | |
| parent | e725b4e5e0011bfb78df3511444e2508a08bef53 (diff) | |
Merge "Use static libclang_rt.ubsan_standalone runtime for musl"
| -rw-r--r-- | cc/sanitize.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cc/sanitize.go b/cc/sanitize.go index 7c073e279..a446cbbf4 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -1392,6 +1392,7 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) { // Determine the runtime library required runtimeLibrary := "" + alwaysStaticRuntime := false var extraStaticDeps []string toolchain := c.toolchain(mctx) if Bool(c.sanitize.Properties.Sanitize.Address) { @@ -1416,8 +1417,15 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) { Bool(c.sanitize.Properties.Sanitize.Undefined) || Bool(c.sanitize.Properties.Sanitize.All_undefined) { runtimeLibrary = config.UndefinedBehaviorSanitizerRuntimeLibrary(toolchain) - if c.staticBinary() { + if c.staticBinary() || toolchain.Musl() { + // Use a static runtime for static binaries. + // Also use a static runtime for musl to match + // what clang does for glibc. Otherwise dlopening + // libraries that depend on libclang_rt.ubsan_standalone.so + // fails with: + // Error relocating ...: initial-exec TLS resolves to dynamic definition runtimeLibrary += ".static" + alwaysStaticRuntime = true } } @@ -1461,7 +1469,7 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) { // // Note that by adding dependency with {static|shared}DepTag, the lib is // added to libFlags and LOCAL_SHARED_LIBRARIES by cc.Module - if c.staticBinary() { + if c.staticBinary() || alwaysStaticRuntime { addStaticDeps(runtimeLibrary) addStaticDeps(extraStaticDeps...) } else if !c.static() && !c.Header() { |