You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TITLE
[Build System] UX Gap: -Wl,-wrap=main does not propagate to non-CMake consumers
Summary
When linking HPX statically on Linux without CMake (e.g., via Makefiles, Godbolt/Compiler Explorer, or direct compiler invocations), users who include <hpx/hpx_main.hpp> hit a runtime crash because the required -Wl,-wrap=main linker flag is not discoverable outside of CMake's target property system.
Root Cause
The -Wl,-wrap=main flag is correctly set as an INTERFACE link library on both hpx_wrap and hpx_auto_wrap targets in wrap/CMakeLists.txt:126-129:
This means non-CMake consumers never see the flag. They must know to pass -Wl,-wrap=main manually, but there is no prominent documentation of this requirement.
Symptoms
Users encounter this runtime error:
Attempting to use hpx_main.hpp functionality without linking to libhpx_wrap.
If you're using CMakeLists, make sure to add HPX::wrap_main to target_link_libraries.
If you're using Makefile, make sure to link to libhpx_wrap when generating the executable.
The error message mentions CMake and Makefiles but does not specify the actual linker flag (-Wl,-wrap=main) required to resolve the issue.
Who Is Affected
Users linking HPX manually via Makefiles or shell scripts
Browser-based compiler services (Compiler Explorer / Godbolt) that invoke g++ directly
CI/CD pipelines that don't use CMake for the final link step
Educational materials and tutorials that show manual compilation
Discoverability
The flag is documented in the pkgconfig file (hpx_application_release.pc), but many users do not use pkg-config. The flag is invisible in the installed CMake targets unless the user inspects the HPXInternalTargets.cmake export file.
Workaround
Users must manually add the flag to their link command:
TITLE
[Build System] UX Gap:
-Wl,-wrap=maindoes not propagate to non-CMake consumersSummary
When linking HPX statically on Linux without CMake (e.g., via Makefiles, Godbolt/Compiler Explorer, or direct compiler invocations), users who include
<hpx/hpx_main.hpp>hit a runtime crash because the required-Wl,-wrap=mainlinker flag is not discoverable outside of CMake's target property system.Root Cause
The
-Wl,-wrap=mainflag is correctly set as anINTERFACElink library on bothhpx_wrapandhpx_auto_wraptargets inwrap/CMakeLists.txt:126-129:This propagates correctly to downstream CMake consumers via the exported target chain:
However, the
hpx_interface_auto_wrap_maintarget uses a generator expression that only activates for CMakeEXECUTABLEtargets:This means non-CMake consumers never see the flag. They must know to pass
-Wl,-wrap=mainmanually, but there is no prominent documentation of this requirement.Symptoms
Users encounter this runtime error:
The error message mentions CMake and Makefiles but does not specify the actual linker flag (
-Wl,-wrap=main) required to resolve the issue.Who Is Affected
g++directlyDiscoverability
The flag is documented in the pkgconfig file (
hpx_application_release.pc), but many users do not usepkg-config. The flag is invisible in the installed CMake targets unless the user inspects theHPXInternalTargets.cmakeexport file.Workaround
Users must manually add the flag to their link command:
Resolution
This issue is partially addressed by:
godbolt-minimalCMake preset that documents the required build configuration for sandboxed environments.get_default_pool.cppto explicitly mention-Wl,-wrap=main(Linux) and-Wl,-e,_initialize_main(macOS), giving non-CMake users an actionable fix.Suggestions for Full Resolution
-Wl,-wrap=mainto any future "HPX Quick Start" or "Try HPX Online" documentation.Environment
HPX_WITH_STATIC_LINKING=ON)