Skip to content

Commit 8c8c1f4

Browse files
authored
Fix darwin arm to amd x-compilation (#573)
This logic is a bit wonky (as you can tell from the misnamed vars). I think the new setup makes more sense. Essentially darwin to darwin cross-compilation is not the same as others because the sysroot is universal
1 parent 305c5c5 commit 8c8c1f4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

toolchain/cc_toolchain_config.bzl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ def cc_toolchain_config(
161161
"-D__TIME__=\"redacted\"",
162162
]
163163

164-
is_xcompile = not (exec_os == target_os and exec_arch == target_arch)
165-
166164
# Default compiler flags:
167165
compile_flags = [
168166
"--target=" + target_system_name,
@@ -198,7 +196,7 @@ def cc_toolchain_config(
198196

199197
if exec_os == "darwin":
200198
# These will get expanded by osx_cc_wrapper's `sanitize_option`
201-
link_flags.append("--ld-path=ld.lld" if is_xcompile else "--ld-path=ld64.lld")
199+
link_flags.append("--ld-path=ld64.lld" if target_os == "darwin" else "--ld-path=ld.lld")
202200

203201
stdlib = compiler_configuration["stdlib"]
204202
if stdlib != "none":
@@ -212,7 +210,7 @@ def cc_toolchain_config(
212210
libunwind_link_flags = []
213211
compiler_rt_link_flags = []
214212

215-
is_darwin_exec_and_target = exec_os == "darwin" and not is_xcompile
213+
is_darwin_exec_and_target = exec_os == "darwin" and target_os == "darwin"
216214

217215
# Linker flags:
218216
if is_darwin_exec_and_target:
@@ -245,14 +243,16 @@ def cc_toolchain_config(
245243
cxx_standard = compiler_configuration["cxx_standard"]
246244
conly_flags = compiler_configuration["conly_flags"]
247245
sysroot_path = compiler_configuration["sysroot_path"]
248-
if stdlib == "builtin-libc++" and is_xcompile:
246+
if stdlib == "builtin-libc++" and exec_os != target_os:
249247
stdlib = "stdc++"
250248
if stdlib == "builtin-libc++":
251249
cxx_flags = [
252250
"-std=" + cxx_standard,
253251
"-stdlib=libc++",
254252
]
255-
if is_darwin_exec_and_target:
253+
254+
# exec_os == target_os at this point.
255+
if exec_os == "darwin":
256256
# Several system libraries on macOS dynamically link libc++ and
257257
# libc++abi, so static linking them becomes a problem. We need to
258258
# ensure that they are dynamic linked from the system sysroot and

0 commit comments

Comments
 (0)