From acf7248ec58a29b6666904d18476b3718b22ba13 Mon Sep 17 00:00:00 2001 From: Chris Green Date: Tue, 10 Mar 2026 16:32:24 -0500 Subject: [PATCH 1/2] Enable compile/link time profiling --- CMakeLists.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index dad56423..44ea6e54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,27 @@ option(ENABLE_TSAN "Enable Thread Sanitizer" OFF) option(ENABLE_ASAN "Enable Address Sanitizer" OFF) option(PHLEX_USE_FORM "Enable experimental integration with FORM" OFF) option(ENABLE_COVERAGE "Enable code coverage instrumentation" OFF) +option(ENABLE_BUILD_PROFILING "Enable monitoring of compile and link operations" OFF) + +# ############################################################################## +# Enable collection of compile/link statistics. +# +# If lld is available but not default for the current toolset, then use +# `-DCMAKE_LINKER_TYPE=LLD` +if (ENABLE_BUILD_PROFILING) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_COMMAND} -E time") + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CMAKE_COMMAND} -E time") + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") + add_compile_options("-ftime-trace") + endif() + if(CMAKE_CXX_COMPILER_LINKER_ID STREQUAL "LLD") + message(STATUS "LLD detected (Phlex build) - Enabling tracing") + add_link_options("-Wl,--time-trace") + add_link_options("-Wl,--Map=phlex_link.map") + add_link_options("-Wl,--print-archive-stats=-") + endif() +endif() +# ############################################################################## add_compile_options( -Wall From c2b60b7e96c6a564c19888d2348d898408bd25c4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 11 Mar 2026 13:49:32 +0000 Subject: [PATCH 2/2] Apply cmake-format fixes --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44ea6e54..b53061a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,7 +70,7 @@ option(ENABLE_BUILD_PROFILING "Enable monitoring of compile and link operations" # # If lld is available but not default for the current toolset, then use # `-DCMAKE_LINKER_TYPE=LLD` -if (ENABLE_BUILD_PROFILING) +if(ENABLE_BUILD_PROFILING) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_COMMAND} -E time") set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CMAKE_COMMAND} -E time") if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")