[linux] Use lld when cross-compiling for Linux on macOS
This is needed since ld64 which is the default linker doesn't support
linking ELF binaries.
Change-Id: If8e06cb42c5ea61c24613e0f3f51267ab89d6fd0
diff --git a/config/linux/BUILD.gn b/config/linux/BUILD.gn
index f350682..85906d7 100644
--- a/config/linux/BUILD.gn
+++ b/config/linux/BUILD.gn
@@ -22,6 +22,15 @@
# in the host build directory.
"-Wl,-rpath=\$ORIGIN/",
]
+ if (host_os == "mac") {
+ # TODO(TC-325): When building binaries for Linux on macOS, we need to use
+ # lld as a linker, hence this flag. This is not needed on Linux since our
+ # Clang is configured to use lld as a default linker, but we cannot use the
+ # same option on macOS since default linker is currently a per-toolchain,
+ # not a per-target option and on macOS, Clang should default to ld64. We
+ # should change Clang to make the default linker a per-target option.
+ ldflags += [ "-fuse-ld=lld" ]
+ }
configs = [
":sysroot",
":target",