From cbc177ca013ff9d87b36074eab9de6261f37bdaf Mon Sep 17 00:00:00 2001 From: Manuel Jacob Date: Fri, 2 Oct 2015 13:36:27 +0200 Subject: [PATCH 1/5] Use pkg-config-provided LDFLAGS for libsqlite3 and libcurl. Previously, pkg-config was already queried for libsqlite3's and libcurl's link flags. However they were not used, but hardcoded instead. This commit replaces the hardcoded LDFLAGS by the ones provided by pkg-config in a similar pattern as already used for libsodium. --- Makefile.config.in | 2 ++ src/libstore/local.mk | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile.config.in b/Makefile.config.in index 29ccc1b14..5a907b35f 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -5,10 +5,12 @@ CXX = @CXX@ CXXFLAGS = @CXXFLAGS@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_SODIUM = @HAVE_SODIUM@ +LIBCURL_LIBS = @LIBCURL_LIBS@ OPENSSL_LIBS = @OPENSSL_LIBS@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ SODIUM_LIBS = @SODIUM_LIBS@ +SQLITE3_LIBS = @SQLITE3_LIBS@ bash = @bash@ bindir = @bindir@ bsddiff_compat_include = @bsddiff_compat_include@ diff --git a/src/libstore/local.mk b/src/libstore/local.mk index bf5c256c9..08460dceb 100644 --- a/src/libstore/local.mk +++ b/src/libstore/local.mk @@ -8,7 +8,7 @@ libstore_SOURCES := $(wildcard $(d)/*.cc) libstore_LIBS = libutil libformat -libstore_LDFLAGS = -lsqlite3 -lbz2 -lcurl +libstore_LDFLAGS = $(SQLITE3_LIBS) -lbz2 $(LIBCURL_LIBS) ifeq ($(OS), SunOS) libstore_LDFLAGS += -lsocket From c999ef70e807e672d58aa7e30af62ed8492bc2c2 Mon Sep 17 00:00:00 2001 From: Manuel Jacob Date: Fri, 2 Oct 2015 14:19:00 +0200 Subject: [PATCH 2/5] Don't pass "--no-copy-dt-needed-entries" option to linker on FreeBSD. Eventually the nested if statements should be replaced by a more general condition, but this is sufficient to make it work on FreeBSD. --- mk/lib.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mk/lib.mk b/mk/lib.mk index 4ad5c636c..bb82801d3 100644 --- a/mk/lib.mk +++ b/mk/lib.mk @@ -61,7 +61,9 @@ ifeq ($(BUILD_SHARED_LIBS), 1) endif ifneq ($(OS), Darwin) ifneq ($(OS), SunOS) - GLOBAL_LDFLAGS += -Wl,--no-copy-dt-needed-entries + ifneq ($(OS), FreeBSD) + GLOBAL_LDFLAGS += -Wl,--no-copy-dt-needed-entries + endif endif endif SET_RPATH_TO_LIBS ?= 1 From 12c1776df9c1e658c614cfd5b2cf398dc7202689 Mon Sep 17 00:00:00 2001 From: Manuel Jacob Date: Fri, 2 Oct 2015 15:35:33 +0200 Subject: [PATCH 3/5] Don't try to link libdl on FreeBSD. There is no libdl on FreeBSD. Instead the symbols are included in libc. --- src/libexpr/local.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libexpr/local.mk b/src/libexpr/local.mk index d1b1987fb..5de9ccc6d 100644 --- a/src/libexpr/local.mk +++ b/src/libexpr/local.mk @@ -10,7 +10,10 @@ libexpr_CXXFLAGS := -Wno-deprecated-register libexpr_LIBS = libutil libstore libformat -libexpr_LDFLAGS = -ldl +libexpr_LDFLAGS = +ifneq ($(OS), FreeBSD) + libexpr_LDFLAGS += -ldl +endif # The dependency on libgc must be propagated (i.e. meaning that # programs/libraries that use libexpr must explicitly pass -lgc), From 7888b2ba15528a7caa24f6923203a55cc38087ed Mon Sep 17 00:00:00 2001 From: Manuel Jacob Date: Sun, 4 Oct 2015 13:53:23 +0200 Subject: [PATCH 4/5] Define SOL_LOCAL if not defined already (e.g. on FreeBSD). Some evidence that defining it to be 0 is right: * OS X headers define it to be 0. * Other code uses 0 instead of SOL_LOCAL to check for peer credentials (e.g. FreeBSD's implementation of getpeereid). --- src/nix-daemon/nix-daemon.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc index aaae691e9..1d0ff701f 100644 --- a/src/nix-daemon/nix-daemon.cc +++ b/src/nix-daemon/nix-daemon.cc @@ -692,6 +692,10 @@ static PeerInfo getPeerInfo(int remote) #elif defined(LOCAL_PEERCRED) +#if !defined(SOL_LOCAL) +#define SOL_LOCAL 0 +#endif + xucred cred; socklen_t credLen = sizeof(cred); if (getsockopt(remote, SOL_LOCAL, LOCAL_PEERCRED, &cred, &credLen) == -1) From 8a74a125bc3ac7a8273b8a1be8f0774a664900af Mon Sep 17 00:00:00 2001 From: janus Date: Tue, 17 Nov 2015 14:16:08 +0000 Subject: [PATCH 5/5] FreeBSD can build Linux 32-bit binaries --- src/libstore/build.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 3adad662d..4809a5a57 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1251,6 +1251,8 @@ static bool canBuildLocally(const string & platform) #if __linux__ || (platform == "i686-linux" && settings.thisSystem == "x86_64-linux") #endif + || (platform == "i686-linux" && settings.thisSystem == "x86_64-freebsd") + || (platform == "i686-linux" && settings.thisSystem == "i686-freebsd") ; }