Skip to content

Commit

Permalink
Merge pull request #21788 from JuliaLang/aa/freebsd-gfortran
Browse files Browse the repository at this point in the history
Workaround for FreeBSD linking to outdated system libs
  • Loading branch information
ararslan authored Jun 10, 2017
2 parents f987466 + 78305aa commit 99f7336
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 21 deletions.
30 changes: 30 additions & 0 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions deps/libgit2.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions deps/libssh2.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 > $@
Expand Down
7 changes: 7 additions & 0 deletions deps/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions deps/mbedtls.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 11 additions & 0 deletions deps/tools/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

2 comments on commit 99f7336

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something went wrong when running your job:

NanosoldierError: failed to run benchmarks against primary commit: failed process: Process(`make -j3`, ProcessExited(2)) [2]

Logs and partial data can be found here
cc @jrevels

Please sign in to comment.