dlinfo is not necessarily present if defined(OBJFORMAT_ELF)
Summary
GHC fails to build on OpenBSD complaining about missing dlinfo
. The function is not in any standard and far from ubiquitous.
Genesis
Change 01f5126b introduced loadNativeObj
which is only used in a test in 9.0.1. So far the damage is minimal as I can ignore the offending code and broken test:
--- /usr/ports/pobj/ghc-9.0.0.20201227/ghc-9.0.0.20201227/rts/Linker.c.orig Sun Jan 3 08:56:23 2021
+++ /usr/ports/pobj/ghc-9.0.0.20201227/ghc-9.0.0.20201227/rts/Linker.c Sun Jan 3 09:33:29 2021
@@ -1217,7 +1217,7 @@
void freeObjectCode (ObjectCode *oc)
{
if (oc->type == DYNAMIC_OBJECT) {
-#if defined(OBJFORMAT_ELF)
+#if defined(OBJFORMAT_ELF) && !defined(openbsd_HOST_OS)
ACQUIRE_LOCK(&dl_mutex);
freeNativeCode_ELF(oc);
RELEASE_LOCK(&dl_mutex);
@@ -1929,7 +1929,7 @@
}
-# if defined(OBJFORMAT_ELF)
+# if defined(OBJFORMAT_ELF) && !defined(openbsd_HOST_OS)
static int loadNativeObjCb_(struct dl_phdr_info *info,
size_t _size GNUC3_ATTRIBUTE(__unused__), void *data) {
ObjectCode* nc = (ObjectCode*) data;
@@ -2052,7 +2052,7 @@
void * loadNativeObj (pathchar *path, char **errmsg)
{
-#if defined(OBJFORMAT_ELF)
+#if defined(OBJFORMAT_ELF) && !defined(openbsd_HOST_OS)
ACQUIRE_LOCK(&linker_mutex);
void *r = loadNativeObj_ELF(path, errmsg);
RELEASE_LOCK(&linker_mutex);
Steps to reproduce
Try building ghc 9.0.1 on OpenBSD-amd64.
Expected behavior
Build a working compiler.
Environment
- GHC version used: 8.10.3
Optional:
- Operating System: OpenBSD 6.8
- System Architecture: amd64