Skip to content

Commit 969c0fc

Browse files
committed
Fix build scripts targeting the wrong architecture
PR bazelbuild#1081 started passing CFLAGS to build scripts, which cargo does too. But unfortunately Bazel's cpp toolchain adds an explicit target to the CFLAGS it provides, and that target uses the host platform instead of the target platform. When building a crate like blake3 or zstd on a Mac with iOS as the target, this ends up in the crate being built for macOS instead of iOS.
1 parent afb41c2 commit 969c0fc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cargo/cargo_build_script.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ load("//rust/private:utils.bzl", "dedent", "expand_dict_value_locations", "find_
1616
def strip_target(elems):
1717
"""Remove '-target xxx' from C(XX)FLAGS.
1818
19-
The cpp toolchain (at least on macOS) adds '-target xxx' to CFLAGS. If it is not stripped out before the CFLAGS are
20-
provided to build scripts, it can cause the build to take on the host architecture instead of the target architecture.
19+
The cpp toolchain adds '-target xxx' to CFLAGS. If it is not stripped out before the CFLAGS are
20+
provided to build scripts, it can cause the build to take on the host architecture instead of the
21+
target architecture.
2122
2223
Args:
2324
elems (list): A list of args

0 commit comments

Comments
 (0)