Skip to content

Commit f1c129a

Browse files
authored
Tweak builtin-libc++ handling to better support linux cross-arch compilation (#588)
#573 regressed the case of linux to linux cross-arch compilation. Revert the changes to the linux logic while keeping the fixed darwin logic.
1 parent 6368fde commit f1c129a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

toolchain/cc_toolchain_config.bzl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,16 +243,19 @@ def cc_toolchain_config(
243243
cxx_standard = compiler_configuration["cxx_standard"]
244244
conly_flags = compiler_configuration["conly_flags"]
245245
sysroot_path = compiler_configuration["sysroot_path"]
246-
if stdlib == "builtin-libc++" and exec_os != target_os:
246+
247+
is_xcompile = not (exec_os == target_os and exec_arch == target_arch)
248+
249+
# Darwin has a universal sysroot so the builtin can compile cross-arch.
250+
if stdlib == "builtin-libc++" and is_xcompile and not is_darwin_exec_and_target:
247251
stdlib = "stdc++"
248252
if stdlib == "builtin-libc++":
249253
cxx_flags = [
250254
"-std=" + cxx_standard,
251255
"-stdlib=libc++",
252256
]
253257

254-
# exec_os == target_os at this point.
255-
if exec_os == "darwin":
258+
if is_darwin_exec_and_target:
256259
# Several system libraries on macOS dynamically link libc++ and
257260
# libc++abi, so static linking them becomes a problem. We need to
258261
# ensure that they are dynamic linked from the system sysroot and

0 commit comments

Comments
 (0)