From 6e97a7b4a19754b903da931f5b170ee018bd3e6c Mon Sep 17 00:00:00 2001 From: Jeff Vander Stoep Date: Wed, 15 Jul 2020 21:34:45 +0200 Subject: [PATCH] rust: Use host linker when building for Mac host. This behavior is non-hermetic, but matches the behavior of the C++ support. On Linux, using lld works, but on OSX, this fails because lld does not support Apple's new .tbd files. Bug: 155302034 Test: On both Linux and Mac hosts: cd external/rust; mma Change-Id: I0ad489113d720bdb9c3b7a67cce9d1e72266f428 --- rust/config/global.go | 5 ++++- rust/config/x86_darwin_host.go | 6 ++++-- rust/config/x86_linux_host.go | 7 +++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/rust/config/global.go b/rust/config/global.go index e1b1775c9..2020f461d 100644 --- a/rust/config/global.go +++ b/rust/config/global.go @@ -54,6 +54,9 @@ var ( "-Wl,--pack-dyn-relocs=android+relr", "-Wl,--no-undefined", "-Wl,--hash-style=gnu", + + "-B${ccConfig.ClangBin}", + "-fuse-ld=lld", } ) @@ -80,7 +83,7 @@ func init() { pctx.ImportAs("ccConfig", "android/soong/cc/config") pctx.StaticVariable("RustLinker", "${ccConfig.ClangBin}/clang++") - pctx.StaticVariable("RustLinkerArgs", "-B ${ccConfig.ClangBin} -fuse-ld=lld") + pctx.StaticVariable("RustLinkerArgs", "") pctx.StaticVariable("DeviceGlobalLinkFlags", strings.Join(deviceGlobalLinkFlags, " ")) diff --git a/rust/config/x86_darwin_host.go b/rust/config/x86_darwin_host.go index 9dd49ff49..4104400c1 100644 --- a/rust/config/x86_darwin_host.go +++ b/rust/config/x86_darwin_host.go @@ -21,8 +21,10 @@ import ( ) var ( - DarwinRustFlags = []string{} - DarwinRustLinkFlags = []string{} + DarwinRustFlags = []string{} + DarwinRustLinkFlags = []string{ + "-B${ccConfig.MacToolPath}", + } darwinX8664Rustflags = []string{} darwinX8664Linkflags = []string{} ) diff --git a/rust/config/x86_linux_host.go b/rust/config/x86_linux_host.go index 5376e5ba5..acc99e1c2 100644 --- a/rust/config/x86_linux_host.go +++ b/rust/config/x86_linux_host.go @@ -21,8 +21,11 @@ import ( ) var ( - LinuxRustFlags = []string{} - LinuxRustLinkFlags = []string{} + LinuxRustFlags = []string{} + LinuxRustLinkFlags = []string{ + "-B${ccConfig.ClangBin}", + "-fuse-ld=lld", + } linuxX86Rustflags = []string{} linuxX86Linkflags = []string{} linuxX8664Rustflags = []string{}