-
-
Notifications
You must be signed in to change notification settings - Fork 542
Feat/compile time wrap check #7074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shivansh023023
wants to merge
10
commits into
TheHPXProject:master
Choose a base branch
from
shivansh023023:feat/compile-time-wrap-check
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+47
−0
Open
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ea3eaf6
Add hpx/local.hpp convenience header for single-node usage
shivansh023023 685ef35
build: add compile-time linker wrap check for Linux static builds
shivansh023023 d3567f8
fix: add missing static_linker_check.hpp and resolve CI failures
501de6e
fix: resolve CI failures for clang-format, circular-deps, inspect, an…
2bc2a5c
fix: resolve inspect and build failures
60b3bac
Suppress unused parameter warnings in local_header.cpp test
b5d25c3
PR#7074: finalize compile-time wrap check, remove rejected local.hpp
20e9e24
Fix C++20 modules build: remove export macro from single_sender_value…
571d5de
Fix inspect: replace non-ASCII em-dashes with ASCII -- in static_link…
4bd6baf
chore: remove redundant hpxinspect suppression
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
libs/core/config/include/hpx/config/static_linker_check.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // Copyright (c) 2026 The STE||AR-Group | ||
| // | ||
| // SPDX-License-Identifier: BSL-1.0 | ||
| // Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
| // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
|
||
| // hpxinspect:linelength | ||
| #pragma once | ||
|
|
||
| #include <hpx/config/defines.hpp> | ||
|
|
||
| // Emit a compile-time diagnostic when the user includes hpx/hpx_main.hpp | ||
| // while building a statically-linked HPX application on Linux or macOS. | ||
| // | ||
| // Root cause: the '--wrap=main' linker flag, which redirects user 'main' to | ||
| // the HPX runtime entry-point, is only applied automatically when the user | ||
| // links against 'HPX::wrap_main'. Without it, the resulting binary will call | ||
| // the raw 'main' symbol, bypassing HPX initialisation and producing a | ||
| // hard-to-diagnose runtime crash or silent hang. | ||
| // | ||
| // Actionable remedies (pick one): | ||
| // CMake -- add target_link_libraries(<target> PRIVATE HPX::wrap_main) | ||
| // Manual -- pass -Wl,--wrap=main to the linker explicitly | ||
| // | ||
| // This check is intentionally limited to Linux/macOS static builds because: | ||
| // * On Windows the wrap mechanism is not used (MSVC uses a different ABI). | ||
| // * Dynamic (shared-library) builds already embed the wrap stub inside | ||
| // libhpx.so/dylib, so no extra linker flag is needed. | ||
|
|
||
| #if defined(HPX_HAVE_DYNAMIC_HPX_MAIN) | ||
| #if (defined(__linux) || defined(__linux__) || defined(linux) || \ | ||
| defined(__APPLE__)) && \ | ||
| defined(HPX_HAVE_STATIC_LINKING) && \ | ||
| !defined(HPX_HAVE_WRAP_MAIN_CONFIGURED) | ||
| #warning \ | ||
| "HPX static-link wrap-main check: you included hpx/hpx_main.hpp but the " \ | ||
| "--wrap=main linker flag has not been applied. Add " \ | ||
| "target_link_libraries(<target> PRIVATE HPX::wrap_main) to your " \ | ||
| "CMakeLists.txt, or pass -Wl,--wrap=main to the linker manually. " \ | ||
| "Without this flag the HPX runtime will not be initialised correctly." | ||
| #endif | ||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @hkaiser
Yes, we still need it. I kept the suppression because the #warning diagnostic message explaining how to fix the linker issue (using HPX::wrap_main or -Wl,--wrap=main) is longer than 80 characters.
I wanted the message to be as clear and actionable as possible for the user, which unfortunately makes it fail the inspect tool's line-length check. If you’d prefer, I can try to break the warning across multiple lines, but the suppression was the cleanest way to keep the message readable in the compiler output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you have split the line using
\continuation characters. I don't think inspect will concatenate the split line to check whether its longer than allowed. This comment should not be necessary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s a fair point. I was under the impression that the tool might evaluate the logical line length, but if it only checks physical line length, then you're right,the line continuations already solve the problem.
I’ll remove the hpxinspect:linelength suppression and push the change now. If the CI 'inspect' tool still flags it for some reason, I'll know for sure, but it's better to keep the code clean of unnecessary suppressions. Thanks for the correction!