From 7a108bccaddb72b6ef76e1d7cd22136c7cd12c52 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 30 Jan 2017 22:44:19 -0800 Subject: [PATCH] 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 --- cc/binary.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cc/binary.go b/cc/binary.go index d6a72a264..afc8a990c 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -41,6 +41,9 @@ type BinaryLinkerProperties struct { // 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 @@ func (binary *binaryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags 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") + } } }