diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 8a7eca0..ec15274 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -96,6 +96,25 @@ target_link_libraries(codspeed PRIVATE instrument_hooks) # Version add_compile_definitions(CODSPEED_VERSION="${CODSPEED_VERSION}") +# Collect compiler toolchain information for environment reporting +execute_process( + COMMAND ${CMAKE_CXX_COMPILER} --version + OUTPUT_VARIABLE CODSPEED_CXX_COMPILER_FULL_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) +# Extract first line only +if(CODSPEED_CXX_COMPILER_FULL_VERSION) + string(REGEX REPLACE "\n.*" "" CODSPEED_CXX_COMPILER_FULL_VERSION "${CODSPEED_CXX_COMPILER_FULL_VERSION}") +endif() + +target_compile_definitions(codspeed PRIVATE + CODSPEED_CXX_COMPILER_ID="${CMAKE_CXX_COMPILER_ID}" + CODSPEED_CXX_COMPILER_VERSION="${CMAKE_CXX_COMPILER_VERSION}" + CODSPEED_CXX_COMPILER_FULL_VERSION="${CODSPEED_CXX_COMPILER_FULL_VERSION}" + CODSPEED_BUILD_TYPE="${CMAKE_BUILD_TYPE}" +) + # Specify the include directories for users of the library target_include_directories( codspeed diff --git a/core/include/measurement.hpp b/core/include/measurement.hpp index 1644415..3d9dc71 100644 --- a/core/include/measurement.hpp +++ b/core/include/measurement.hpp @@ -35,6 +35,21 @@ inline bool measurement_is_instrumented() { inline void measurement_set_metadata() { std::string version = get_version(); instrument_hooks_set_integration(g_hooks, "codspeed-cpp", version.c_str()); + + // Report C++ toolchain information +#ifdef CODSPEED_CXX_COMPILER_ID + instrument_hooks_set_toolchain("cpp", "compiler_id", CODSPEED_CXX_COMPILER_ID); +#endif +#ifdef CODSPEED_CXX_COMPILER_VERSION + instrument_hooks_set_toolchain("cpp", "version", CODSPEED_CXX_COMPILER_VERSION); +#endif +#ifdef CODSPEED_CXX_COMPILER_FULL_VERSION + instrument_hooks_set_toolchain("cpp", "build", CODSPEED_CXX_COMPILER_FULL_VERSION); +#endif +#ifdef CODSPEED_BUILD_TYPE + instrument_hooks_set_toolchain("cpp", "build_type", CODSPEED_BUILD_TYPE); +#endif + instrument_hooks_write_environment(); } ALWAYS_INLINE void measurement_start() { @@ -54,9 +69,9 @@ ALWAYS_INLINE uint64_t measurement_current_timestamp() { return instrument_hooks_current_timestamp(); } -ALWAYS_INLINE int8_t measurement_add_marker(uint8_t marker_type, - uint64_t timestamp) { - auto pid = getpid(); +ALWAYS_INLINE uint8_t measurement_add_marker(uint8_t marker_type, + uint64_t timestamp) { + auto pid = static_cast(getpid()); return instrument_hooks_add_marker(g_hooks, pid, marker_type, timestamp); } diff --git a/core/instrument-hooks b/core/instrument-hooks index 89fb72a..9028c39 160000 --- a/core/instrument-hooks +++ b/core/instrument-hooks @@ -1 +1 @@ -Subproject commit 89fb72a076ec71c9eca6eee9bca98bada4b4dfb4 +Subproject commit 9028c391c73bccf8d36b12fac714233c634636e5