Skip to content

[llvm-driver] Add driver alias for c++filt #92803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2024

Conversation

rupprecht
Copy link
Collaborator

@rupprecht rupprecht commented May 20, 2024

Similar to 9d955a6, this allows the driver to respond to c++filt.

…tool (llvm-profdata)

Similar to 9d955a6, this allows the driver to respond to `c++filt` and `gcov-tool`.
@rupprecht rupprecht requested a review from MaskRay May 20, 2024 18:37
@rupprecht rupprecht requested a review from keith as a code owner May 20, 2024 18:37
@llvmbot llvmbot added PGO Profile Guided Optimizations bazel "Peripheral" support tier build system: utils/bazel llvm:binary-utilities labels May 20, 2024
@llvmbot
Copy link
Member

llvmbot commented May 20, 2024

@llvm/pr-subscribers-llvm-binary-utilities

@llvm/pr-subscribers-pgo

Author: Jordan Rupprecht (rupprecht)

Changes

Similar to 9d955a6, this allows the driver to respond to c++filt and gcov-tool.


Full diff: https://github.com/llvm/llvm-project/pull/92803.diff

4 Files Affected:

  • (modified) llvm/test/tools/llvm-driver/symlink-call.test (+2)
  • (modified) llvm/tools/llvm-cxxfilt/CMakeLists.txt (+4)
  • (modified) llvm/tools/llvm-profdata/CMakeLists.txt (+4)
  • (modified) utils/bazel/llvm-project-overlay/llvm/driver.bzl (+2)
diff --git a/llvm/test/tools/llvm-driver/symlink-call.test b/llvm/test/tools/llvm-driver/symlink-call.test
index eeedf9edc73f2..ca6098216b13a 100644
--- a/llvm/test/tools/llvm-driver/symlink-call.test
+++ b/llvm/test/tools/llvm-driver/symlink-call.test
@@ -14,6 +14,8 @@
 # RUN: %t/cxxfilt-15 --help | FileCheck %s
 # RUN: ln -s %llvm %t/cxxfilt-15.exe
 # RUN: %t/cxxfilt-15.exe --help | FileCheck %s
+# RUN: ln -s %llvm %t/c++filt
+# RUN: %t/c++filt --help | FileCheck %s
 
 # RUN: ln -s %llvm %t/llvm-15
 # RUN: %t/llvm-15 cxxfilt --help | FileCheck %s
diff --git a/llvm/tools/llvm-cxxfilt/CMakeLists.txt b/llvm/tools/llvm-cxxfilt/CMakeLists.txt
index cbc4c2db61543..a644baffdd90e 100644
--- a/llvm/tools/llvm-cxxfilt/CMakeLists.txt
+++ b/llvm/tools/llvm-cxxfilt/CMakeLists.txt
@@ -17,6 +17,10 @@ add_llvm_tool(llvm-cxxfilt
   GENERATE_DRIVER
   )
 
+if(LLVM_TOOL_LLVM_DRIVER_BUILD)
+  set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_HIDDEN_TOOL_ALIASES_llvm-cxxfilt c++filt)
+endif()
+
 if(LLVM_INSTALL_BINUTILS_SYMLINKS)
   add_llvm_tool_symlink(c++filt llvm-cxxfilt)
 endif()
diff --git a/llvm/tools/llvm-profdata/CMakeLists.txt b/llvm/tools/llvm-profdata/CMakeLists.txt
index 25cf143337ad4..40731b8fe2532 100644
--- a/llvm/tools/llvm-profdata/CMakeLists.txt
+++ b/llvm/tools/llvm-profdata/CMakeLists.txt
@@ -12,3 +12,7 @@ add_llvm_tool(llvm-profdata
   intrinsics_gen
   GENERATE_DRIVER
   )
+
+if(LLVM_TOOL_LLVM_DRIVER_BUILD)
+  set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_HIDDEN_TOOL_ALIASES_llvm-profdata gcov-tool)
+endif()
diff --git a/utils/bazel/llvm-project-overlay/llvm/driver.bzl b/utils/bazel/llvm-project-overlay/llvm/driver.bzl
index 10796d9198343..0d568ebf5a91e 100644
--- a/utils/bazel/llvm-project-overlay/llvm/driver.bzl
+++ b/utils/bazel/llvm-project-overlay/llvm/driver.bzl
@@ -39,8 +39,10 @@ _EXTRA_ALIASES = {
     "clang": ["clang++", "clang-cl", "clang-cpp"],
     "lld": ["ld", "lld-link", "ld.lld", "ld64.lld", "wasm-ld"],
     "llvm-ar": ["ranlib", "lib", "dlltool"],
+    "llvm-cxxfilt": ["c++filt"],
     "llvm-objcopy": ["bitcode-strip", "install-name-tool", "strip"],
     "llvm-objdump": ["otool"],
+    "llvm-profdata": ["gcov-tool"],
     "llvm-rc": ["windres"],
     "llvm-readobj": ["readelf"],
     "llvm-symbolizer": ["addr2line"],

@rupprecht rupprecht changed the title [llvm-driver] Add driver aliases for c++filt and gcov-tool [llvm-driver] Add driver alias for c++filt May 21, 2024
@MaskRay
Copy link
Member

MaskRay commented May 21, 2024

FTR: gcov-tool might be used for GCC PGO/AutoFDO. The tool is different from llvm-profdata even if they both support xxx merge xxx yyy -o zzz

gcc -fprofile-generate -c a.c b.c && gcc -fprofile-generate a.o b.o -o a; ./a; gcov-tool merge . . -o dir; gcov-tool creates a directory.

clang -fprofile-generate -c a.c b.c && fclang -fprofile-generate a.o b.o -o a; llvm-profdata merge dir1 dir2 -o file; llvm-profdata creates a file.

@rupprecht rupprecht merged commit 2805e6f into llvm:main May 21, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bazel "Peripheral" support tier build system: utils/bazel llvm:binary-utilities PGO Profile Guided Optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants