Skip to content

Commit

Permalink
Merge #6317
Browse files Browse the repository at this point in the history
6317: Fixing linker problem on FreeBSD r=hkaiser a=hkaiser

Fixes #6316

Co-authored-by: Hartmut Kaiser <hartmut.kaiser@gmail.com>
  • Loading branch information
StellarBot and hkaiser committed Aug 7, 2023
2 parents 8c699d1 + 4a61c0b commit e7c31a4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
19 changes: 10 additions & 9 deletions libs/full/init_runtime/include/hpx/hpx_init_impl.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2018 Mikael Simberg
// Copyright (c) 2007-2022 Hartmut Kaiser
// Copyright (c) 2007-2023 Hartmut Kaiser
// Copyright (c) 2011 Bryce Lelbach
//
// SPDX-License-Identifier: BSL-1.0
Expand All @@ -9,6 +9,7 @@
#pragma once

#include <hpx/assert.hpp>
#include <hpx/debugging/environ.hpp>
#include <hpx/functional/bind_back.hpp>
#include <hpx/functional/function.hpp>
#include <hpx/hpx_init.hpp>
Expand All @@ -26,8 +27,7 @@
#include <utility>

#if defined(__FreeBSD__)
extern HPX_EXPORT char** freebsd_environ;
extern char** environ;
extern char** environ; // available in executables only
#endif

#if defined(HPX_WINDOWS) && defined(HPX_HAVE_APEX)
Expand Down Expand Up @@ -56,7 +56,8 @@ namespace hpx {
inline int init(std::function<int(hpx::program_options::variables_map&)> f,
int argc, char** argv, init_params const& params)
{
return detail::init_impl(HPX_MOVE(f), argc, argv, params, HPX_PREFIX);
return detail::init_impl(
HPX_MOVE(f), argc, argv, params, HPX_PREFIX, environ);
}

/// \brief Main entry point for launching the HPX runtime system.
Expand All @@ -71,7 +72,7 @@ namespace hpx {
std::function<int(hpx::program_options::variables_map&)> main_f =
hpx::bind_back(detail::init_helper, HPX_MOVE(f));
return detail::init_impl(
HPX_MOVE(main_f), argc, argv, params, HPX_PREFIX);
HPX_MOVE(main_f), argc, argv, params, HPX_PREFIX, environ);
}

/// \brief Main entry point for launching the HPX runtime system.
Expand All @@ -82,8 +83,8 @@ namespace hpx {
/// function given by \p f as a HPX thread.
inline int init(int argc, char** argv, init_params const& params)
{
return detail::init_impl(
hpx_startup::get_main_func(), argc, argv, params, HPX_PREFIX);
return detail::init_impl(hpx_startup::get_main_func(), argc, argv,
params, HPX_PREFIX, environ);
}

/// \brief Main entry point for launching the HPX runtime system.
Expand All @@ -97,7 +98,7 @@ namespace hpx {
{
hpx::function<int(hpx::program_options::variables_map&)> main_f;
return detail::init_impl(
HPX_MOVE(main_f), argc, argv, params, HPX_PREFIX);
HPX_MOVE(main_f), argc, argv, params, HPX_PREFIX, environ);
}

/// \brief Main entry point for launching the HPX runtime system.
Expand All @@ -109,6 +110,6 @@ namespace hpx {
{
return detail::init_impl(hpx_startup::get_main_func(),
hpx::local::detail::dummy_argc, hpx::local::detail::dummy_argv,
params, HPX_PREFIX);
params, HPX_PREFIX, environ);
}
} // namespace hpx
19 changes: 10 additions & 9 deletions libs/full/init_runtime/include/hpx/hpx_start_impl.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2018 Mikael Simberg
// Copyright (c) 2007-2022 Hartmut Kaiser
// Copyright (c) 2007-2023 Hartmut Kaiser
//
// SPDX-License-Identifier: BSL-1.0
// Distributed under the Boost Software License, Version 1.0. (See accompanying
Expand All @@ -8,6 +8,7 @@
#pragma once

#include <hpx/assert.hpp>
#include <hpx/debugging/environ.hpp>
#include <hpx/functional/bind_back.hpp>
#include <hpx/functional/function.hpp>
#include <hpx/hpx_start.hpp>
Expand All @@ -24,8 +25,7 @@
#include <utility>

#if defined(__FreeBSD__)
extern HPX_EXPORT char** freebsd_environ;
extern char** environ;
extern char** environ; // available in executables only
#endif

#if defined(HPX_WINDOWS) && defined(HPX_HAVE_APEX)
Expand Down Expand Up @@ -57,7 +57,8 @@ namespace hpx {
std::function<int(hpx::program_options::variables_map&)> f, int argc,
char** argv, init_params const& params)
{
return detail::start_impl(HPX_MOVE(f), argc, argv, params, HPX_PREFIX);
return detail::start_impl(
HPX_MOVE(f), argc, argv, params, HPX_PREFIX, environ);
}

/// \brief Main non-blocking entry point for launching the HPX runtime system.
Expand All @@ -74,7 +75,7 @@ namespace hpx {
hpx::function<int(hpx::program_options::variables_map&)> main_f =
hpx::bind_back(detail::init_helper, HPX_MOVE(f));
return detail::start_impl(
HPX_MOVE(main_f), argc, argv, params, HPX_PREFIX);
HPX_MOVE(main_f), argc, argv, params, HPX_PREFIX, environ);
}

/// \brief Main non-blocking entry point for launching the HPX runtime system.
Expand All @@ -87,8 +88,8 @@ namespace hpx {
/// with the runtime system's execution.
inline bool start(int argc, char** argv, init_params const& params)
{
return detail::start_impl(
hpx_startup::get_main_func(), argc, argv, params, HPX_PREFIX);
return detail::start_impl(hpx_startup::get_main_func(), argc, argv,
params, HPX_PREFIX, environ);
}

/// \brief Main non-blocking entry point for launching the HPX runtime system.
Expand All @@ -104,7 +105,7 @@ namespace hpx {
{
hpx::function<int(hpx::program_options::variables_map&)> main_f;
return detail::start_impl(
HPX_MOVE(main_f), argc, argv, params, HPX_PREFIX);
HPX_MOVE(main_f), argc, argv, params, HPX_PREFIX, environ);
}

/// \brief Main non-blocking entry point for launching the HPX runtime system.
Expand All @@ -119,6 +120,6 @@ namespace hpx {
{
return detail::start_impl(hpx_startup::get_main_func(),
hpx::local::detail::dummy_argc, hpx::local::detail::dummy_argv,
params, HPX_PREFIX);
params, HPX_PREFIX, environ);
}
} // namespace hpx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ namespace hpx {
HPX_EXPORT int init_impl(
hpx::function<int(hpx::program_options::variables_map&)> const& f,
int argc, char** argv, init_params const& params,
char const* hpx_prefix);
char const* hpx_prefix, char** env);

HPX_EXPORT bool start_impl(
hpx::function<int(hpx::program_options::variables_map&)> const& f,
int argc, char** argv, init_params const& params,
char const* hpx_prefix);
char const* hpx_prefix, char** env);
} // namespace detail
/// \endcond
} // namespace hpx
10 changes: 5 additions & 5 deletions libs/full/init_runtime/src/hpx_init.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2007-2022 Hartmut Kaiser
// Copyright (c) 2007-2023 Hartmut Kaiser
// Copyright (c) 2017 Shoshana Jakobovits
// Copyright (c) 2010-2011 Phillip LeBlanc, Dylan Stark
// Copyright (c) 2011 Bryce Lelbach
Expand Down Expand Up @@ -109,7 +109,7 @@ namespace hpx::detail {
int init_impl(
hpx::function<int(hpx::program_options::variables_map&)> const& f,
int argc, char** argv, init_params const& params,
char const* hpx_prefix)
char const* hpx_prefix, [[maybe_unused]] char** env)
{
if (argc == 0 || argv == nullptr)
{
Expand All @@ -127,7 +127,7 @@ namespace hpx::detail {
#endif
util::set_hpx_prefix(hpx_prefix);
#if defined(__FreeBSD__)
freebsd_environ = environ;
freebsd_environ = env;
#endif
// set a handler for std::abort, std::at_quick_exit, and std::atexit
std::signal(SIGABRT, detail::on_abort);
Expand All @@ -142,7 +142,7 @@ namespace hpx::detail {
bool start_impl(
hpx::function<int(hpx::program_options::variables_map&)> const& f,
int argc, char** argv, init_params const& params,
char const* hpx_prefix)
char const* hpx_prefix, [[maybe_unused]] char** env)
{
if (argc == 0 || argv == nullptr)
{
Expand All @@ -160,7 +160,7 @@ namespace hpx::detail {
#endif
util::set_hpx_prefix(hpx_prefix);
#if defined(__FreeBSD__)
freebsd_environ = environ;
freebsd_environ = env;
#endif
// set a handler for std::abort, std::at_quick_exit, and std::atexit
std::signal(SIGABRT, detail::on_abort);
Expand Down

0 comments on commit e7c31a4

Please sign in to comment.