File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -221,6 +221,19 @@ build:macos --copt='-femit-dwarf-unwind=no-compact-unwind'
221
221
# TODO(soon): File a bazel issue for the flag so we can drop this.
222
222
build:macos --experimental_objc_fastbuild_options=""
223
223
224
+ # Cross-Compilation
225
+ # Only cross-compiling on macOS from Apple Silicon to x86_64 is supported – using apple_support
226
+ # makes this much easier than on other platforms. We could define a configuration for cross-
227
+ # compiling from Intel Mac too, but it lacks a means to run Apple Silicon binaries. We would have to
228
+ # change V8 mksnapshot to build in the host configuration again (effectively compiling much of V8
229
+ # twice) and couldn't run tests, so it would provide little value.
230
+ #
231
+ # Define the target platform
232
+ build:macos-cross-x86_64 --cpu=darwin_x86_64 --host_cpu=darwin_arm64 --platforms //:macOS_x86
233
+ # Some cross-compiled tests are slower when run over Rosetta, increase the medium test size timeout.
234
+ # Test performance is still very much satisfactory considering that emulation is being used here.
235
+ build:macos-cross-x86_64 --test_timeout=1,30,60,240
236
+
224
237
# On Linux, always link libc++ statically to avoid compatibility issues with different OS versions.
225
238
# macOS links with dynamic libc++ by default, which has good backwards compatibility.
226
239
# Drop default link flags, which include libstdc++ for Linux
Original file line number Diff line number Diff line change @@ -46,6 +46,15 @@ platform(
46
46
],
47
47
)
48
48
49
+ # Used for cross-compilation
50
+ platform (
51
+ name = "macOS_x86" ,
52
+ constraint_values = [
53
+ "@platforms//os:macos" ,
54
+ "@platforms//cpu:x86_64" ,
55
+ ],
56
+ )
57
+
49
58
# bazel enables the --ffunction-sections, --gc-sections flags used to remove dead code by default
50
59
# on Linux opt builds. Enable the equivalent macOS flag -Wl,-dead_strip here to work around bazel
51
60
# idiosyncrasies.
Original file line number Diff line number Diff line change @@ -178,8 +178,11 @@ rules_rust_dependencies()
178
178
179
179
rust_register_toolchains (
180
180
edition = "2021" ,
181
- # Rust registers wasm targets by default which we don't need, workerd is only built for its native platform.
182
- extra_target_triples = [],
181
+ # Add support macOS cross-compilation, the overhead for this is limited with only a few more
182
+ # targets being generated for the extra triple as part of the toolchain. Setting this explicitly
183
+ # also avoids registering support for the wasm32-unknown-unknown and wasm32-wasi targets, which
184
+ # are otherwise added by default.
185
+ extra_target_triples = ["x86_64-apple-darwin" ],
183
186
versions = ["1.81.0" ], # LLVM 18
184
187
)
185
188
You can’t perform that action at this time.
0 commit comments