diff --git a/Make.inc b/Make.inc index 4eb2e688f8661..5cdabb6374441 100644 --- a/Make.inc +++ b/Make.inc @@ -524,6 +524,36 @@ ifeq (exists, $(shell [ -e $(BUILDROOT)/Make.user ] && echo exists )) include $(BUILDROOT)/Make.user endif +# A bit of a kludge to work around libraries linking to FreeBSD's outdated system libgcc_s +# Instead, let's link to the libgcc_s corresponding to the installation of gfortran +ifeq ($(OS),FreeBSD) +ifneq (,$(findstring gfortran,$(FC))) + +# First let's figure out what version of GCC we're dealing with +_GCCMAJOR := $(shell $(FC) -dumpversion | cut -d'.' -f1) +_GCCMINOR := $(shell $(FC) -dumpversion | cut -d'.' -f2) + +# The ports system uses major and minor for GCC < 5 (e.g. gcc49 for GCC 4.9), otherwise major only +ifeq ($(_GCCMAJOR),4) + _GCCVER := $(_GCCMAJOR)$(_GCCMINOR) +else + _GCCVER := $(_GCCMAJOR) +endif + +# Allow the user to specify this in Make.user +GCCPATH ?= $(LOCALBASE)/lib/gcc$(_GCCVER) + +LDFLAGS += -L$(build_libdir) -L$(GCCPATH) -Wl,-rpath,$(build_libdir) -Wl,-rpath,$(GCCPATH) + +# This ensures we get the right RPATH even if we're missing FFLAGS somewhere +FC += -Wl,-rpath=$(GCCPATH) + +# Build our own libc++ and libc++abi because otherwise /usr/lib/libc++.so and /lib/libcxxrt.so will +# be linked in when building LLVM, and those link to /lib/libgcc_s.so +BUILD_CUSTOM_LIBCXX ?= 1 +endif # gfortran +endif # FreeBSD + ifneq ($(CC_BASE)$(CXX_BASE),$(shell echo $(CC) | cut -d' ' -f1)$(shell echo $(CXX) | cut -d' ' -f1)) $(error Forgot override directive on CC or CXX in Make.user? Cowardly refusing to build) endif diff --git a/deps/libgit2.mk b/deps/libgit2.mk index 129fbe610fa17..11d5bcbee196b 100644 --- a/deps/libgit2.mk +++ b/deps/libgit2.mk @@ -37,11 +37,7 @@ LIBGIT2_OPTS += -DCURL_INCLUDE_DIRS=$(build_includedir) -DCURL_LIBRARIES="-L$(bu endif ifeq ($(OS),Linux) -LIBGIT2_OPTS += -DUSE_OPENSSL=OFF -DUSE_MBEDTLS=ON -DCMAKE_INSTALL_RPATH="\$$ORIGIN" -endif - -ifeq ($(OS),FreeBSD) -LIBGIT2_OPTS += -DCMAKE_INSTALL_RPATH="\$$ORIGIN" +LIBGIT2_OPTS += -DUSE_OPENSSL=OFF -DUSE_MBEDTLS=ON endif # We need to bundle ca certs on linux now that we're using libgit2 with ssl diff --git a/deps/libssh2.mk b/deps/libssh2.mk index 8bbe6dd310dac..ea77379988ac0 100644 --- a/deps/libssh2.mk +++ b/deps/libssh2.mk @@ -20,14 +20,6 @@ else LIBSSH2_OPTS += -DCRYPTO_BACKEND=mbedTLS -DENABLE_ZLIB_COMPRESSION=OFF endif -ifeq ($(OS),Linux) -LIBSSH2_OPTS += -DCMAKE_INSTALL_RPATH="\$$ORIGIN" -endif - -ifeq ($(OS),FreeBSD) -LIBSSH2_OPTS += -DCMAKE_INSTALL_RPATH="\$$ORIGIN" -endif - $(SRCDIR)/srccache/$(LIBSSH2_SRC_DIR)/libssh2-encryptedpem.patch-applied: $(SRCDIR)/srccache/$(LIBSSH2_SRC_DIR)/source-extracted cd $(SRCDIR)/srccache/$(LIBSSH2_SRC_DIR) && patch -p1 -f < $(SRCDIR)/patches/libssh2-encryptedpem.patch echo 1 > $@ diff --git a/deps/llvm.mk b/deps/llvm.mk index 6a8b8ad2ce380..79b5d6f8d4969 100644 --- a/deps/llvm.mk +++ b/deps/llvm.mk @@ -139,6 +139,13 @@ LLVM_CMAKE += -DLLDB_DISABLE_PYTHON=ON endif # LLDB_DISABLE_PYTHON endif # BUILD_LLDB +# Part of the FreeBSD libgcc_s kludge +ifeq ($(OS),FreeBSD) +ifneq ($(GCCPATH),) +LLVM_LDFLAGS += -Wl,-rpath,'\$$ORIGIN',-rpath,$(GCCPATH) +endif +endif + ifneq (,$(filter $(ARCH), powerpc64le ppc64le)) LLVM_CXXFLAGS += -mminimal-toc endif diff --git a/deps/mbedtls.mk b/deps/mbedtls.mk index 4199c947779ab..9ebc0c071dbdd 100644 --- a/deps/mbedtls.mk +++ b/deps/mbedtls.mk @@ -15,14 +15,6 @@ ifeq ($(BUILD_OS),WINNT) MBEDTLS_OPTS += -G"MSYS Makefiles" endif -ifeq ($(OS),Linux) -MBEDTLS_OPTS += -DCMAKE_INSTALL_RPATH="\$$ORIGIN" -endif - -ifeq ($(OS),FreeBSD) -MBEDTLS_OPTS += -DCMAKE_INSTALL_RPATH="\$$ORIGIN" -endif - $(SRCDIR)/srccache/$(MBEDTLS_SRC).tgz: | $(SRCDIR)/srccache $(JLDOWNLOAD) $@ $(MBEDTLS_URL) diff --git a/deps/tools/common.mk b/deps/tools/common.mk index 76c000f904665..edab53c5f7682 100644 --- a/deps/tools/common.mk +++ b/deps/tools/common.mk @@ -40,6 +40,17 @@ CMAKE_COMMON += -DCMAKE_RC_COMPILER="$$(which $(CROSS_COMPILE)windres)" endif endif +ifneq (,$(findstring $(OS),Linux FreeBSD)) +INSTALL_RPATH := "\$$ORIGIN" +# Part of the FreeBSD libgcc_s kludge +ifeq ($(OS),FreeBSD) +ifneq ($(GCCPATH),) +INSTALL_RPATH := "\$$ORIGIN:$(GCCPATH)" +endif +endif +CMAKE_COMMON += -DCMAKE_INSTALL_RPATH=$(INSTALL_RPATH) +endif # Linux or FreeBSD + # For now this is LLVM specific, but I expect it won't be in the future ifeq ($(LLVM_USE_CMAKE),1) ifeq ($(CMAKE_GENERATOR),Ninja)