gn build: Use target OS to control whether to use/depend on llvm-ar.

When cross-compiling from Mac to non-Mac, we need to use the just-built
llvm-ar instead of libtool. We're currently doing the right thing
when determining which archiver command to use, but the path to ar
and the toolchain dependencies were being set based on the host OS
(current_os evaluated in host OS toolchain), instead of the target
OS. Fix the problem by looking up current_os inside toolchain_args.

Differential Revision: https://reviews.llvm.org/D123244
This commit is contained in:
Peter Collingbourne 2022-04-06 12:46:05 -07:00
parent 6795f37c14
commit 096477e25e
1 changed files with 2 additions and 1 deletions

View File

@ -198,7 +198,8 @@ template("stage2_unix_toolchain") {
"//:clang($host_toolchain)", "//:clang($host_toolchain)",
"//:lld($host_toolchain)", "//:lld($host_toolchain)",
] ]
if (current_os != "ios" && current_os != "mac") { if (toolchain_args.current_os != "ios" &&
toolchain_args.current_os != "mac") {
ar = "bin/llvm-ar" ar = "bin/llvm-ar"
deps += [ "//:llvm-ar($host_toolchain)" ] deps += [ "//:llvm-ar($host_toolchain)" ]
} }