From a218b814196983e00c19c3bca8f8dc9698334a13 Mon Sep 17 00:00:00 2001 From: Mohammad Akhlaghi Date: Tue, 4 Dec 2018 20:42:56 +0000 Subject: Shared library absolute address fixed in Libgit2 and WCSLIB on Mac OS The build systems of Libgit2 and WCSLIB on Mac OS does not account for installation in non-standard addresses: `Libgit2' keeps the absolute address of its build directory (not the installation directory) and WCSLIB doesn't write any absolute address at all (so the system uses the first one it finds). To address these issues, we are now using Mac OS's `install_name_tool' program to fix the absolute path within the installed shared library. Since the version of the library is actually present in its shared library name, in `dependency-versions.mk' we have also separated these two libraries so later when their version is changed, we are careful in correcting the shared library name also. --- reproduce/src/make/dependencies-basic.mk | 3 +- reproduce/src/make/dependencies.mk | 73 +++++++++++++++++++++++--------- 2 files changed, 54 insertions(+), 22 deletions(-) (limited to 'reproduce/src') diff --git a/reproduce/src/make/dependencies-basic.mk b/reproduce/src/make/dependencies-basic.mk index b007778..bedf0a0 100644 --- a/reproduce/src/make/dependencies-basic.mk +++ b/reproduce/src/make/dependencies-basic.mk @@ -208,8 +208,9 @@ $(ibdir)/low-level-links: | $(ibdir) $(ildir) $(call makelink,ps) $(call makelink,ranlib) - # Mac OS information (used by TeX Live). + # Mac OS specific $(call makelink,sw_vers) + $(call makelink,install_name_tool) # On Mac OS, libtool is different compared to GNU Libtool. The # libtool we'll build in the high-level dependencies has the diff --git a/reproduce/src/make/dependencies.mk b/reproduce/src/make/dependencies.mk index e309473..24f42a9 100644 --- a/reproduce/src/make/dependencies.mk +++ b/reproduce/src/make/dependencies.mk @@ -188,23 +188,6 @@ $(ilidir)/cfitsio: $(tdir)/cfitsio-$(cfitsio-version).tar.gz \ --enable-sse2 --enable-reentrant) \ && echo "CFITSIO is built" > $@ - -# The libgit2 page recommends doing a static build, especially for Mac -# systems (with `-DBUILD_SHARED_LIBS=OFF'). Under XCode, the following link -# has written "It’s highly recommended that you build libgit2 as a static -# library for Xcode projects. This simplifies distribution significantly, -# as the resolution of dynamic libraries at runtime can be extremely -# problematic.". This is a major problem we have been having so far with -# Mac systems: https://libgit2.org/docs/guides/build-and-link -$(ilidir)/libgit2: $(tdir)/libgit2-$(libgit2-version).tar.gz \ - $(ibdir)/cmake \ - $(ibdir)/curl - export LDFLAGS="$$LDFLAGS -lssl -lcrypto -lz"; \ - $(call cbuild, $<, libgit2-$(libgit2-version), static, \ - -DUSE_SSH=OFF -DBUILD_CLAR=OFF \ - -DTHREADSAFE=ON ) \ - && echo "Libgit2 is built" > $@ - $(ilidir)/gsl: $(tdir)/gsl-$(gsl-version).tar.gz $(call gbuild, $<, gsl-$(gsl-version), static) \ && echo "GNU Scientific Library is built" > $@ @@ -217,20 +200,68 @@ $(ilidir)/libtiff: $(tdir)/tiff-$(libtiff-version).tar.gz \ $(call gbuild, $<, tiff-$(libtiff-version), static) \ && echo "Libtiff is built" > $@ + + + + +# Libraries with special attention on Mac OS +# ------------------------------------------ +# +# Libgit2 and WCSLIB don't set their installation path, or don't do it +# properly, in their finally installed shared libraries. But since we are +# linking everything (including OpenSSL and its dependencies) dynamically, +# we need to also make a shared libraries and can't use static +# libraries. So for Mac OS systems we have to correct their addresses +# manually. +# +# For example, Libgit2 page recommends doing a static build, especially for +# Mac systems (with `-DBUILD_SHARED_LIBS=OFF'): "It’s highly recommended +# that you build libgit2 as a static library for Xcode projects. This +# simplifies distribution significantly, as the resolution of dynamic +# libraries at runtime can be extremely problematic.". This is a major +# problem we have been having so far with Mac systems: +# https://libgit2.org/docs/guides/build-and-link +$(ilidir)/libgit2: $(tdir)/libgit2-$(libgit2-version).tar.gz \ + $(ibdir)/cmake \ + $(ibdir)/curl + # Build and install the library. + $(call cbuild, $<, libgit2-$(libgit2-version), static, \ + -DUSE_SSH=OFF -DBUILD_CLAR=OFF \ + -DTHREADSAFE=ON ) + + # The builders didn't set the shared library name (ID) for Mac OS + # systems. So we'll have to fix it manually. + if [ x$(on_mac_os) = xyes ]; then + install_name_tool -id $(ildir)/libgit2.26.dylib + $(ildir)/libgit2.26.dylib + fi + + # Write the target file. + echo "Libgit2 is built" > $@ + $(ilidir)/wcslib: $(tdir)/wcslib-$(wcslib-version).tar.bz2 \ $(ilidir)/cfitsio - # Unfortunately WCSLIB forces the building of shared libraries. So - # we'll just delete any shared library that is produced afterwards. - $(call gbuild, $<, wcslib-$(wcslib-version), , \ + # Build and install the library. + $(call gbuild, $<, wcslib-$(wcslib-version), , \ LIBS="-pthread -lcurl -lssl -lcrypto -lz -lm" \ --with-cfitsiolib=$(ildir) \ --with-cfitsioinc=$(idir)/include \ - --without-pgplot --disable-fortran) && \ + --without-pgplot --disable-fortran) + + # The builders didn't set the shared library name (ID) for Mac OS + # systems. So we'll have to fix it manually. + if [ x$(on_mac_os) = xyes ]; then + install_name_tool -id $(ildir)/libwcs.6.2.dylib + $(ildir)/libwcs.6.2.dylib; + fi + + # Write the target file. echo "WCSLIB is built" > $@ + # Programs # -------- # -- cgit v1.2.1