Skip to content
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

Adds Debug option for hpx initializing from main #3385

Merged
merged 2 commits into from Aug 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions hpx/hpx_main.hpp
Expand Up @@ -20,8 +20,8 @@ namespace hpx_start
// include_libhpx_wrap here is an override for the one present in
// src/hpx_wrap.cpp. The value of this variable defines if we need
// to change the program's entry point or not.
extern bool include_libhpx_wrap;
bool include_libhpx_wrap = true;
HPX_SYMBOL_EXPORT extern bool include_libhpx_wrap;
HPX_SYMBOL_EXPORT bool include_libhpx_wrap = true;
}

#else
Expand Down
20 changes: 20 additions & 0 deletions src/hpx_init.cpp
Expand Up @@ -283,6 +283,17 @@ namespace hpx { namespace detail
}
}}

#if (HPX_HAVE_DYNAMIC_HPX_MAIN != 0) && \
(defined(__linux) || defined(__linux__) || defined(linux))
namespace hpx_start
{
// Importing weak symbol from libhpx_wrap.a which may be shadowed by one present in
// hpx_main.hpp.
HPX_SYMBOL_EXPORT __attribute__((weak)) extern bool include_libhpx_wrap;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need the attribute on the definition only?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we do not need to add attributes twice. I tried to make it clear by adding it twice. I can remove it if you want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NK-Nikunj I'd say either add it everywhere or just for the definition.

}

#endif

///////////////////////////////////////////////////////////////////////////////
namespace hpx
{
Expand Down Expand Up @@ -587,6 +598,15 @@ namespace hpx
// make sure the runtime system is not active yet
if (get_runtime_ptr() != nullptr)
{
// make sure the runtime system is not initialized
// after its activation from int main()
if(hpx_start::include_libhpx_wrap)
{
std::cerr << "hpx is already initialized from main.\n"
"Note: Delete hpx_main.hpp to initialize hpx system "
"using hpx::init. Exiting...\n";
return -1;
}
std::cerr << "hpx::init: can't initialize runtime system "
"more than once! Exiting...\n";
return -1;
Expand Down
4 changes: 2 additions & 2 deletions src/hpx_wrap.cpp
Expand Up @@ -18,8 +18,8 @@ namespace hpx_start
// will change the program's entry point to HPX's own custom entry point
// initialize_main. Subsequent calls before entering main() are handled
// by this code.
extern bool include_libhpx_wrap;
bool include_libhpx_wrap __attribute__((weak)) = false;
HPX_SYMBOL_EXPORT extern bool include_libhpx_wrap;
HPX_SYMBOL_EXPORT bool include_libhpx_wrap __attribute__((weak)) = false;
}

#include <hpx/hpx_init.hpp>
Expand Down