Feat/compile time wrap check#7074
Feat/compile time wrap check#7074shivansh023023 wants to merge 2 commits intoTheHPXProject:masterfrom
Conversation
Signed-off-by: shivansh023023 <singhshivansh023@gmail.com>
e1557d8 to
399b4ed
Compare
|
Can one of the admins verify this patch? |
|
Have you seen the existing |
That's a good point, @hkaiser . I did consider HPX_HAVE_DYNAMIC_HPX_MAIN, but that macro indicates that the feature is enabled in the HPX build configuration. The reason for the new HPX_HAVE_WRAP_MAIN_CONFIGURED (injected via INTERFACE compile definitions) is to distinguish between: CMake users: Who get the linker flag automatically and should not see the warning. Non-CMake users: Who have the feature enabled in their HPX installation but haven't necessarily passed the -Wl,-wrap=main flag to their manual link command. Without the new definition, hpx_main.hpp wouldn't be able to tell if the user linking manually has actually applied the flag or not. Does that make sense, or is there a way to leverage the existing macro to detect the linker-state that I might have missed? |
Signed-off-by: shivansh023023 <singhshivansh023@gmail.com>
399b4ed to
17f832f
Compare
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesFootnotes
|
|
@shivansh023023 Could you please have a look at the compilation failure generated? |
Add a compile-time diagnostic that fires when dynamic main() wrapping is enabled (HPX_HAVE_DYNAMIC_HPX_MAIN) but the -Wl,-wrap=main linker flag was not configured (HPX_HAVE_WRAP_MAIN_CONFIGURED). Uses #pragma message instead of #warning to avoid -Werror failures. CMake targets hpx_wrap and hpx_auto_wrap now define HPX_HAVE_WRAP_MAIN_CONFIGURED, suppressing the diagnostic for properly linked consumers. Refs: TheHPXProject#7074 Signed-off-by: shivansh023023 <singhshivansh023@gmail.com>
|
The CIs still report that one of the translation units can't find the header |
|
@shivansh023023 ping? |
Fixes #
Proposed Changes
INTERFACEcompile definitionHPX_HAVE_WRAP_MAIN_CONFIGUREDto bothhpx_wrapandhpx_auto_wraptargets inwrap/CMakeLists.txt(inside the existingHPX_WITH_DYNAMIC_HPX_MAIN+ Linux guard). This injects the define automatically into any downstream CMake consumer, ensuring zero noise for CMake users.#warninginwrap/include/hpx/hpx_main.hppthat fires when all of these are true:__linux__,HPX_HAVE_DYNAMIC_HPX_MAIN,HPX_HAVE_STATIC_LINKING, andHPX_HAVE_WRAP_MAIN_CONFIGUREDis not defined. This catches the missing-Wl,-wrap=mainlinker flag at compile time instead of letting it become a runtime crash.Any background context you want to provide?
This is the compile-time component of a safety net for the UX gap where
-Wl,-wrap=maindoes not propagate to non-CMake consumers (Godbolt / Compiler Explorer, Makefiles, rawg++invocations). It complements:godbolt-minimalCMake preset (build-system level)hpx/local.hppconvenience header (usability level)Design trade-off: Non-CMake users who have already added
-Wl,-wrap=mainmanually will still see the#warning(since they lack the define). They can silence it with-DHPX_HAVE_WRAP_MAIN_CONFIGURED. A suppressible compile-time warning is far better than a silent compilation followed by a cryptic runtime crash.This work is part of the GSoC 2026 effort to integrate HPX into Compiler Explorer.
Checklist
I have fixed a bug and have added a regression test.(N/A — this is a new diagnostic, not a bugfix)I have added a test using random numbers(N/A)