Skip to content

feat: Support cross compiles from linux to macos #457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions toolchain/cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,14 @@ def cc_toolchain_config(
archive_flags = []

# Linker flags:
if exec_os == "darwin" and not is_xcompile:
# lld is experimental for Mach-O, so we use the native ld64 linker.
# TODO: How do we cross-compile from Linux to Darwin?
use_lld = False
ld = "ld.lld"
if target_os == "darwin":
use_lld = True

ld = "ld64.lld"
ld_path = toolchain_path_prefix + "/bin/" + ld
link_flags.extend([
"--ld-path=" + ld_path,
"-headerpad_max_install_names",
"-fobjc-link-runtime",
])
Expand All @@ -195,7 +198,9 @@ def cc_toolchain_config(
# not an option because it is not a cross-linker, so lld is the
# only option.
use_lld = True
ld_path = toolchain_path_prefix + "/bin/" + ld
link_flags.extend([
"--ld-path=" + ld_path,
"-fuse-ld=lld",
"-Wl,--build-id=md5",
"-Wl,--hash-style=gnu",
Expand Down Expand Up @@ -323,7 +328,7 @@ def cc_toolchain_config(
"dwp": tools_path_prefix + "llvm-dwp",
"gcc": wrapper_bin_prefix + "cc_wrapper.sh",
"gcov": tools_path_prefix + "llvm-profdata",
"ld": tools_path_prefix + "ld.lld" if use_lld else "/usr/bin/ld",
"ld": tools_path_prefix + ld if use_lld else "/usr/bin/ld",
"llvm-cov": tools_path_prefix + "llvm-cov",
"llvm-profdata": tools_path_prefix + "llvm-profdata",
"nm": tools_path_prefix + "llvm-nm",
Expand Down
1 change: 1 addition & 0 deletions toolchain/internal/common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ _toolchain_tools = {
for name in [
"clang-cpp",
"ld.lld",
"ld64.lld",
"llvm-ar",
"llvm-dwp",
"llvm-profdata",
Expand Down
Loading