# RTLD_DI_ORIGIN is not defined in musl as a result hpx fails to build.
# Closes: https://bugs.gentoo.org/829242
#
# With this PR https://github.com/STEllAR-GROUP/hpx/pull/5947 merged, from
# 1.8.1 we can drop these patches
--- a/libs/core/plugin/include/hpx/plugin/detail/dll_dlopen.hpp
+++ b/libs/core/plugin/include/hpx/plugin/detail/dll_dlopen.hpp
@@ -319,6 +319,7 @@ namespace hpx { namespace util { namespace plugin {
             std::string result;

 #if !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
+#if defined(RTLD_DI_ORIGIN)
             char directory[PATH_MAX] = {'\0'};
             const_cast<dll&>(*this).LoadLibrary(ec);
             if (!ec && ::dlinfo(dll_handle, RTLD_DI_ORIGIN, directory) < 0)
@@ -333,6 +334,9 @@ namespace hpx { namespace util { namespace plugin {
             }
             result = directory;
             ::dlerror();    // Clear the error state.
+#else
+            result = path(dll_name).parent_path().string();
+#endif
 #elif defined(__APPLE__)
             // SO staticfloat's solution
             const_cast<dll&>(*this).LoadLibrary(ec);
