[PATCH] D97989: [gn build] allow setting clang_base_path to a source-absolute path

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 4 16:11:25 PST 2021


thakis created this revision.
thakis added a reviewer: aeubanks.
thakis requested review of this revision.
Herald added a project: LLVM.

With this, you can set `clang_base_path = "//out/gn1"` in `out/gn2/args.gn` and the build in out/gn2 will use clang and lld from out/gn1.

Setting `clang_base_path` to an absolute path (with e.g. `clang_base_path = getenv("HOME") + "/src/..."`) should behave as before.


https://reviews.llvm.org/D97989

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


Index: llvm/utils/gn/build/toolchain/BUILD.gn
===================================================================
--- llvm/utils/gn/build/toolchain/BUILD.gn
+++ llvm/utils/gn/build/toolchain/BUILD.gn
@@ -25,8 +25,8 @@
     cxx = "c++"
 
     if (clang_base_path != "") {
-      cc = "$clang_base_path/bin/clang"
-      cxx = "$clang_base_path/bin/clang++"
+      cc = rebase_path(clang_base_path, root_build_dir) + "/bin/clang"
+      cxx = rebase_path(clang_base_path, root_build_dir) + "/bin/clang++"
     }
 
     ld = cxx  # Don't use goma wrapper for linking.
@@ -185,7 +185,7 @@
     toolchain_args = {
       forward_variables_from(invoker.toolchain_args, "*")
 
-      clang_base_path = "."
+      clang_base_path = root_build_dir
       use_goma = false
     }
 
@@ -244,9 +244,9 @@
   link = "link"
 
   if (clang_base_path != "") {
-    cl = "$clang_base_path/bin/clang-cl"
+    cl = rebase_path(clang_base_path, root_build_dir) + "/bin/clang-cl"
     if (use_lld) {
-      link = "$clang_base_path/bin/lld-link"
+      link = rebase_path(clang_base_path, root_build_dir) + "/bin/lld-link"
     }
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97989.328331.patch
Type: text/x-patch
Size: 1115 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210305/7132fa87/attachment.bin>


More information about the llvm-commits mailing list