NVIDIA / NVIDIA/cutlass

[Bug] `cutlass_profiler` fails to build with `CUTLASS_BUILD_SHARED_LIBS=OFF`

Open Beginner friendly
#3,179 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

inactive-30d inactive-90d
Dominant language
C++
Stars
10.5k
Forks
2.1k
Avg merge
3d 11h
Merged PRs (30d)
7

Description

Bug: cutlass_profiler fails to build with CUTLASS_BUILD_SHARED_LIBS=OFF

Description

When building CUTLASS v4.3.5 (and main) with static-only configuration (-DCUTLASS_BUILD_SHARED_LIBS=OFF -DCUTLASS_BUILD_STATIC_LIBS=ON), the cutlass_profiler target fails to compile with:

fatal error: cutlass/library/library.h: No such file or directory

The header file exists at tools/library/include/cutlass/library/library.h, but the include path is never propagated to the profiler target.

Root Cause

In tools/library/CMakeLists.txt (lines 283–290), the cutlass_lib alias is only created when shared libs are enabled:

# For backward compatibility with the old name
if(CUTLASS_BUILD_SHARED_LIBS)
  add_library(cutlass_lib ALIAS cutlass_library)       # ← only when shared ON
endif()

if(CUTLASS_BUILD_STATIC_LIBS)
  add_library(cutlass_lib_static ALIAS cutlass_library_static)
endif()

However, tools/profiler/CMakeLists.txt (line 89) unconditionally links against cutlass_lib:

target_link_libraries(
  cutlass_profiler
  PRIVATE
  cutlass_lib          # ← always required, no fallback
  cutlass_tools_util_includes
  ...
)

When CUTLASS_BUILD_SHARED_LIBS=OFF, the cutlass_lib target does not exist. CMake silently treats the name as a plain linker flag (-lcutlass_lib) rather than a CMake target, so:

  1. Transitive include directories from cutlass_library_includes (which provides tools/library/include/) are not propagated → compilation fails with missing headers.
  2. Even if compilation somehow passed, linking would also fail because no libcutlass_lib.so or libcutlass_lib.a file exists.

Environment

  • CUTLASS version: v4.3.5 (also verified on main)
  • Platform: aarch64
  • CMake: 3.31.6
  • GCC: 13.3.0
  • Base image: nvcr.io/nvidia/pytorch:25.08-py3

Steps to Reproduce

git clone --branch v4.3.5 --depth 1 https://github.com/NVIDIA/cutlass.git
cmake \
    -DCUTLASS_BUILD_SHARED_LIBS=OFF \
    -DCUTLASS_BUILD_STATIC_LIBS=ON \
    -DCUTLASS_NVCC_ARCHS="100a;103a" \
    -DCUTLASS_ENABLE_EXAMPLES=OFF \
    -DCUTLASS_ENABLE_TESTS=OFF \
    -DCUTLASS_LIBRARY_KERNELS="cutlass3x_sm100_tensorop_gemm_f16_*" \
    -S ./cutlass \
    -B ./cutlass/build
cmake --build ./cutlass/build --target cutlass_profiler

Why static-only?

On aarch64, even per-family shared libraries can overflow R_AARCH64_PREL32 relocations (±2 GB limit) in .eh_frame when thousands of SM100 GEMM kernel objects are linked into a single .so. Building static-only avoids this linker limitation entirely, since .a archives defer relocation to the final executable link.

CUTLASS already has -mcmodel=medium handling for x86_64 large library relocation issues, but has no equivalent workaround for aarch64.

Suggested Fix

Add a static fallback alias in tools/library/CMakeLists.txt:

if(CUTLASS_BUILD_STATIC_LIBS)
  add_library(cutlass_lib_static ALIAS cutlass_library_static)
  if(NOT TARGET cutlass_lib)
    add_library(cutlass_lib ALIAS cutlass_library_static)
  endif()
endif()

This ensures cutlass_lib exists regardless of the shared/static configuration, preserving backward compatibility.

Current Workaround

We apply a sed patch post-clone before running cmake:

sed -i '/add_library(cutlass_lib_static ALIAS cutlass_library_static)/a\
  if(NOT TARGET cutlass_lib)\n\
    add_library(cutlass_lib ALIAS cutlass_library_static)\n\
  endif()' cutlass/tools/library/CMakeLists.txt

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in tools/library/CMakeLists.txt around the cutlass_lib and cutlass_lib_static aliases, then inspect the cutlass_profiler linkage in tools/profiler/CMakeLists.txt. Configure with shared libraries off and static libraries on, build the cutlass_profiler target, and confirm that compilation and linking succeed with the library include paths propagated.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.