diff --git a/libphobos/configure b/libphobos/configure index fe7cd9c11ff5357c937d354d9e087e6c74c5694f..2c0f57cef031b322fa6d80c02d1ff4a238a66ee9 100755 --- a/libphobos/configure +++ b/libphobos/configure @@ -14917,7 +14917,7 @@ fi DCFG_HAVE_LIBATOMIC=false LIBATOMIC= - if test "x$with_libatomic" != "xno"; then : + if test "x$enable_libatomic" != "xno" && test "x$with_libatomic" != "xno"; then : DCFG_HAVE_LIBATOMIC=true LIBATOMIC=../../libatomic/libatomic_convenience.la @@ -14953,7 +14953,7 @@ if test "${with_libbacktrace+set}" = set; then : fi - if test "x$with_libbacktrace" != "xno"; then : + if test "x$enable_libbacktrace" != "xno" && test "x$with_libbacktrace" != "xno"; then : LIBBACKTRACE=../../libbacktrace/libbacktrace.la diff --git a/libphobos/libdruntime/config/common/threadasm.S b/libphobos/libdruntime/config/common/threadasm.S index 1e9bc760527d15c1fe922cf877ebe7cfef4d41b1..35462170e585798dfef45c4311467f301c1d2069 100644 --- a/libphobos/libdruntime/config/common/threadasm.S +++ b/libphobos/libdruntime/config/common/threadasm.S @@ -22,7 +22,7 @@ a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ -#if (__linux__ || __FreeBSD__ || __NetBSD__ || __DragonFly__) && __ELF__ +#if (__linux__ || __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__) && __ELF__ /* * Mark the resulting object file as not requiring execution permissions on * stack memory. The absence of this section would mark the whole resulting diff --git a/libphobos/libdruntime/gcc/backtrace.d b/libphobos/libdruntime/gcc/backtrace.d index 45dd011dc63802624fb909f88f5b85c281acf0e3..8f5582d746990146edd5b24fb4ccaacd88def62e 100644 --- a/libphobos/libdruntime/gcc/backtrace.d +++ b/libphobos/libdruntime/gcc/backtrace.d @@ -424,8 +424,10 @@ private: import core.sys.freebsd.dlfcn; else version (NetBSD) import core.sys.netbsd.dlfcn; + else version (OpenBSD) + import core.sys.openbsd.dlfcn; else version (Solaris) - import core.sys.netbsd.dlfcn; + import core.sys.solaris.dlfcn; else version (Posix) import core.sys.posix.dlfcn; diff --git a/libphobos/libdruntime/gcc/sections/elf.d b/libphobos/libdruntime/gcc/sections/elf.d index 8450aecb239feb6c22de415e659b9f868938c7b6..3480fb9474c472a9d242b590cf5dfc2a5c1d18e8 100644 --- a/libphobos/libdruntime/gcc/sections/elf.d +++ b/libphobos/libdruntime/gcc/sections/elf.d @@ -33,6 +33,7 @@ version (CRuntime_Glibc) enum SharedELF = true; else version (CRuntime_Musl) enum SharedELF = true; else version (FreeBSD) enum SharedELF = true; else version (NetBSD) enum SharedELF = true; +else version (OpenBSD) enum SharedELF = true; else version (DragonFlyBSD) enum SharedELF = true; else version (CRuntime_UClibc) enum SharedELF = true; else version (Solaris) enum SharedELF = true; @@ -62,6 +63,12 @@ else version (NetBSD) import core.sys.netbsd.sys.elf; import core.sys.netbsd.sys.link_elf; } +else version (OpenBSD) +{ + import core.sys.openbsd.dlfcn; + import core.sys.openbsd.sys.elf; + import core.sys.openbsd.sys.link_elf; +} else version (DragonFlyBSD) { import core.sys.dragonflybsd.dlfcn; @@ -688,20 +695,22 @@ version (Shared) @nogc nothrow: link_map* linkMapForHandle(void* handle) { - link_map* map; - const success = dlinfo(handle, RTLD_DI_LINKMAP, &map) == 0; - safeAssert(success, "Failed to get DSO info."); - return map; + static if (__traits(compiles, RTLD_DI_LINKMAP)) + { + link_map* map; + const success = dlinfo(handle, RTLD_DI_LINKMAP, &map) == 0; + safeAssert(success, "Failed to get DSO info."); + return map; + } + else version (OpenBSD) + { + safeAssert(handle !is null, "Failed to get DSO info."); + return cast(link_map*)handle; + } + else + static assert(0, "unimplemented"); } - link_map* exeLinkMap(link_map* map) - { - safeAssert(map !is null, "Invalid link_map."); - while (map.l_prev !is null) - map = map.l_prev; - return map; - } - DSO* dsoForHandle(void* handle) { DSO* pdso; @@ -766,6 +775,8 @@ version (Shared) strtab = cast(const(char)*)(info.dlpi_addr + dyn.d_un.d_ptr); // relocate else version (NetBSD) strtab = cast(const(char)*)(info.dlpi_addr + dyn.d_un.d_ptr); // relocate + else version (OpenBSD) + strtab = cast(const(char)*)(info.dlpi_addr + dyn.d_un.d_ptr); // relocate else version (DragonFlyBSD) strtab = cast(const(char)*)(info.dlpi_addr + dyn.d_un.d_ptr); // relocate else version (Solaris) @@ -795,9 +806,21 @@ version (Shared) void* handleForName(const char* name) { - auto handle = .dlopen(name, RTLD_NOLOAD | RTLD_LAZY); - version (Solaris) { } - else if (handle !is null) .dlclose(handle); // drop reference count + version (Solaris) enum refCounted = false; + else version (OpenBSD) enum refCounted = false; + else enum refCounted = true; + + static if (__traits(compiles, RTLD_NOLOAD)) + enum flags = (RTLD_NOLOAD | RTLD_LAZY); + else + enum flags = RTLD_LAZY; + + auto handle = .dlopen(name, flags); + static if (refCounted) + { + if (handle !is null) + .dlclose(handle); // drop reference count + } return handle; } } @@ -891,6 +914,7 @@ bool findDSOInfoForAddr(in void* addr, dl_phdr_info* result=null) nothrow @nogc { version (linux) enum IterateManually = true; else version (NetBSD) enum IterateManually = true; + else version (OpenBSD) enum IterateManually = true; else version (Solaris) enum IterateManually = true; else enum IterateManually = false; diff --git a/libphobos/libdruntime/gcc/sections/package.d b/libphobos/libdruntime/gcc/sections/package.d index 4c2b542df2386d00eceb44ddb34b34aba355ba0d..1e887cdcb8ffdd0b514df5f23447115f7c1cc8b7 100644 --- a/libphobos/libdruntime/gcc/sections/package.d +++ b/libphobos/libdruntime/gcc/sections/package.d @@ -27,6 +27,7 @@ version (CRuntime_Musl) version = SectionsElf; version (CRuntime_UClibc) version = SectionsElf; version (FreeBSD) version = SectionsElf; version (NetBSD) version = SectionsElf; +version (OpenBSD) version = SectionsElf; version (DragonFlyBSD) version = SectionsElf; version (Solaris) version = SectionsElf; version (OSX) version = SectionsMacho; diff --git a/libphobos/m4/druntime/libraries.m4 b/libphobos/m4/druntime/libraries.m4 index 743d3e3e17c776ff540d0010097c62f5ba70eab5..45a56f6f76a791fa58920ca9f3f4ee7b79a877bc 100644 --- a/libphobos/m4/druntime/libraries.m4 +++ b/libphobos/m4/druntime/libraries.m4 @@ -116,7 +116,7 @@ AC_DEFUN([DRUNTIME_LIBRARIES_ATOMIC], DCFG_HAVE_LIBATOMIC=false LIBATOMIC= - AS_IF([test "x$with_libatomic" != "xno"], [ + AS_IF([test "x$enable_libatomic" != "xno" && test "x$with_libatomic" != "xno"], [ DCFG_HAVE_LIBATOMIC=true LIBATOMIC=../../libatomic/libatomic_convenience.la ], [ @@ -145,7 +145,7 @@ AC_DEFUN([DRUNTIME_LIBRARIES_BACKTRACE], AS_HELP_STRING([--without-libbacktrace], [Do not use libbacktrace in core.runtime (default: auto)])) - AS_IF([test "x$with_libbacktrace" != "xno"], [ + AS_IF([test "x$enable_libbacktrace" != "xno" && test "x$with_libbacktrace" != "xno"], [ LIBBACKTRACE=../../libbacktrace/libbacktrace.la gdc_save_CPPFLAGS=$CPPFLAGS