Replace target_cpu with current_cpu in Build.gn files
A recent change was made that failed when building nacl, because despite
the target_cpu being set to x86, current_cpu is x64 for nacl, as it is
cross-compiled to x64 using a different toolchain. As such, we were
building and linking the x86 version of Subzero with the x64 version of
nacl, resulting in a linker error.
See the following doc for more info:
https://chromium.googlesource.com/dart/dartium/src/+/refs/heads/master/tools/gn/docs/cross_compiles.md#as-a-build_gn-author
Bug: b/150008309
Change-Id: I581538cb7bb090e5b30819052eb7e245bc90ab12
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/41528
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 7d2a6f5..8ff1631 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -92,14 +92,14 @@
]
}
- if (target_cpu == "x64") { # 64 bit version
+ if (current_cpu == "x64") { # 64 bit version
cflags += [
"-m64",
"-fPIC",
"-march=x86-64",
"-mtune=generic",
]
- } else if (target_cpu == "x86") { # 32 bit version
+ } else if (current_cpu == "x86") { # 32 bit version
cflags += [
"-m32",
"-msse2",
@@ -137,7 +137,7 @@
if (is_linux) {
ldflags = [ "-Wl,--gc-sections" ]
- if (target_cpu == "mipsel") {
+ if (current_cpu == "mipsel") {
ldflags += [
"-Wl,--hash-style=sysv",
]
@@ -150,7 +150,7 @@
"-mips32r2",
]
}
- } else if (target_cpu == "mips64el") {
+ } else if (current_cpu == "mips64el") {
ldflags += [
"-Wl,--hash-style=sysv",
"-mips64r2",
@@ -160,7 +160,7 @@
}
# A bug in the gold linker prevents using ICF on 32-bit (crbug.com/729532)
- if (use_gold && (target_cpu == "x86" || target_cpu == "mipsel")) {
+ if (use_gold && (current_cpu == "x86" || current_cpu == "mipsel")) {
ldflags += [ "-Wl,--icf=none" ]
}
}