ENH: reimplement Foam::dlOpen() for macOS (#2801)

- The Apple SIP (System Integrity Protection) clears environment
  variables, which affects the behaviour of dynamic library loading
  (the DYLD_LIBRARY_PATH env variable).

  OpenFOAM shadows this variable as FOAM_LD_LIBRARY_PATH, which has
  been used to restore DYLD_LIBRARY_PATH (eg, in RunFunctions script).

  However, this solution is not quite complete, as it
    (a) requires sourcing of RunFunctions file,
    (b) additional errors appear depending on a user workflow.

  This changeset alleviates the problem by also iterating through
  paths stored in the shadow variable when loading dynamic libraries
  (if the DYLD_LIBRARY_PATH is empty).
This commit is contained in:
Alexey Matveichev
2023-06-14 10:45:45 +02:00
committed by Mark Olesen
parent 83b1ebee6f
commit f584ec97d0
3 changed files with 54 additions and 27 deletions

View File

@ -23,13 +23,6 @@
# If dispatching via foamExec
foamExec="$WM_PROJECT_DIR/bin/tools/foamExec"
# Darwin workaround - SIP clearing DYLD_LIBRARY_PATH variable
if [ -n "$FOAM_LD_LIBRARY_PATH" ] && [ -z "$DYLD_LIBRARY_PATH" ]
then
export DYLD_LIBRARY_PATH="$FOAM_LD_LIBRARY_PATH"
fi
#------------------------------------------------------------------------------
usage() {