Skip to content

[cutlass-library] Alias cutlass_lib to the static target when shared is off (fixes #3179)#3245

Open
LeSingh1 wants to merge 1 commit into
NVIDIA:mainfrom
LeSingh1:fix/cutlass-lib-alias-for-static-only-build
Open

[cutlass-library] Alias cutlass_lib to the static target when shared is off (fixes #3179)#3245
LeSingh1 wants to merge 1 commit into
NVIDIA:mainfrom
LeSingh1:fix/cutlass-lib-alias-for-static-only-build

Conversation

@LeSingh1
Copy link
Copy Markdown

Summary

When CUTLASS is built with a static-only configuration (-DCUTLASS_BUILD_SHARED_LIBS=OFF -DCUTLASS_BUILD_STATIC_LIBS=ON), tools/profiler fails to compile:

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

Root cause

In tools/library/CMakeLists.txt the legacy cutlass_lib ALIAS is only created when CUTLASS_BUILD_SHARED_LIBS=ON:

if(CUTLASS_BUILD_SHARED_LIBS)
  add_library(cutlass_lib ALIAS cutlass_library)
endif()

But tools/profiler/CMakeLists.txt unconditionally consumes it (line 89):

target_link_libraries(cutlass_profiler PRIVATE cutlass_lib ...)

When shared is disabled, cutlass_lib doesn't exist; CMake silently treats it as a plain -lcutlass_lib linker flag, so the transitive include directories from cutlass_library_includes (which expose tools/library/include/) are never propagated, hence the missing-header error.

Fix

Fall back to aliasing cutlass_lib to the static target when shared is disabled:

if(CUTLASS_BUILD_SHARED_LIBS)
  add_library(cutlass_lib ALIAS cutlass_library)
elseif(CUTLASS_BUILD_STATIC_LIBS)
  add_library(cutlass_lib ALIAS cutlass_library_static)
endif()

Behavior when SHARED_LIBS=ON (the default and most common configuration) is unchanged.

Verification

I don't have a CUDA build environment on this machine, so I have not run a full static-only build locally. The diff matches the diagnosis in the issue body verbatim, and the change is local to a single backwards-compatibility alias.

Issue

Fixes #3179

…is off

The legacy `cutlass_lib` ALIAS was only created when
CUTLASS_BUILD_SHARED_LIBS=ON. Consumers such as tools/profiler
unconditionally link to it, so a static-only configuration
(`-DCUTLASS_BUILD_SHARED_LIBS=OFF -DCUTLASS_BUILD_STATIC_LIBS=ON`)
loses both the transitive include directories from
`cutlass_library_includes` and the link itself -- the profiler then
fails to build with:

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

Fall back to aliasing `cutlass_lib` to the static target when shared is
disabled. Behavior when shared is enabled (the default) is unchanged.

Fixes NVIDIA#3179
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.

[Bug] cutlass_profiler fails to build with CUTLASS_BUILD_SHARED_LIBS=OFF

1 participant