From 096477e25e440ca923703750c628c862cd2a876c Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 6 Apr 2022 12:46:05 -0700 Subject: [PATCH] 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 --- llvm/utils/gn/build/toolchain/BUILD.gn | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/utils/gn/build/toolchain/BUILD.gn b/llvm/utils/gn/build/toolchain/BUILD.gn index f48f25c..864ae45 100644 --- a/llvm/utils/gn/build/toolchain/BUILD.gn +++ b/llvm/utils/gn/build/toolchain/BUILD.gn @@ -198,7 +198,8 @@ template("stage2_unix_toolchain") { "//:clang($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" deps += [ "//:llvm-ar($host_toolchain)" ] } -- 2.7.4