Repository navigation
Put the full version into the SONAME of the HPX libraries #8225
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
base: master
Are you sure you want to change the base?
Changes from all commits
c11d108
01513a7
a8c5378
26647a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,11 +50,15 @@ | |
| #endif | ||
|
|
||
| /////////////////////////////////////////////////////////////////////////////// | ||
| // The version check enforces the major and minor version numbers to match for | ||
| // every compilation unit to be compiled. | ||
| // The name of the symbol the version check refers to, it holds the full | ||
| // version (for instance hpx_check_version_2_1_0): HPX keeps no ABI | ||
| // compatibility between releases. | ||
| #define HPX_CHECK_VERSION \ | ||
| HPX_PP_CAT(hpx_check_version_, \ | ||
| HPX_PP_CAT(HPX_VERSION_MAJOR, HPX_PP_CAT(_, HPX_VERSION_MINOR))) \ | ||
| HPX_PP_CAT(HPX_VERSION_MAJOR, \ | ||
| HPX_PP_CAT(_, \ | ||
| HPX_PP_CAT(HPX_VERSION_MINOR, \ | ||
| HPX_PP_CAT(_, HPX_VERSION_SUBMINOR))))) \ | ||
| /**/ | ||
|
|
||
| // The version check enforces the major and minor version numbers to match for | ||
|
|
@@ -66,27 +70,49 @@ | |
| /////////////////////////////////////////////////////////////////////////////// | ||
| namespace hpx { | ||
| // Helper data structures allowing to automatically detect version problems | ||
| // between applications and the core libraries. | ||
| HPX_CORE_EXPORT extern char const HPX_CHECK_VERSION[]; | ||
| // between applications and the core libraries. C linkage keeps the symbol | ||
| // name undecorated for the linker directive below. | ||
| HPX_CXX_CORE_EXPORT extern "C" HPX_CORE_EXPORT char const | ||
| HPX_CHECK_VERSION[]; | ||
| HPX_CORE_EXPORT extern char const HPX_CHECK_BOOST_VERSION[]; | ||
| } // namespace hpx | ||
|
|
||
| /////////////////////////////////////////////////////////////////////////////// | ||
| #if !defined(HPX_CORE_EXPORTS) && !defined(HPX_NO_VERSION_CHECK) | ||
|
|
||
| // This is instantiated for each translation unit outside the HPX core | ||
| // library, forcing to resolve the variable HPX_CHECK_VERSION. | ||
| namespace { | ||
| // Note: this function is never executed. | ||
| #if defined(__GNUG__) || defined(__clang__) | ||
| __attribute__((unused)) | ||
| // Every binary built from a translation unit outside the HPX core library | ||
| // refers to HPX_CHECK_VERSION. Such a binary doesn't load with the core | ||
| // library of another release (the loader reports the missing symbol), instead | ||
| // of running with a mismatched ABI. The reference has to survive optimization. | ||
| #if defined(_MSC_VER) | ||
| // MSVC has no attribute that keeps an unreferenced variable: let the linker | ||
| // include the symbol instead (32-bit x86 prefixes C names with '_') | ||
| #if defined(_M_IX86) | ||
| #define HPX_CHECK_VERSION_SYMBOL "_" HPX_PP_STRINGIZE(HPX_CHECK_VERSION) | ||
| #else | ||
| #define HPX_CHECK_VERSION_SYMBOL HPX_PP_STRINGIZE(HPX_CHECK_VERSION) | ||
| #endif | ||
| #if !defined(HPX_MODULE_STATIC_LINKING) && !defined(HPX_HAVE_STATIC_LINKING) | ||
| #pragma comment(linker, "/include:__imp_" HPX_CHECK_VERSION_SYMBOL) | ||
| #else | ||
| #pragma comment(linker, "/include:" HPX_CHECK_VERSION_SYMBOL) | ||
| #endif | ||
| #undef HPX_CHECK_VERSION_SYMBOL | ||
| #elif defined(__GNUC__) || defined(__clang__) | ||
| // 'used' keeps the variable from the compiler, 'retain' (ELF only) keeps its | ||
| // section from the linker's garbage collection (--gc-sections) | ||
| #if defined(__ELF__) && defined(__has_attribute) | ||
| #if __has_attribute(retain) | ||
| #define HPX_CHECK_VERSION_KEEP __attribute__((used, retain)) | ||
|
Comment on lines
+105
to
+106
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The On ELF targets, the header emits Choose the GCC retention behavior so this combination does not fail under
|
||
| #endif | ||
| char const* | ||
| check_hpx_version() | ||
| { | ||
| char const* versions[] = { | ||
| hpx::HPX_CHECK_VERSION, hpx::HPX_CHECK_BOOST_VERSION}; | ||
| return versions[0]; | ||
| } | ||
| #endif | ||
| #if !defined(HPX_CHECK_VERSION_KEEP) | ||
| #define HPX_CHECK_VERSION_KEEP __attribute__((used)) | ||
| #endif | ||
| namespace { | ||
| HPX_CHECK_VERSION_KEEP char const* const hpx_check_version_reference = | ||
| hpx::HPX_CHECK_VERSION; | ||
| } // namespace | ||
| #undef HPX_CHECK_VERSION_KEEP | ||
| #endif | ||
| #endif | ||
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.
Document the version-check opt-out.
If an application defines
HPX_NO_VERSION_CHECKbefore including HPX headers, it does not retain this reference. On Windows and Android, that application can lack the stated cross-release protection. Qualify the guarantee and mention the opt-out here, as the release notes do. (raw.githubusercontent.com)