Skip to content

Commit 5e50d3a

Browse files
committed
fix for clang18 builds
getInt8PtrTy removed in clang18
1 parent ab302aa commit 5e50d3a

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

src/c/CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
77
# require at least Clang 9.0
88
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
99
message(FATAL_ERROR "Clang++ version must be at least 9.0!")
10-
elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 15)
11-
set(PERFFLOWASPECT_CLANG_15_NEWER TRUE CACHE BOOL "using >=clang15")
10+
endif()
11+
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 17)
12+
set(PERFFLOWASPECT_CLANG_18_NEWER TRUE CACHE BOOL "using >clang17")
13+
add_definitions(-DPERFFLOWASPECT_CLANG_18_NEWER)
14+
endif()
15+
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 15)
16+
set(PERFFLOWASPECT_CLANG_15_NEWER TRUE CACHE BOOL "using >clang15")
1217
add_definitions(-DPERFFLOWASPECT_CLANG_15_NEWER)
13-
elseif ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15))
18+
endif()
19+
if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15))
1420
set(PERFFLOWASPECT_CLANG_11_NEWER TRUE CACHE BOOL "using >=clang11")
1521
set(PERFFLOWASPECT_CLANG_15_NEWER FALSE CACHE BOOL "using < clang15")
1622
add_definitions(-DPERFFLOWASPECT_CLANG_11_NEWER)

src/c/weaver/weave/perfflow_weave_common.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,18 @@ bool weave_ns::WeaveCommon::insertAfter(Module &m, Function &f, StringRef &a,
145145
auto &context = m.getContext();
146146
Type *voidType = Type::getVoidTy(context);
147147
Type *int32Type = Type::getInt32Ty(context);
148-
Type *int8PtrType = Type::getInt8PtrTy(context);
148+
#ifdef PERFFLOWASPECT_CLANG_18_NEWER
149+
Type *int8Type = Type::getInt8Ty(context);
150+
#else
151+
Type *int8Type = Type::getInt8PtrTy(context);
152+
#endif
149153
std::vector<llvm::Type *> params;
150154
params.push_back(int32Type);
151-
params.push_back(int8PtrType);
152-
params.push_back(int8PtrType);
153-
params.push_back(int8PtrType);
154-
params.push_back(int8PtrType);
155-
params.push_back(int8PtrType);
155+
params.push_back(int8Type);
156+
params.push_back(int8Type);
157+
params.push_back(int8Type);
158+
params.push_back(int8Type);
159+
params.push_back(int8Type);
156160

157161
// voidType is return type, params are parameters and no variable length args
158162
FunctionType *weaveFuncTy = FunctionType::get(voidType, params, false);
@@ -198,14 +202,18 @@ bool weave_ns::WeaveCommon::insertBefore(Module &m, Function &f, StringRef &a,
198202
auto &context = m.getContext();
199203
Type *voidType = Type::getVoidTy(context);
200204
Type *int32Type = Type::getInt32Ty(context);
201-
Type *int8PtrType = Type::getInt8PtrTy(context);
205+
#ifdef PERFFLOWASPECT_CLANG_18_NEWER
206+
Type *int8Type = Type::getInt8Ty(context);
207+
#else
208+
Type *int8Type = Type::getInt8PtrTy(context);
209+
#endif
202210
std::vector<llvm::Type *> params;
203211
params.push_back(int32Type);
204-
params.push_back(int8PtrType);
205-
params.push_back(int8PtrType);
206-
params.push_back(int8PtrType);
207-
params.push_back(int8PtrType);
208-
params.push_back(int8PtrType);
212+
params.push_back(int8Type);
213+
params.push_back(int8Type);
214+
params.push_back(int8Type);
215+
params.push_back(int8Type);
216+
params.push_back(int8Type);
209217

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

0 commit comments

Comments
 (0)