aboutsummaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2015-04-27 11:13:34 -0700
committerColin Cross <ccross@android.com>2015-04-27 11:18:21 -0700
commit712fc026df63504311e7ad4d348320497d6a9414 (patch)
treeab3ef116ba419d0560ac17203827d1777dec4770 /cc
parent9ffb4f529536e22a9fb6135b2804f1efdf942d97 (diff)
downloadbuild_soong-712fc026df63504311e7ad4d348320497d6a9414.tar.gz
build_soong-712fc026df63504311e7ad4d348320497d6a9414.tar.bz2
build_soong-712fc026df63504311e7ad4d348320497d6a9414.zip
Fix gcc libraries for host targets with platform libc++
Targeting the platform-provided libc++ on the host requires passing -nodefautlibs to gcc, and then re-adding all the default libs except libc++. Change-Id: I5a42375bcc819b07f6ee02e9d76e7f5088fa00e0
Diffstat (limited to 'cc')
-rw-r--r--cc/cc.go18
1 files changed, 16 insertions, 2 deletions
diff --git a/cc/cc.go b/cc/cc.go
index 9f063543..f527bf1c 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -743,6 +743,11 @@ func (c *CCLinked) stl(ctx common.AndroidBaseContext) string {
}
}
+var (
+ hostDynamicGccLibs = []string{"-lgcc_s", "-lgcc", "-lc", "-lgcc_s", "-lgcc"}
+ hostStaticGccLibs = []string{"-Wl,--start-group", "-lgcc", "-lgcc_eh", "-lc", "-Wl,--end-group"}
+)
+
func (c *CCLinked) Flags(ctx common.AndroidModuleContext, flags CCFlags) CCFlags {
stl := c.stl(ctx)
if ctx.Failed() {
@@ -756,7 +761,12 @@ func (c *CCLinked) Flags(ctx common.AndroidModuleContext, flags CCFlags) CCFlags
if ctx.Host() {
flags.CppFlags = append(flags.CppFlags, "-nostdinc++")
flags.LdFlags = append(flags.LdFlags, "-nodefaultlibs")
- flags.LdFlags = append(flags.LdFlags, "-lc", "-lm", "-lpthread")
+ flags.LdFlags = append(flags.LdFlags, "-lm", "-lpthread")
+ if c.shared() {
+ flags.LdFlags = append(flags.LdFlags, hostDynamicGccLibs...)
+ } else {
+ flags.LdFlags = append(flags.LdFlags, hostStaticGccLibs...)
+ }
}
case "stlport", "stlport_static":
if ctx.Device() {
@@ -785,7 +795,11 @@ func (c *CCLinked) Flags(ctx common.AndroidModuleContext, flags CCFlags) CCFlags
if ctx.Host() {
flags.CppFlags = append(flags.CppFlags, "-nostdinc++")
flags.LdFlags = append(flags.LdFlags, "-nodefaultlibs")
- flags.LdFlags = append(flags.LdFlags, "-lc", "-lm")
+ if c.shared() {
+ flags.LdFlags = append(flags.LdFlags, hostDynamicGccLibs...)
+ } else {
+ flags.LdFlags = append(flags.LdFlags, hostStaticGccLibs...)
+ }
}
default:
panic(fmt.Errorf("Unknown stl in CCLinked.Flags: %q", stl))