Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-Wl,--Map=phlex_link.map is added globally when build profiling is enabled. Since this project links multiple shared libraries/modules/executables in parallel, all link steps will try to write the same map file in the build directory, leading to races/overwrites (and potentially interleaved/corrupt output under parallel builds). Consider removing the global map generation, or emitting a per-target map file (e.g., via target-specific link options or a small helper that sets a unique map path per target).

Suggested change
add_link_options("-Wl,--Map=phlex_link.map")

Copilot uses AI. Check for mistakes.
add_link_options("-Wl,--print-archive-stats=-")
endif()
endif()
# ##############################################################################

add_compile_options(
-Wall
Expand Down
Loading