Skip to content

Commit

Permalink
fix for clang18 builds
Browse files Browse the repository at this point in the history
getInt8PtrTy removed in clang18
  • Loading branch information
slabasan committed Oct 10, 2024
1 parent dfd0e1f commit 6ea2647
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
12 changes: 9 additions & 3 deletions src/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# require at least Clang 9.0
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
message(FATAL_ERROR "Clang++ version must be at least 9.0!")
elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 15)
set(PERFFLOWASPECT_CLANG_15_NEWER TRUE CACHE BOOL "using >=clang15")
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 17)
set(PERFFLOWASPECT_CLANG_18_NEWER TRUE CACHE BOOL "using >clang17")
add_definitions(-DPERFFLOWASPECT_CLANG_18_NEWER)
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 15)
set(PERFFLOWASPECT_CLANG_15_NEWER TRUE CACHE BOOL "using >clang15")
add_definitions(-DPERFFLOWASPECT_CLANG_15_NEWER)
elseif ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15))
endif()
if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15))
set(PERFFLOWASPECT_CLANG_11_NEWER TRUE CACHE BOOL "using >=clang11")
set(PERFFLOWASPECT_CLANG_15_NEWER FALSE CACHE BOOL "using < clang15")
add_definitions(-DPERFFLOWASPECT_CLANG_11_NEWER)
Expand Down
32 changes: 20 additions & 12 deletions src/c/weaver/weave/perfflow_weave_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,18 @@ bool weave_ns::WeaveCommon::insertAfter(Module &m, Function &f, StringRef &a,
auto &context = m.getContext();
Type *voidType = Type::getVoidTy(context);
Type *int32Type = Type::getInt32Ty(context);
Type *int8PtrType = Type::getInt8PtrTy(context);
#ifdef PERFFLOWASPECT_CLANG_18_NEWER
Type *int8Type = Type::getInt8Ty(context);
#else
Type *int8Type = Type::getInt8PtrTy(context);
#endif
std::vector<llvm::Type *> params;
params.push_back(int32Type);
params.push_back(int8PtrType);
params.push_back(int8PtrType);
params.push_back(int8PtrType);
params.push_back(int8PtrType);
params.push_back(int8PtrType);
params.push_back(int8Type);
params.push_back(int8Type);
params.push_back(int8Type);
params.push_back(int8Type);
params.push_back(int8Type);

// voidType is return type, params are parameters and no variable length args
FunctionType *weaveFuncTy = FunctionType::get(voidType, params, false);
Expand Down Expand Up @@ -198,14 +202,18 @@ bool weave_ns::WeaveCommon::insertBefore(Module &m, Function &f, StringRef &a,
auto &context = m.getContext();
Type *voidType = Type::getVoidTy(context);
Type *int32Type = Type::getInt32Ty(context);
Type *int8PtrType = Type::getInt8PtrTy(context);
#ifdef PERFFLOWASPECT_CLANG_18_NEWER
Type *int8Type = Type::getInt8Ty(context);
#else
Type *int8Type = Type::getInt8PtrTy(context);
#endif
std::vector<llvm::Type *> params;
params.push_back(int32Type);
params.push_back(int8PtrType);
params.push_back(int8PtrType);
params.push_back(int8PtrType);
params.push_back(int8PtrType);
params.push_back(int8PtrType);
params.push_back(int8Type);
params.push_back(int8Type);
params.push_back(int8Type);
params.push_back(int8Type);
params.push_back(int8Type);

// voidType is return type, params are parameters and no variable length args
FunctionType *weaveFuncTy = FunctionType::get(voidType, params, false);
Expand Down

0 comments on commit 6ea2647

Please sign in to comment.