Skip to content

Commit 9c585ad

Browse files
yingcong-wumahesh-attarde
authored andcommitted
[libunwind][test] Add check for objcopy to improve test compatibility (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.
1 parent 57e449c commit 9c585ad

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

libunwind/test/configs/cmake-bridge.cfg.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import os, site
1515
site.addsitedir(os.path.join('@LIBUNWIND_LIBCXX_PATH@', 'utils'))
1616
import libcxx.test.format
17+
from lit.util import which
1718

1819
# Basic configuration of the test suite
1920
config.name = os.path.basename('@LIBUNWIND_TEST_CONFIG@')
@@ -33,3 +34,13 @@ config.substitutions.append(('%{install-prefix}', '@LIBUNWIND_TESTING_INSTALL_PR
3334
config.substitutions.append(('%{include}', '@LIBUNWIND_TESTING_INSTALL_PREFIX@/include'))
3435
config.substitutions.append(('%{lib}', '@LIBUNWIND_TESTING_INSTALL_PREFIX@/@LIBUNWIND_INSTALL_LIBRARY_DIR@'))
3536
config.substitutions.append(('%{benchmark_flags}', ''))
37+
38+
# Check for objcopy tools
39+
objcopy_path = which('llvm-objcopy', '@LLVM_BUILD_BINARY_DIR@/bin')
40+
if not objcopy_path:
41+
objcopy_path = which('llvm-objcopy')
42+
if not objcopy_path:
43+
objcopy_path = which('objcopy')
44+
if objcopy_path:
45+
config.substitutions.append(('%{objcopy}', objcopy_path))
46+
config.available_features.add('objcopy-available')

libunwind/test/eh_frame_fde_pc_range.pass.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@
1414
// clang-format off
1515

1616
// REQUIRES: target={{x86_64-.+-linux-gnu}}
17-
// aarch64,arm have a cross toolchain build(llvm-clang-win-x-aarch64, etc)
18-
// where objdump is not available.
17+
// REQUIRES: objcopy-available
1918

2019
// TODO: Figure out why this fails with Memory Sanitizer.
2120
// XFAIL: msan
2221

2322
// RUN: %{build}
24-
// RUN: objcopy --dump-section .eh_frame_hdr=%t_ehf_hdr.bin %t.exe
23+
// RUN: %{objcopy} --dump-section .eh_frame_hdr=%t_ehf_hdr.bin %t.exe
2524
// RUN: echo -ne '\xFF' | dd of=%t_ehf_hdr.bin bs=1 seek=2 count=2 conv=notrunc status=none
26-
// RUN: objcopy --update-section .eh_frame_hdr=%t_ehf_hdr.bin %t.exe
25+
// RUN: %{objcopy} --update-section .eh_frame_hdr=%t_ehf_hdr.bin %t.exe
2726
// RUN: %{exec} %t.exe
2827

2928
// clang-format on

0 commit comments

Comments
 (0)