[llvm] [llvm-readtapi] Fix bad symlink with readtapi tool (PR #68835)

Nivetha Kuruparan via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 11 13:23:17 PDT 2023


https://github.com/nivetha-kuruparan created https://github.com/llvm/llvm-project/pull/68835

The Clang-AIX-Wyvern-Dev buildbot is currently failing at the set directory permission due to a bad symlink caused by this [commit](https://github.ibm.com/compiler/llvm-project/commit/a54f31fabd55ab111484b1e094e3d2c6b29c4715). This change is creating the additional symlink `readtapi -> llvm-readtapi` which causes it to appear in `/buildbot_worker/official-worker/clang-aix-dev/installdir`. 

After some investigation, it looks like `readtapi` is the only tool that is getting symlinked that is not guarded by the `LLVM_INSTALL_BINUTILS_SYMLINKS` macro. For example:

1. `llvm/tools/llvm-objcopy/CMakeLists.txt`

```
if(LLVM_INSTALL_BINUTILS_SYMLINKS)
  add_llvm_tool_symlink(objcopy llvm-objcopy)
endif()
```

2. `llvm/tools/llvm-dwp/CMakeLists.txt`
```
if(LLVM_INSTALL_BINUTILS_SYMLINKS)
  add_llvm_tool_symlink(dwp llvm-dwp)
endif()
```

>From d9064835c249dd30dd52be7f92eb227baea685aa Mon Sep 17 00:00:00 2001
From: Nivetha Kuruparan <nivetha.kuruparan at gmail.com>
Date: Wed, 11 Oct 2023 16:40:08 -0400
Subject: [PATCH] Add guard to readtapi

---
 llvm/tools/llvm-readtapi/CMakeLists.txt       |  4 +++-
 .../llvm/tools/llvm-readtapi/BUILD.gn         | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/llvm/tools/llvm-readtapi/CMakeLists.txt b/llvm/tools/llvm-readtapi/CMakeLists.txt
index bc859ee57c6a67a..277011cf13c8e41 100644
--- a/llvm/tools/llvm-readtapi/CMakeLists.txt
+++ b/llvm/tools/llvm-readtapi/CMakeLists.txt
@@ -9,4 +9,6 @@ add_llvm_tool(llvm-readtapi
   DiffEngine.cpp
   )
 
-add_llvm_tool_symlink(readtapi llvm-readtapi)
+if(LLVM_INSTALL_BINUTILS_SYMLINKS)
+  add_llvm_tool_symlink(readtapi llvm-readtapi)
+endif()
diff --git a/llvm/utils/gn/secondary/llvm/tools/llvm-readtapi/BUILD.gn b/llvm/utils/gn/secondary/llvm/tools/llvm-readtapi/BUILD.gn
index c9d8afb2f1c5e82..bcd883b0d9d5858 100644
--- a/llvm/utils/gn/secondary/llvm/tools/llvm-readtapi/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/tools/llvm-readtapi/BUILD.gn
@@ -1,3 +1,22 @@
+import("//llvm/tools/binutils_symlinks.gni")
+import("//llvm/utils/gn/build/symlink_or_copy.gni")
+
+if (llvm_install_binutils_symlinks) {
+  symlink_or_copy("readtapi") {
+    deps = [ ":llvm-readtapi" ]
+    source = "llvm-readtapi"
+    output = "$root_out_dir/bin/readtapi"
+  }
+}
+
+# //:llvm-readtapi depends on this symlink target, see comment in //BUILD.gn.
+group("symlinks") {
+  deps = [ ":llvm-readtapi" ]
+  if (llvm_install_binutils_symlinks) {
+    deps += [ ":readtapi" ]
+  }
+}
+
 executable("llvm-readtapi") {
   deps = [
     "//llvm/lib/Object",



More information about the llvm-commits mailing list