Skip to content

Fix codegen writing config.h into source tree - #3764

Open
alexioslyrakis-amd wants to merge 1 commit into
developfrom
fix/codegen-config-source-tree-pollution
Open

Fix codegen writing config.h into source tree#3764
alexioslyrakis-amd wants to merge 1 commit into
developfrom
fix/codegen-config-source-tree-pollution

Conversation

@alexioslyrakis-amd

Copy link
Copy Markdown

Summary

codegen/CMakeLists.txt uses configure_file() to generate config.h directly into the source tree (include/ck/config.h) instead of the build directory. This causes -Wmacro-redefined warnings because:

  1. The generated source-tree config.h unconditionally #defines macros like CK_ENABLE_INT8, CK_ENABLE_FP8, etc.
  2. The same macros are also passed via -D flags on the command line by CMake
  3. The source-tree include/ is searched before the build-dir include/, so this guardless file wins over the properly generated one

The main CMakeLists.txt (line 530) already generates config.h correctly into ${CMAKE_CURRENT_BINARY_DIR}. This PR fixes codegen/CMakeLists.txt to do the same.

Example warnings

In file included from .../ck/include/ck/ck.hpp:6:
.../ck/include/ck/config.h:5:9: warning: 'CK_ENABLE_INT8' macro redefined [-Wmacro-redefined]
    5 | #define CK_ENABLE_INT8 "ON"
      |         ^
<command line>:8:9: note: previous definition is here
    8 | #define CK_ENABLE_INT8 1
      |         ^

.../ck/include/ck/config.h:6:9: warning: 'CK_ENABLE_FP8' macro redefined [-Wmacro-redefined]
    6 | #define CK_ENABLE_FP8 "ON"
      |         ^
<command line>:7:9: note: previous definition is here
    7 | #define CK_ENABLE_FP8 1
      |         ^

.../ck/include/ck/config.h:8:9: warning: 'CK_ENABLE_FP16' macro redefined [-Wmacro-redefined]
    8 | #define CK_ENABLE_FP16 "ON"
      |         ^
<command line>:4:9: note: previous definition is here
    4 | #define CK_ENABLE_FP16 1
      |         ^

These warnings repeat for every translation unit that includes ck.hpp.

Fix

Change codegen/CMakeLists.txt to write the generated config.h to ${CMAKE_CURRENT_BINARY_DIR} instead of the source tree, matching the main CMakeLists.txt.

codegen/CMakeLists.txt generates config.h directly into the source
tree (include/ck/config.h) instead of the build directory. This
pollutes the source tree with a build artifact that lacks the #ifndef
guards present in config.h.in, causing -Wmacro-redefined warnings
when macros are also defined via -D flags on the command line.

Write the generated config.h to CMAKE_CURRENT_BINARY_DIR instead,
matching what the main CMakeLists.txt already does (line 530).
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