diff --git a/src/c/CMakeLists.txt b/src/c/CMakeLists.txt index 3668cb15..e96bd411 100644 --- a/src/c/CMakeLists.txt +++ b/src/c/CMakeLists.txt @@ -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) diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index 0c8e28ad..3c41f103 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -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 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); @@ -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 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);