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 <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent fff7f48 commit 7ff3551

File tree

4 files changed

+27
-25
lines changed

4 files changed

+27
-25
lines changed

‎deps/base64/unofficial.gni‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ template("base64_gn_build"){
1919
} else{
2020
defines= []
2121
}
22-
if (target_cpu=="x86"||target_cpu=="x64"){
22+
if (current_cpu=="x86"||current_cpu=="x64"){
2323
defines+= [
2424
"HAVE_SSSE3=1",
2525
"HAVE_SSE41=1",
@@ -29,10 +29,10 @@ template("base64_gn_build"){
2929
"HAVE_AVX512=1",
3030
]
3131
}
32-
if (target_cpu=="arm"){
32+
if (current_cpu=="arm"){
3333
defines+= [ "HAVE_NEON32=1" ]
3434
}
35-
if (target_cpu=="arm64"){
35+
if (current_cpu=="arm64"){
3636
defines+= [ "HAVE_NEON64=1" ]
3737
}
3838
if (is_clang||!is_win){
@@ -69,7 +69,7 @@ template("base64_gn_build"){
6969
source_set("base64_ssse3"){
7070
configs+= [ ":base64_internal_config" ]
7171
sources= [ "base64/lib/arch/ssse3/codec.c" ]
72-
if (target_cpu=="x86"||target_cpu=="x64"){
72+
if (current_cpu=="x86"||current_cpu=="x64"){
7373
if (is_clang||!is_win){
7474
cflags_c= [ "-mssse3" ]
7575
}
@@ -79,7 +79,7 @@ template("base64_gn_build"){
7979
source_set("base64_sse41"){
8080
configs+= [ ":base64_internal_config" ]
8181
sources= [ "base64/lib/arch/sse41/codec.c" ]
82-
if (target_cpu=="x86"||target_cpu=="x64"){
82+
if (current_cpu=="x86"||current_cpu=="x64"){
8383
if (is_clang||!is_win){
8484
cflags_c= [ "-msse4.1" ]
8585
}
@@ -89,7 +89,7 @@ template("base64_gn_build"){
8989
source_set("base64_sse42"){
9090
configs+= [ ":base64_internal_config" ]
9191
sources= [ "base64/lib/arch/sse42/codec.c" ]
92-
if (target_cpu=="x86"||target_cpu=="x64"){
92+
if (current_cpu=="x86"||current_cpu=="x64"){
9393
if (is_clang||!is_win){
9494
cflags_c= [ "-msse4.2" ]
9595
}
@@ -99,7 +99,7 @@ template("base64_gn_build"){
9999
source_set("base64_avx"){
100100
configs+= [ ":base64_internal_config" ]
101101
sources= [ "base64/lib/arch/avx/codec.c" ]
102-
if (target_cpu=="x86"||target_cpu=="x64"){
102+
if (current_cpu=="x86"||current_cpu=="x64"){
103103
if (is_clang||!is_win){
104104
cflags_c= [ "-mavx" ]
105105
} elseif (is_win){
@@ -111,7 +111,7 @@ template("base64_gn_build"){
111111
source_set("base64_avx2"){
112112
configs+= [ ":base64_internal_config" ]
113113
sources= [ "base64/lib/arch/avx2/codec.c" ]
114-
if (target_cpu=="x86"||target_cpu=="x64"){
114+
if (current_cpu=="x86"||current_cpu=="x64"){
115115
if (is_clang||!is_win){
116116
cflags_c= [ "-mavx2" ]
117117
} elseif (is_win){
@@ -123,7 +123,7 @@ template("base64_gn_build"){
123123
source_set("base64_avx512"){
124124
configs+= [ ":base64_internal_config" ]
125125
sources= [ "base64/lib/arch/avx512/codec.c" ]
126-
if (target_cpu=="x86"||target_cpu=="x64"){
126+
if (current_cpu=="x86"||current_cpu=="x64"){
127127
if (is_clang||!is_win){
128128
cflags_c= [
129129
"-mavx512vl",
@@ -138,7 +138,7 @@ template("base64_gn_build"){
138138
source_set("base64_neon32"){
139139
configs+= [ ":base64_internal_config" ]
140140
sources= [ "base64/lib/arch/neon32/codec.c" ]
141-
if (target_cpu=="arm"){
141+
if (current_cpu=="arm"){
142142
if (is_clang||!is_win){
143143
cflags_c= [ "-mfpu=neon" ]
144144
}

‎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-
} elseif (target_cpu=="x64"){
100+
} elseif (current_cpu=="x64"){
101101
config_path_name="VC-WIN64A"
102-
} elseif (target_cpu=="arm64"){
102+
} elseif (current_cpu=="arm64"){
103103
config_path_name="VC-WIN64-ARM"
104104
}
105105
} elseif (is_linux){
106-
if (target_cpu=="x86"){
106+
if (current_cpu=="x86"){
107107
config_path_name="linux-elf"
108-
} elseif (target_cpu=="x64"){
108+
} elseif (current_cpu=="x64"){
109109
config_path_name="linux-x86_64"
110-
} elseif (target_cpu=="arm"){
110+
} elseif (current_cpu=="arm"){
111111
config_path_name="linux-armv4"
112-
} elseif (target_cpu=="arm64"){
112+
} elseif (current_cpu=="arm64"){
113113
config_path_name="linux-aarch64"
114114
}
115115
} elseif (is_apple){
116-
if (target_cpu=="x86"){
116+
if (current_cpu=="x86"){
117117
config_path_name="darwin-i386-cc"
118-
} elseif (target_cpu=="x64"){
118+
} elseif (current_cpu=="x64"){
119119
config_path_name="darwin64-x86_64-cc"
120-
} elseif (target_cpu=="arm64"){
120+
} elseif (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
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ template("node_gn_build"){
8282
"-Wno-unused-function",
8383
]
8484

85-
if (target_cpu=="x86"){
85+
if (current_cpu=="x86"){
8686
node_arch="ia32"
8787
} else{
88-
node_arch=target_cpu
88+
node_arch=current_cpu
8989
}
9090
if (target_os=="win"){
9191
node_platform="win32"

0 commit comments

Comments
(0)