Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4d8834f

Browse filesBrowse files
richardlauRafaelGSS
authored andcommitted
build: add rust target for macOS cross compiles
When we build the macOS pkg, we build Node.js twice (on arm64): - Once for arm64 (native) - Once for x64, using a combination of Rosetta 2 and compiler flags before combining both into a universal binary. For the x64 case, pass target flag to `rustc` so that the binary is built for the correct target architecture. Signed-off-by: Richard Lau <richard.lau@ibm.com> PR-URL: #63015 Reviewed-By: Stewart X Addison <sxa@redhat.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent dae2219 commit 4d8834f
Copy full SHA for 4d8834f

2 files changed

+13-4Lines changed: 13 additions & 4 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎configure.py‎

Copy file name to clipboardExpand all lines: configure.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,6 +1812,10 @@ def configure_node(o):
18121812
if flavor == 'win':
18131813
o['variables']['cargo_rust_target'] = \
18141814
'aarch64-pc-windows-msvc' if target_arch == 'arm64' else 'x86_64-pc-windows-msvc'
1815+
# Always set the Rust target for x64 macOS in case we will be building
1816+
# under Rosetta 2.
1817+
if flavor == 'mac' and target_arch == 'x64':
1818+
o['variables']['cargo_rust_target'] = 'x86_64-apple-darwin'
18151819

18161820
# Allow overriding the compiler - needed by embedders.
18171821
if options.use_clang:
Collapse file

‎deps/crates/crates.gyp‎

Copy file name to clipboardExpand all lines: deps/crates/crates.gyp
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@
1111
},
1212
'conditions': [
1313
['cargo_rust_target!=""', {
14+
'variables': {
15+
'cargo_build_flags': ['--target', '<(cargo_rust_target)'],
16+
}
17+
}],
18+
['OS=="win"', {
1419
'variables': {
1520
'node_crates_libpath': '<(SHARED_INTERMEDIATE_DIR)/$(Platform)/release/node_crates.lib',
1621
},
1722
}, {
1823
'variables': {
19-
'node_crates_libpath': '<(SHARED_INTERMEDIATE_DIR)/release/<(STATIC_LIB_PREFIX)node_crates<(STATIC_LIB_SUFFIX)',
24+
'node_crates_libpath': '<(SHARED_INTERMEDIATE_DIR)/<(cargo_rust_target)/release/<(STATIC_LIB_PREFIX)node_crates<(STATIC_LIB_SUFFIX)',
2025
},
2126
}],
2227
],
@@ -25,13 +30,13 @@
2530
'cargo_build_flags': [],
2631
},
2732
'conditions': [
28-
['cargo_rust_target!=""', {
33+
['OS=="win"', {
2934
'variables': {
3035
'node_crates_libpath': '<(SHARED_INTERMEDIATE_DIR)/$(Platform)/debug/node_crates.lib',
3136
},
3237
}, {
3338
'variables': {
34-
'node_crates_libpath': '<(SHARED_INTERMEDIATE_DIR)/debug/<(STATIC_LIB_PREFIX)node_crates<(STATIC_LIB_SUFFIX)',
39+
'node_crates_libpath': '<(SHARED_INTERMEDIATE_DIR)/<(cargo_rust_target)/debug/<(STATIC_LIB_PREFIX)node_crates<(STATIC_LIB_SUFFIX)',
3540
},
3641
}],
3742
],
@@ -62,7 +67,7 @@
6267
],
6368
},
6469
'conditions': [
65-
['cargo_rust_target!=""', {
70+
['OS=="win"', {
6671
'actions': [
6772
{
6873
'action_name': 'cargo_build',

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.