Skip to content

test: find c++filt with CMAKE_NM's target prefix - #130

Draft
ConnorBaker wants to merge 1 commit into
NVIDIA:develfrom
ConnorBaker:cxxfilt-toolchain-prefix
Draft

ConnorBaker wants to merge 1 commit into
NVIDIA:develfrom
ConnorBaker:cxxfilt-toolchain-prefix

Conversation

@ConnorBaker

Copy link
Copy Markdown

Problem

3.8.0's host ABI test (test/host/abi) demangles the symbols that ${CMAKE_NM} lists with ${NVSHMEM_CXXFILT}. CMake finds CMAKE_NM with the compiler's target prefix, for example aarch64-unknown-linux-gnu-nm for aarch64-unknown-linux-gnu-g++. NVSHMEM_CXXFILT, however, is found by its unprefixed names only:

find_program(NVSHMEM_CXXFILT NAMES c++filt llvm-cxxfilt REQUIRED)

A cross toolchain that installs only prefixed binutils therefore fails to configure:

CMake Error at test/host/abi/CMakeLists.txt:2 (find_program):
  Could not find NVSHMEM_CXXFILT using the following names: c++filt,
  llvm-cxxfilt

Change

Derive a c++filt name from CMAKE_NM's prefix and search CMAKE_NM's directory first, then fall back to the previous names. The symbols are then demangled by the same binutils that listed them. A native build's CMAKE_NM has no prefix, so it still finds c++filt as before.

Testing

Built in Nixpkgs from the 3.8.0 release with this patch, CUDA 13.4, NVSHMEM_BUILD_TESTS=ON and NVSHMEM_BUILD_EXAMPLES=ON:

  • x86_64-linux to aarch64-linux cross build (SM 12.1a): configures, generates and builds the host ABI link test, and installs. Without the patch it fails at configure with the error above.
  • x86_64-linux native build (SM 8.9): configures, generates and builds the host ABI link test, and installs.
  • A downstream CMake consumer of the installed package builds against both.

The patch applies unchanged to devel (2dca770), whose test/host/abi/CMakeLists.txt is identical to 3.8.0's.

🤖 Generated with Claude Code

The host ABI test pairs CMAKE_NM with c++filt, but finds c++filt by its
unprefixed name. CMake finds nm with the compiler's target prefix, and
cross toolchains may install only prefixed tools (for example
aarch64-linux-gnu-c++filt), so configuration fails when cross-compiling.

Look for the c++filt that shares CMAKE_NM's prefix and directory first,
then fall back to the previous names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Connor Baker <connorb@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant