From 7a035de2d6c440f677cb0e03ad25011f56cd08b5 Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Fri, 17 Feb 2023 09:56:51 -0800 Subject: [PATCH] Revert "[gn build] Support linux/win compiler-rt cross compilation" This reverts commit d73eb92cc673acf532b396537d78fe041dc9a9c2. Breaks win/mac, e.g. http://45.33.8.238/win/75236/step_4.txt --- llvm/utils/gn/build/toolchain/BUILD.gn | 36 ++++++---------------- llvm/utils/gn/build/toolchain/compiler.gni | 7 ----- llvm/utils/gn/secondary/compiler-rt/BUILD.gn | 10 +++--- .../gn/secondary/compiler-rt/test/asan/BUILD.gn | 3 +- 4 files changed, 15 insertions(+), 41 deletions(-) diff --git a/llvm/utils/gn/build/toolchain/BUILD.gn b/llvm/utils/gn/build/toolchain/BUILD.gn index ecb2371..80e5bd9 100644 --- a/llvm/utils/gn/build/toolchain/BUILD.gn +++ b/llvm/utils/gn/build/toolchain/BUILD.gn @@ -9,8 +9,6 @@ declare_args() { assert(!use_goma || goma_dir != "", "set `goma_dir` to the output of `goma_ctl goma_dir` in your args.gn") -unix_copy_command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})" - template("unix_toolchain") { toolchain(target_name) { # https://groups.google.com/a/chromium.org/g/gn-dev/c/F_lv5T-tNDM @@ -146,8 +144,9 @@ template("unix_toolchain") { default_output_dir = "{{root_out_dir}}/bin" } + copy_command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})" tool("copy") { - command = unix_copy_command + command = copy_command description = "COPY {{source}} {{output}}" } @@ -379,23 +378,14 @@ template("win_toolchain") { } tool("copy") { - if (host_os == "win") { - # GN hands out slash-using paths, but cmd's copy needs backslashes. - # Use cmd's %foo:a=b% substitution feature to convert. - command = "cmd /c set source=\"{{source}}\" & set output=\"{{output}}\" & call copy /Y %source:/=\% %output:\=/% > nul" - } else { - command = unix_copy_command - } - + # GN hands out slash-using paths, but cmd's copy needs backslashes. + # Use cmd's %foo:a=b% substitution feature to convert. + command = "cmd /c set source=\"{{source}}\" & set output=\"{{output}}\" & call copy /Y %source:/=\% %output:\=/% > nul" description = "COPY {{source}} {{output}}" } tool("stamp") { - if (host_os == "win") { - command = "cmd /c type nul > {{output}}" - } else { - command = "touch {{output}}" - } + command = "cmd /c type nul > {{output}}" description = "STAMP {{output}}" } } @@ -408,14 +398,11 @@ win_toolchain("win") { } } -win_toolchain("stage2_win_x64") { +win_toolchain("stage2_win") { toolchain_args = { - current_os = "win" - current_cpu = "x64" + current_os = host_os + current_cpu = host_cpu - if (host_os != "win") { - sysroot = win_sysroot - } clang_base_path = root_build_dir use_goma = false } @@ -427,12 +414,9 @@ win_toolchain("stage2_win_x64") { win_toolchain("stage2_win_x86") { toolchain_args = { - current_os = "win" + current_os = host_os current_cpu = "x86" - if (host_os != "win") { - sysroot = win_sysroot - } clang_base_path = root_build_dir use_goma = false } diff --git a/llvm/utils/gn/build/toolchain/compiler.gni b/llvm/utils/gn/build/toolchain/compiler.gni index 7cd15e6..28efe99 100644 --- a/llvm/utils/gn/build/toolchain/compiler.gni +++ b/llvm/utils/gn/build/toolchain/compiler.gni @@ -13,9 +13,6 @@ declare_args() { # Set this to the path to Android NDK r21. If set, cross compilation targeting # Android will be enabled. android_ndk_path = "" - - # Set this to the path of the Win SDK. Only used for cross compilation. If set, cross compilation targeting Windows will be enabled. - win_sysroot = "" } declare_args() { @@ -26,7 +23,3 @@ declare_args() { # Set this to true to link with LLD instead of the default linker. use_lld = clang_base_path != "" } - -assert( - !(host_os == "win" && win_sysroot != ""), - "win_sysroot should only be used for cross compilation, use sysroot on Windows") diff --git a/llvm/utils/gn/secondary/compiler-rt/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/BUILD.gn index b310161..edadd26 100644 --- a/llvm/utils/gn/secondary/compiler-rt/BUILD.gn +++ b/llvm/utils/gn/secondary/compiler-rt/BUILD.gn @@ -5,13 +5,11 @@ import("//llvm/utils/gn/build/toolchain/compiler.gni") # In the GN build, compiler-rt is always built by just-built clang and lld. # FIXME: For macOS and iOS builds, depend on lib in all needed target arch # toolchains and then lipo them together for the final output. -supported_toolchains = [] -if (current_os == "win" || win_sysroot != "") { - supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_win_x64" ] +if (current_os == "win") { + supported_toolchains = [ "//llvm/utils/gn/build/toolchain:stage2_win" ] supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_win_x86" ] -} -if (current_os != "win") { - supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_unix" ] +} else { + supported_toolchains = [ "//llvm/utils/gn/build/toolchain:stage2_unix" ] } supported_toolchains += supported_android_toolchains if (llvm_build_AArch64) { diff --git a/llvm/utils/gn/secondary/compiler-rt/test/asan/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/test/asan/BUILD.gn index 92a74a0..27ab789 100644 --- a/llvm/utils/gn/secondary/compiler-rt/test/asan/BUILD.gn +++ b/llvm/utils/gn/secondary/compiler-rt/test/asan/BUILD.gn @@ -48,9 +48,8 @@ supported_toolchains = [] if (host_os == "linux") { supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_unix" ] } else if (host_os == "win") { - supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_win_64" ] + supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_win" ] } - group("asan") { deps = [] foreach(toolchain, supported_toolchains) { -- 2.7.4