gn build: Use target OS to control whether to use/depend on llvm-ar.
authorPeter Collingbourne <peter@pcc.me.uk>
Wed, 6 Apr 2022 19:46:05 +0000 (12:46 -0700)
committerPeter Collingbourne <peter@pcc.me.uk>
Wed, 6 Apr 2022 20:45:40 +0000 (13:45 -0700)
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

index f48f25c..864ae45 100644 (file)
@@ -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)" ]
     }