Feat/compile time wrap check#7074
Feat/compile time wrap check#7074shivansh023023 wants to merge 3 commits intoTheHPXProject:masterfrom
Conversation
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? |
399b4ed to
17f832f
Compare
|
@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 <[email protected]>
|
The CIs still report that one of the translation units can't find the header |
|
@shivansh023023 ping? |
|
@shivansh023023 Are you still interested in moving tis forward? Otherwise I'll go ahead and close this without merging. |
Signed-off-by: shivansh023023 <[email protected]>
Signed-off-by: shivansh023023 <[email protected]>
17f832f to
af6bf75
Compare
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
@shivansh023023 Please have an eye on the CIs yourself. Many issues are still being reported. |
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)