[lldb] [test] Do not link -ldl on NetBSD
authorMichal Gorny <mgorny@gentoo.org>
Thu, 21 Feb 2019 20:28:21 +0000 (20:28 +0000)
committerMichal Gorny <mgorny@gentoo.org>
Thu, 21 Feb 2019 20:28:21 +0000 (20:28 +0000)
Fix the load_* using test Makefiles not to link -ldl on NetBSD.
There is no such a library on NetBSD, and dlopen() is available
without a library.  Quoting the manpage:

    (These functions are not in a library.  They are included in every
    dynamically linked program automatically.)

To resolve this portably, introduce a new USE_LIBDL option.  If it set
to 1, Makefile.rules automatically appends -ldl on platforms needing it.

Differential Revision: https://reviews.llvm.org/D58517

llvm-svn: 354617

lldb/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile
lldb/packages/Python/lldbsuite/test/functionalities/load_using_paths/Makefile
lldb/packages/Python/lldbsuite/test/make/Makefile.rules

index 0dd9eb4..6574478 100644 (file)
@@ -2,8 +2,9 @@ LEVEL := ../../make
 
 LIB_PREFIX := loadunload_
 
-LD_EXTRAS := -L. -l$(LIB_PREFIX)d -ldl
+LD_EXTRAS := -L. -l$(LIB_PREFIX)d
 CXX_SOURCES := main.cpp
+USE_LIBDL := 1
 
 include $(LEVEL)/Makefile.rules
 
index 6d1ca51..378f5af 100644 (file)
@@ -415,6 +415,15 @@ ifeq (1,$(USE_LIBCPP))
 endif
 
 #----------------------------------------------------------------------
+# Additional system libraries
+#----------------------------------------------------------------------
+ifeq (1,$(USE_LIBDL))
+       ifneq ($(OS),NetBSD)
+               LDFLAGS += -ldl
+       endif
+endif
+
+#----------------------------------------------------------------------
 # dylib settings
 #----------------------------------------------------------------------
 ifneq "$(strip $(DYLIB_C_SOURCES))" ""