diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 29474c282a8b175af079a555d0576c2993bf5b36..664a745b955182aaf1ffc39cdcee7be16067b7df 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ include: - file: .gitlab-ci.yml - project: fsl/fsl-ci-rules + project: fsl/conda/fsl-ci-rules stages: - test diff --git a/CHANGELOG.md b/CHANGELOG.md index de107b4221cef585996fb5e3ac31acba6ee4e464..2a8f79c1179bd105dca256118325855e90de25a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # FSL base project changelog +## 2111.0 (Thursday 11th November 2021) + + - The `rpath` is explicitly set on executables and shared libraries, + and the `install_name` set on shared libraries under macOS. This + is to support local development, and execution of commands from + their `$FSLDIR/src/` directory. + ## 2109.1 (Wednesday 22nd September 2021) diff --git a/config/buildSettings.mk b/config/buildSettings.mk index e74b761e9ed6d6e45bbb5bf123347eeb1b09a905..885008126d2c6455acfbc7cab933a03cf8faaf86 100644 --- a/config/buildSettings.mk +++ b/config/buildSettings.mk @@ -77,6 +77,22 @@ ARCHNVCCLDFLAGS = # macOS. # ##################################################################### + +# Drop -rpath flags from LDFLAGS if it is +# set in the environment - we explicitly +# add them below such that executables +# will be able to find libs in $(pwd) and +# in $FSLDIR/lib *in that order*. This is +# so that executables located in the +# project source dir can be executed in +# place with sensible behaviour (i.e. any +# shared libs located in the same dir will +# take precedence over libs of the same +# name in $FSLDIR/lib/). +COMMA := , +_LDFLAGS := $(patsubst -Wl${COMMA}-rpath%,,${LDFLAGS}) +LDFLAGS = ${_LDFLAGS} + ifeq ($(SYSTYPE), Darwin) # CC, CXX, CFLAGS, CXXFLAGS, and LDFLAGS @@ -85,8 +101,20 @@ ifeq ($(SYSTYPE), Darwin) CXX ?= clang++ CFLAGS ?= -arch x86_64 -Wall -pedantic CXXFLAGS ?= -arch x86_64 -Wall -pedantic - LDFLAGS ?= -Wl,-search_paths_first + LDFLAGS += -Wl,-rpath,"@executable_path/" \ + -Wl,-rpath,"${FSLDIR}/lib" ARCHLIBS += -llapack -lblas -lz -lm + + # On macOS, we need to change the install + # name of shared libs so that they can be + # looked up according to the rpath of + # executables that depend on them. Note + # that we give shared libs a suffix of + # .so (not .dylib) on both linux and + # macOS. + ifeq ($(patsubst %.so,,$@),) + LDFLAGS += -Wl,-install_name,@rpath/$@ + endif endif ##################################################################### @@ -105,9 +133,8 @@ ifeq ($(SYSTYPE), Linux) -Wall -pedantic -Wno-long-long CXXFLAGS ?= -fexpensive-optimizations \ -Wall -pedantic -Wno-long-long - # TODO add extra rpath here to - # support local development? - LDFLAGS ?= -Wl,-rpath,'$$ORIGIN/../lib' + LDFLAGS += -Wl,-rpath,'$$ORIGIN:${FSLDIR}/lib' \ + -Wl,-rpath-link,'$$ORIGIN:${FSLDIR}/lib' ARCHLIBS += -lopenblas -lz -lm endif