From bd0f4401deb80eca14a31fce22ed30e64583c965 Mon Sep 17 00:00:00 2001 From: Eugene Kim Date: Tue, 12 Feb 2019 11:28:18 -0800 Subject: [PATCH] =?UTF-8?q?DYLD=5FLIBRARY=5FPATH=20=E2=86=92=20DYLD=5FFALL?= =?UTF-8?q?BACK=5FLIBRARY=5FPATH?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DYLD_LIBRARY_PATH has a “look here first before usual places” semantics, in order to let users use an alternative version of a shared library. On the other side, DYLD_FALLBACK_LIBRARY_PATH has a “look here if not found in usual places” semantics, in order to let users specify additional locations where a shared library is found. In our case, if a binary refers to a common shared library found in usual places, we want to use it; we simply want to specify additional locations where BLS/MCL/OpenSSL libraries are found. So it is more appropriate to use DYLD_FALLBACK_LIBRARY_PATH. This also fixes a nasty symbol table mismatch, which is the main reason for this change: Certain commonly used shared libraries - such as libJPEG.dylib, co-located within the ImageIO framework and expected by the main ImageIO library – are often also found in Homebrew or MacPorts root (/opt/local//lib for MacPort). If DYLD_LIBRARY_PATH included /opt/local/lib for OpenSSL, many system programs linked against ImageIO will erroneously pick up libJPEG.dylib in /opt/local/lib, which lacks certain internal symbols that the framework version has. Using DYLD_FALLBACK_LIBRARY_PATH makes dyld honor the full path to the framework version of libJPEG, which is hardcoded in the main ImageIO framework library. --- README.md | 2 +- scripts/setup_bls_build_flags.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4b315fcd3..983d09bd8 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ export CGO_CFLAGS="-I$GOPATH/src/github.com/harmony-one/bls/include -I$GOPATH/sr export CGO_LDFLAGS="-L$GOPATH/src/github.com/harmony-one/bls/lib -L/usr/local/opt/openssl/lib" export LD_LIBRARY_PATH=$GOPATH/src/github.com/harmony-one/bls/lib:$GOPATH/src/github.com/harmony-one/mcl/lib:/usr/local/opt/openssl/lib export LIBRARY_PATH=$LD_LIBRARY_PATH -export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH +export DYLD_FALLBACK_LIBRARY_PATH=$LD_LIBRARY_PATH mkdir -p $HOME//src/github.com/harmony-one diff --git a/scripts/setup_bls_build_flags.sh b/scripts/setup_bls_build_flags.sh index eb0115c18..c65e9c7f4 100644 --- a/scripts/setup_bls_build_flags.sh +++ b/scripts/setup_bls_build_flags.sh @@ -16,6 +16,6 @@ case $OS in export CGO_CFLAGS="-I${BLS_DIR}/include -I${MCL_DIR}/include -I${OPENSSL_DIR}/include" export CGO_LDFLAGS="-L${BLS_DIR}/lib -L${OPENSSL_DIR}/lib" export LD_LIBRARY_PATH=${BLS_DIR}/lib:${MCL_DIR}/lib:${OPENSSL_DIR}/lib - export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH + export DYLD_FALLBACK_LIBRARY_PATH=$LD_LIBRARY_PATH ;; esac