From fa7cbf82221f81efb59fcba0ed0f80b7a2a2158a Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 17 May 2021 17:08:57 +0000 Subject: [PATCH] Only link with libdl on Linux Linux is (as far as I know) the only mainstream operating system that requires linking with libdl for dlopen. On BSD, libdl doesn't exist, so on non-FreeBSD BSDs linking will currently fail. On macOS, it's apparently just a symlink to libSystem (macOS libc), presumably present for compatibility with things that assume Linux. So the right thing to do here is to only add -ldl on Linux, not to add it for everything that isn't FreeBSD. (cherry picked from commit c57ab1768767ca4f860ce5ca5faf54a7dba4969f) --- src/libexpr/local.mk | 2 +- src/libstore/local.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libexpr/local.mk b/src/libexpr/local.mk index ccd5293e4..00d6d75c1 100644 --- a/src/libexpr/local.mk +++ b/src/libexpr/local.mk @@ -9,7 +9,7 @@ libexpr_SOURCES := $(wildcard $(d)/*.cc) $(wildcard $(d)/primops/*.cc) $(d)/lexe libexpr_LIBS = libutil libstore libexpr_LDFLAGS = -ifneq ($(OS), FreeBSD) +ifeq ($(OS), Linux) libexpr_LDFLAGS += -ldl endif diff --git a/src/libstore/local.mk b/src/libstore/local.mk index d690fea28..bc665f2cb 100644 --- a/src/libstore/local.mk +++ b/src/libstore/local.mk @@ -9,7 +9,7 @@ libstore_SOURCES := $(wildcard $(d)/*.cc $(d)/builtins/*.cc) libstore_LIBS = libutil libstore_LDFLAGS = $(SQLITE3_LIBS) -lbz2 $(LIBCURL_LIBS) $(SODIUM_LIBS) -pthread -ifneq ($(OS), FreeBSD) +ifeq ($(OS), Linux) libstore_LDFLAGS += -ldl endif