Skip to content

Conversation

yingcong-wu
Copy link
Contributor

@yingcong-wu yingcong-wu commented Sep 29, 2025

Previously, we only used objcopy, which is not available for some build configurations. With this patch, we not only try to use objcopy, but also try to use llvm-objcopy if available.

This is a follow-up of #156383.

@yingcong-wu yingcong-wu requested a review from a team as a code owner September 29, 2025 02:03
@llvmbot
Copy link
Member

llvmbot commented Sep 29, 2025

@llvm/pr-subscribers-libunwind

Author: Wu Yingcong (yingcong-wu)

Changes

Previous, we only use objcopy, which is not available for some of the build configs. With this patch, we not only try to use objcopy, but also try to use llvm-objcopy if available.

This is a following up of #156383.


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

2 Files Affected:

  • (modified) libunwind/test/configs/cmake-bridge.cfg.in (+11)
  • (modified) libunwind/test/eh_frame_fde_pc_range.pass.cpp (+3-5)
diff --git a/libunwind/test/configs/cmake-bridge.cfg.in b/libunwind/test/configs/cmake-bridge.cfg.in
index b804c210f0bbc..186118da92597 100644
--- a/libunwind/test/configs/cmake-bridge.cfg.in
+++ b/libunwind/test/configs/cmake-bridge.cfg.in
@@ -14,6 +14,7 @@
 import os, site
 site.addsitedir(os.path.join('@LIBUNWIND_LIBCXX_PATH@', 'utils'))
 import libcxx.test.format
+from lit.util import which
 
 # Basic configuration of the test suite
 config.name = os.path.basename('@LIBUNWIND_TEST_CONFIG@')
@@ -33,3 +34,13 @@ config.substitutions.append(('%{install-prefix}', '@LIBUNWIND_TESTING_INSTALL_PR
 config.substitutions.append(('%{include}', '@LIBUNWIND_TESTING_INSTALL_PREFIX@/include'))
 config.substitutions.append(('%{lib}', '@LIBUNWIND_TESTING_INSTALL_PREFIX@/@LIBUNWIND_INSTALL_LIBRARY_DIR@'))
 config.substitutions.append(('%{benchmark_flags}', ''))
+
+# Check for objcopy tools
+objcopy_path = which('objcopy')
+if not objcopy_path:
+    objcopy_path = which('llvm-objcopy')
+if not objcopy_path:
+    objcopy_path = which('llvm-objcopy', '@LLVM_BUILD_BINARY_DIR@/bin')
+if objcopy_path:
+    config.substitutions.append(('%{objcopy}', objcopy_path))
+    config.available_features.add('objcopy-available')
diff --git a/libunwind/test/eh_frame_fde_pc_range.pass.cpp b/libunwind/test/eh_frame_fde_pc_range.pass.cpp
index 39c8e8066264d..d11fedd45b5c7 100644
--- a/libunwind/test/eh_frame_fde_pc_range.pass.cpp
+++ b/libunwind/test/eh_frame_fde_pc_range.pass.cpp
@@ -13,17 +13,15 @@
 
 // clang-format off
 
-// REQUIRES: target={{x86_64-.+-linux-gnu}}
-// aarch64,arm have a cross toolchain build(llvm-clang-win-x-aarch64, etc)
-// where objdump is not available.
+// REQUIRES: linux, objcopy-available
 
 // TODO: Figure out why this fails with Memory Sanitizer.
 // XFAIL: msan
 
 // RUN: %{build}
-// RUN: objcopy --dump-section .eh_frame_hdr=%t_ehf_hdr.bin %t.exe
+// RUN: %{objcopy} --dump-section .eh_frame_hdr=%t_ehf_hdr.bin %t.exe
 // RUN: echo -ne '\xFF' | dd of=%t_ehf_hdr.bin bs=1 seek=2 count=2 conv=notrunc status=none 
-// RUN: objcopy --update-section .eh_frame_hdr=%t_ehf_hdr.bin %t.exe
+// RUN: %{objcopy} --update-section .eh_frame_hdr=%t_ehf_hdr.bin %t.exe
 // RUN: %{exec} %t.exe
 
 // clang-format on

@yingcong-wu yingcong-wu requested a review from fmayer October 1, 2025 00:22
@yingcong-wu
Copy link
Contributor Author

CI Failures not related.

@yingcong-wu yingcong-wu merged commit 4aaf6d1 into llvm:main Oct 1, 2025
71 of 77 checks passed
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
…llvm#161112)

Previously, we only used `objcopy`, which is not available for some
build configurations. With this patch, we not only try to use `objcopy`,
but also try to use `llvm-objcopy` if available.

This is a follow-up of llvm#156383.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants