pika
pika copied to clipboard
Build breaks on FreeBSD: ld: error: undefined symbol: environ
ld: error: undefined symbol: environ
>>> referenced by unity_0_cxx.cxx
>>> libs/pika/init_runtime/CMakeFiles/pika_init_runtime.dir/Unity/unity_0_cxx.cxx.o:(pika::init(std::__1::function<int (pika::program_options::variables_map&)>, int, char const* const*, pika::init_params const&))
>>> referenced by unity_0_cxx.cxx
>>> libs/pika/init_runtime/CMakeFiles/pika_init_runtime.dir/Unity/unity_0_cxx.cxx.o:(pika::init(std::__1::function<int (int, char**)>, int, char const* const*, pika::init_params const&))
>>> referenced by unity_0_cxx.cxx
>>> libs/pika/init_runtime/CMakeFiles/pika_init_runtime.dir/Unity/unity_0_cxx.cxx.o:(pika::init(std::__1::function<int ()>, int, char const* const*, pika::init_params const&))
>>> referenced 5 more times
Version: 0.14.0 FreeBSD 13.1
In other projects this was worked around like this:
-extern char** environ;
+//extern char** environ; // this is broken on FreeBSD, see https://reviews.freebsd.org/D30842
+#include <dlfcn.h>
+static char*** environ_ptr = (char***)dlsym(RTLD_DEFAULT, "environ"); // workaround for the above
and then
- execve (argv[0], (char**) argv, environ);
+ execve (argv[0], (char**) argv, *environ_ptr);
Thanks @yurivict.
Do you know if this is broken temporarily or "permanently" (meaning there is no plan to fix it so that the old code still works)? Do you know if this needs to be done conditionally or can the dlsym
version always be used? Would be willing to provide a PR to fix this?
The 'environ' bug is there semi-permanently. People suggested several patches but they were rejected for some reasons.
AFAIK the dlsym approach should always work.