Skip to content

Commit

Permalink
Link profiling libraries for coverage builds (hyrise#2499)
Browse files Browse the repository at this point in the history
  • Loading branch information
dey4ss authored Aug 18, 2022
1 parent 08c2b3f commit 3228b77
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ if (${ENABLE_COVERAGE})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
add_link_options(-fprofile-instr-generate -fcoverage-mapping)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
else()
message(FATAL_ERROR "Don't know how to run coverage on your compiler (${CMAKE_CXX_COMPILER_ID}).")
Expand Down
1 change: 1 addition & 0 deletions src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ set(
types.cpp
types.hpp
uid_allocator.hpp
utils/abstract_plugin.cpp
utils/abstract_plugin.hpp
utils/aligned_size.hpp
utils/assert.hpp
Expand Down
13 changes: 13 additions & 0 deletions src/lib/utils/abstract_plugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "abstract_plugin.hpp"

namespace hyrise {

// We have to instantiate this function here because clang-12(+) does not instantiate it and llvm-cov throws a warning
// (functions have mismatched data). See
// https://stackoverflow.com/questions/57331600/llvm-cov-statistics-for-uninstantiated-functions
std::vector<std::pair<PluginFunctionName, PluginFunctionPointer>> AbstractPlugin::provided_user_executable_functions()
const {
return {};
}

} // namespace hyrise
10 changes: 5 additions & 5 deletions src/lib/utils/abstract_plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ namespace hyrise {

// This is necessary to make the plugin instantiable, it leads to plain C linkage to avoid
// ugly mangled names. Use EXPORT in the implementation file of your plugin.
#define EXPORT_PLUGIN(PluginName) \
extern "C" AbstractPlugin* factory() { return new PluginName(); }
#define EXPORT_PLUGIN(PluginName) \
extern "C" AbstractPlugin* factory() { \
return new PluginName(); \
}

using PluginFunctionName = std::string;
using PluginFunctionPointer = std::function<void(void)>;
Expand All @@ -34,9 +36,7 @@ class AbstractPlugin {
// exec_user_function method. If you are writing a plugin and provide user-exectuable functions it
// is YOUR responsibility to keep these function calls as short and efficient as possible, e.g.,
// by spinning up a thread inside the plugin to execute the actual functionality.
virtual std::vector<std::pair<PluginFunctionName, PluginFunctionPointer>> provided_user_executable_functions() const {
return {};
}
virtual std::vector<std::pair<PluginFunctionName, PluginFunctionPointer>> provided_user_executable_functions() const;
};

} // namespace hyrise

0 comments on commit 3228b77

Please sign in to comment.