Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ __pycache__/
# Distribution / packaging
.Python
build/
build_out/
!csrc/cmake/third_party/build/
!csrc/cmake/third_party/build/modules/
!csrc/cmake/third_party/build/modules/patch/
!csrc/cmake/third_party/build/modules/patch/*.patch
develop-eggs/
dist/
downloads/
Expand Down Expand Up @@ -215,11 +210,3 @@ kernel_meta/
# generated by CANN
fusion_result.json
csrc/output/
csrc/third_party/

# claude code skills
.claude/skills/*

.codegraph/

.vllm_ascend/
5 changes: 5 additions & 0 deletions csrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ set_directory_properties(PROPERTIES
)

# Suppress warnings from catlass/tla third-party headers for CANN kernel compilation
set(VLLM_ASCEND_CANN_COMPAT_HEADER "${OPS_TRANSFORMER_DIR}/common/include/cann_compat.h")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

According to the Repository Style Guide, the PR Title and PR Summary should follow a specific format, especially when the PR description is empty.

Here are the suggested PR Title and PR Summary for this pull request:

Suggested PR Title:

[Ops][BugFix] Fix for new version of CANN

Suggested PR Summary:

### What this PR does / why we need it?

This PR introduces a compatibility header `cann_compat.h` to fix compilation issues with newer versions of CANN (specifically B080 and above). It addresses the issue where `op_common/log/log.h` stopped exposing the unqualified `OP` module ID and provides fallback definitions for logging functions (`CheckLogLevel` and `DlogRecord`) when `LOG_CPP` is defined.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Tested by compiling the `csrc` module with the new CANN version.
References
  1. The PR Title and PR Summary must follow the specified format when the PR description is empty or needs updating. (link)

list(APPEND OPS_COMPILE_OPTIONS -Wno-ignored-attributes)
list(APPEND OPS_COMPILE_OPTIONS -include${VLLM_ASCEND_CANN_COMPAT_HEADER})
add_compile_options(
$<$<COMPILE_LANGUAGE:CXX>:-include${VLLM_ASCEND_CANN_COMPAT_HEADER}>
)
Comment on lines +104 to +107

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Passing -include${VLLM_ASCEND_CANN_COMPAT_HEADER} as a single concatenated argument can cause compilation failures if the path contains spaces. It is much more robust to pass -include and the file path as separate arguments using CMake's list structure and generator expressions.

list(APPEND OPS_COMPILE_OPTIONS "-include" "${VLLM_ASCEND_CANN_COMPAT_HEADER}")
add_compile_options(
    $<$<COMPILE_LANGUAGE:CXX>:-include>
    $<$<COMPILE_LANGUAGE:CXX>:${VLLM_ASCEND_CANN_COMPAT_HEADER}>
)


include(cmake/config.cmake)
include(cmake/func.cmake)
Expand Down
30 changes: 30 additions & 0 deletions csrc/common/include/cann_compat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include <stdint.h>

// B080 op_common/log/log.h stopped exposing the unqualified OP module id used
// by inherited ops-transformer tiling/error headers. Include the CANN log type
// header early so OP still comes from the active CANN version.
#if defined(__has_include)
#if __has_include("base/log_types.h")
#include "base/log_types.h"
#elif __has_include("toolchain/log_types.h")
#include "toolchain/log_types.h"
#endif
#endif

#if !defined(LOG_TYPES_H_) && !defined(OP)
#define OP 63
#endif

#if defined(LOG_CPP) && !defined(DLOG_PUB_H_)
#ifdef __cplusplus
extern "C" {
#endif
int32_t CheckLogLevel(int32_t moduleId, int32_t logLevel);
void DlogRecord(int32_t moduleId, int32_t level, const char *fmt, ...);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

To prevent format string vulnerabilities and ensure compile-time type safety of arguments, it is highly recommended to add the printf format attribute to the variadic DlogRecord function declaration.

Suggested change
void DlogRecord(int32_t moduleId, int32_t level, const char *fmt, ...);
void DlogRecord(int32_t moduleId, int32_t level, const char *fmt, ...) __attribute__((format(printf, 3, 4)));

#ifdef __cplusplus
}
#endif
#define DLOG_PUB_H_
#endif
Loading