Allow clang builds to disable -pie
-pie triggers a bug in glibc's linker when used with goma
(https://sourceware.org/bugzilla/show_bug.cgi?id=16381). Allow
the clang build to disable -pie for host modules through the
DISABLE_HOST_PIE environment variable so it can produce a toolchain
that works with goma.
Bug: 15814177
Bug: 34722791
Change-Id: Ic664a1b821aaeaf2bde14b0afa1a1975e31300cb
diff --git a/cc/binary.go b/cc/binary.go
index d6a72a2..afc8a99 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -41,6 +41,9 @@
// extension (if any) appended
Symlinks []string `android:"arch_variant"`
+ // do not pass -pie
+ No_pie *bool `android:"arch_variant"`
+
DynamicLinker string `blueprint:"mutated"`
}
@@ -194,9 +197,11 @@
flags = binary.baseLinker.linkerFlags(ctx, flags)
if ctx.Host() && !binary.static() {
- flags.LdFlags = append(flags.LdFlags, "-pie")
- if ctx.Os() == android.Windows {
- flags.LdFlags = append(flags.LdFlags, "-Wl,-e_mainCRTStartup")
+ if !ctx.AConfig().IsEnvTrue("DISABLE_HOST_PIE") {
+ flags.LdFlags = append(flags.LdFlags, "-pie")
+ if ctx.Os() == android.Windows {
+ flags.LdFlags = append(flags.LdFlags, "-Wl,-e_mainCRTStartup")
+ }
}
}