Skip to content

Commit 18952bd

Browse files
authored
[gn build] Fix up win/x86 flags and add stage2_unix_x86 (#111595)
1 parent 774893d commit 18952bd

File tree

6 files changed

+23
-6
lines changed

6 files changed

+23
-6
lines changed

llvm/utils/gn/build/BUILD.gn

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ config("compiler_defaults") {
6161
}
6262

6363
asmflags = target_flags
64-
cflags = target_flags
64+
cflags = target_flags + target_cflags
6565
cflags_cc = []
6666
ldflags = target_flags + target_ldflags
6767

@@ -343,7 +343,11 @@ config("compiler_defaults") {
343343
ldflags += [ "/winsysroot:" + rebase_path(sysroot, root_build_dir) ]
344344

345345
# FIXME: Remove once PR54409 is fixed.
346-
ldflags += [ "/machine:x64" ]
346+
if (current_cpu == "x64") {
347+
ldflags += [ "/machine:x64" ]
348+
} else if (current_cpu == "x86") {
349+
ldflags += [ "/machine:x86" ]
350+
}
347351
}
348352
} else if (current_os != "ios" && current_os != "mac" &&
349353
current_os != "android") {

llvm/utils/gn/build/toolchain/BUILD.gn

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,13 @@ stage2_unix_toolchain("stage2_unix") {
209209
}
210210
}
211211

212+
stage2_unix_toolchain("stage2_unix_x86") {
213+
toolchain_args = {
214+
current_os = host_os
215+
current_cpu = "x86"
216+
}
217+
}
218+
212219
if (android_ndk_path != "") {
213220
# Android compiler-rt libraries don't really work with per-target runtime
214221
# directories yet so force it off.

llvm/utils/gn/build/toolchain/target_flags.gni

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import("//llvm/utils/gn/build/toolchain/compiler.gni")
88
# COMPILER_RT_TEST_COMPILER_CFLAGS).
99

1010
target_flags = []
11+
target_cflags = []
1112
target_ldflags = []
1213

1314
if (current_os == "android") {
@@ -55,6 +56,10 @@ if (current_os == "android") {
5556
target_flags += [ "--target=$llvm_current_triple" ]
5657
}
5758

58-
if (current_cpu == "x86" && current_os != "win") {
59-
target_flags += [ "-m32" ]
59+
if (current_cpu == "x86") {
60+
if (current_os == "win") {
61+
target_cflags += [ "-m32" ]
62+
} else {
63+
target_flags += [ "-m32" ]
64+
}
6065
}

llvm/utils/gn/secondary/compiler-rt/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ if (current_os == "win" || win_sysroot != "") {
1212
}
1313
if (current_os != "win") {
1414
supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_unix" ]
15+
supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_unix_x86" ]
1516
}
1617
supported_toolchains += supported_android_toolchains
1718
if (llvm_build_AArch64) {

llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ group("lib") {
44
"//compiler-rt/lib/builtins",
55
"//compiler-rt/lib/cfi:ignorelist($host_toolchain)",
66
]
7-
if (current_os == "linux") {
7+
if (current_os == "linux" && current_cpu == "x64") {
88
deps += [ "//compiler-rt/lib/msan" ]
99
}
1010
if (current_os == "linux" || current_os == "android") {

llvm/utils/gn/secondary/compiler-rt/test/test.gni

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ declare_args() {
1010

1111
target_flags_string = ""
1212

13-
foreach(flag, target_flags + target_ldflags) {
13+
foreach(flag, target_flags + target_cflags + target_ldflags) {
1414
if (target_flags_string != "") {
1515
target_flags_string += " "
1616
}

0 commit comments

Comments
 (0)