build: fix arm64 host cross-compilation in GN · nodejs/node@7ff3551 · GitHub
Skip to content

Commit 7ff3551

Browse files
zcbenztargos
authored andcommitted
build: fix arm64 host cross-compilation in GN
Should use `current_cpu` instead of `target_cpu` in GN build files, otherwise the host build may use wrong configs when doing cross compilation. PR-URL: #51903 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent fff7f48 commit 7ff3551

4 files changed

Lines changed: 27 additions & 25 deletions

File tree

deps/base64/unofficial.gni

Lines changed: 10 additions & 10 deletions

deps/openssl/unofficial.gni

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,29 +95,29 @@ template("openssl_gn_build") {
9595

9696
config_path_name = ""
9797
if (is_win) {
98-
if (target_cpu == "x86") {
98+
if (current_cpu == "x86") {
9999
config_path_name = "VC-WIN32"
100-
} else if (target_cpu == "x64") {
100+
} else if (current_cpu == "x64") {
101101
config_path_name = "VC-WIN64A"
102-
} else if (target_cpu == "arm64") {
102+
} else if (current_cpu == "arm64") {
103103
config_path_name = "VC-WIN64-ARM"
104104
}
105105
} else if (is_linux) {
106-
if (target_cpu == "x86") {
106+
if (current_cpu == "x86") {
107107
config_path_name = "linux-elf"
108-
} else if (target_cpu == "x64") {
108+
} else if (current_cpu == "x64") {
109109
config_path_name = "linux-x86_64"
110-
} else if (target_cpu == "arm") {
110+
} else if (current_cpu == "arm") {
111111
config_path_name = "linux-armv4"
112-
} else if (target_cpu == "arm64") {
112+
} else if (current_cpu == "arm64") {
113113
config_path_name = "linux-aarch64"
114114
}
115115
} else if (is_apple) {
116-
if (target_cpu == "x86") {
116+
if (current_cpu == "x86") {
117117
config_path_name = "darwin-i386-cc"
118-
} else if (target_cpu == "x64") {
118+
} else if (current_cpu == "x64") {
119119
config_path_name = "darwin64-x86_64-cc"
120-
} else if (target_cpu == "arm64") {
120+
} else if (current_cpu == "arm64") {
121121
config_path_name = "darwin64-arm64-cc"
122122
}
123123
}
@@ -132,7 +132,7 @@ template("openssl_gn_build") {
132132
# TODO(zcbenz): Check gas_version and nasm_version.
133133
asm_name = "asm_avx2"
134134
}
135-
if (is_win && target_cpu == "arm64") {
135+
if (is_win && current_cpu == "arm64") {
136136
asm_name = "no-asm"
137137
}
138138
config_path = "config/archs/" + config_path_name + "/" + asm_name

node.gni

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ declare_args() {
5454
node_use_node_code_cache = host_os == target_os && host_cpu == target_cpu
5555

5656
# Use snapshot to speed up startup.
57-
# TODO(zcbenz): node_mksnapshot is not ready for cross-os compilation.
58-
node_use_node_snapshot = host_os == target_os
57+
# TODO(zcbenz): There are few broken things for now:
58+
# 1. cross-os compilation is not supported.
59+
# 2. node_mksnapshot crashes when cross-compiling for x64 from arm64.
60+
node_use_node_snapshot = (host_os == target_os) && !(host_cpu == "arm64" && target_cpu == "x64")
5961
}
6062

6163
assert(!node_enable_inspector || node_use_openssl,

unofficial.gni

Lines changed: 2 additions & 2 deletions

0 commit comments

Comments
 (0)