Commit 84785608 by Antonio Maiorano

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/+/41528Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com>
parent 48d08d64
......@@ -92,14 +92,14 @@ config("swiftshader_config") {
]
}
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 @@ config("swiftshader_config") {
if (is_linux) {
ldflags = [ "-Wl,--gc-sections" ]
if (target_cpu == "mipsel") {
if (current_cpu == "mipsel") {
ldflags += [
"-Wl,--hash-style=sysv",
]
......@@ -150,7 +150,7 @@ config("swiftshader_config") {
"-mips32r2",
]
}
} else if (target_cpu == "mips64el") {
} else if (current_cpu == "mips64el") {
ldflags += [
"-Wl,--hash-style=sysv",
"-mips64r2",
......@@ -160,7 +160,7 @@ config("swiftshader_config") {
}
# 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" ]
}
}
......
......@@ -21,7 +21,7 @@ config("swiftshader_common_private_config") {
"/wd4201", # nameless struct/union
"/wd5030", # attribute is not recognized
]
} else if (target_cpu == "x86" || target_cpu == "x64") {
} else if (current_cpu == "x86" || current_cpu == "x64") {
cflags = [ "-msse2" ]
}
}
......
......@@ -29,7 +29,7 @@ config("swiftshader_main_private_config") {
"-Wno-sign-compare",
]
}
} else if (target_cpu == "x86" || target_cpu == "x64") {
} else if (current_cpu == "x86" || current_cpu == "x64") {
cflags = [ "-msse2" ]
defines =
[ "NO_SANITIZE_FUNCTION=__attribute__((no_sanitize(\"function\")))" ]
......
......@@ -18,7 +18,7 @@ declare_args() {
# Subzero produces smaller binaries, but doesn't support ARM64, MIPS64, and
# PPC64.
use_swiftshader_with_subzero =
target_cpu != "arm64" && target_cpu != "mips64el" && target_cpu != "ppc64"
current_cpu != "arm64" && current_cpu != "mips64el" && current_cpu != "ppc64"
supports_llvm = is_linux || is_fuchsia || is_win || is_android || is_mac
}
......@@ -38,7 +38,7 @@ config("swiftshader_reactor_private_config") {
"__STDC_LIMIT_MACROS",
]
if (target_cpu == "x86" || target_cpu == "x64") {
if (current_cpu == "x86" || current_cpu == "x64") {
cflags += [ "-msse2" ]
}
}
......@@ -71,22 +71,22 @@ if (use_swiftshader_with_subzero) {
defines += [ "SUBZERO_USE_MICROSOFT_ABI" ]
}
if (target_cpu == "x64") {
if (current_cpu == "x64") {
defines += [
"SZTARGET=X8664",
"SUBZERO_TARGET=X8664",
]
} else if (target_cpu == "x86") {
} else if (current_cpu == "x86") {
defines += [
"SZTARGET=X8632",
"SUBZERO_TARGET=X8632",
]
} else if (target_cpu == "mipsel") {
} else if (current_cpu == "mipsel") {
defines += [
"SZTARGET=MIPS32",
"SUBZERO_TARGET=MIPS32",
]
} else if (target_cpu == "arm") {
} else if (current_cpu == "arm") {
defines += [
"SZTARGET=ARM32",
"SUBZERO_TARGET=ARM32",
......@@ -272,23 +272,23 @@ if (use_swiftshader_with_subzero) {
"$subzero_llvm_dir/lib/Support/regstrlcpy.c",
]
if (target_cpu == "x64") {
if (current_cpu == "x64") {
sources += [
"$subzero_dir/src/IceInstX8664.cpp",
"$subzero_dir/src/IceTargetLoweringX8664.cpp",
]
} else if (target_cpu == "x86") {
} else if (current_cpu == "x86") {
sources += [
"$subzero_dir/src/IceInstX8632.cpp",
"$subzero_dir/src/IceTargetLoweringX8632.cpp",
]
} else if (target_cpu == "mipsel") {
} else if (current_cpu == "mipsel") {
sources += [
"$subzero_dir/src/IceAssemblerMIPS32.cpp",
"$subzero_dir/src/IceInstMIPS32.cpp",
"$subzero_dir/src/IceTargetLoweringMIPS32.cpp",
]
} else if (target_cpu == "arm") {
} else if (current_cpu == "arm") {
sources += [
"$subzero_dir/src/IceAssemblerARM32.cpp",
"$subzero_dir/src/IceInstARM32.cpp",
......
......@@ -22,7 +22,7 @@ config("swiftshader_renderer_private_config") {
"/wd4324", # structure was padded due to alignment specifier
"/wd5030", # attribute is not recognized
]
} else if (target_cpu == "x86" || target_cpu == "x64") {
} else if (current_cpu == "x86" || current_cpu == "x64") {
cflags = [
"-msse2",
"-Wno-sign-compare",
......
......@@ -69,7 +69,7 @@ config("swiftshader_llvm_private_config") {
"-Wno-unused-result",
"-Wno-unused-variable",
]
if (target_cpu == "x86" || target_cpu == "x64") {
if (current_cpu == "x86" || current_cpu == "x64") {
cflags += [ "-msse2" ]
}
}
......@@ -325,25 +325,25 @@ swiftshader_source_set("swiftshader_llvm") {
":swiftshader_llvm_transforms",
]
if (target_cpu == "x86" || target_cpu == "x64") {
if (current_cpu == "x86" || current_cpu == "x64") {
deps += [":swiftshader_llvm_x86"]
} else if (target_cpu == "arm") {
} else if (current_cpu == "arm") {
deps += [":swiftshader_llvm_arm"]
} else if (target_cpu == "arm64") {
} else if (current_cpu == "arm64") {
deps += [":swiftshader_llvm_aarch64"]
} else if (target_cpu == "mipsel" || target_cpu == "mips64el") {
} else if (current_cpu == "mipsel" || current_cpu == "mips64el") {
deps += [":swiftshader_llvm_mips"]
} else if (target_cpu == "ppc64") {
} else if (current_cpu == "ppc64") {
deps += [":swiftshader_llvm_ppc"]
} else {
assert(false, "Unsupported target_cpu")
assert(false, "Unsupported current_cpu")
}
if (target_cpu != current_cpu &&
if (current_cpu != current_cpu &&
(current_cpu == "x86" || current_cpu == "x64") ||
# Windows ARM64 does cross compilation on Windows x64 host, and requires native
# x86 target.
(is_win && target_cpu == "arm64")) {
(is_win && current_cpu == "arm64")) {
deps += [ ":swiftshader_llvm_x86" ]
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment