OS X's dyld embarrassingly drops some environment variables it depends on as shown by the dyld-env-drop-test.sh
script next to this note.
This means you cannot wrap your binaries with shims that fixup environment variables, etc. and hope them to inherit any DYLD_*
environment set from another layer of wrapper script.
You must call the binary executables immediately after setting up dyld.
$ ./dyld-env-drop-test.sh
does work: some_random_env_var='foo'
does work: another_random_name='foo'
does work: PATH='foo'
does work: USER='foo'
does work: LOGNAME='foo'
does work: HOME='foo'
does NOT work: DYLD_FRAMEWORK_PATH=''
does NOT work: DYLD_FALLBACK_FRAMEWORK_PATH=''
does NOT work: DYLD_VERSIONED_FRAMEWORK_PATH=''
does NOT work: DYLD_LIBRARY_PATH=''
does NOT work: DYLD_FALLBACK_LIBRARY_PATH=''
does NOT work: DYLD_VERSIONED_LIBRARY_PATH=''
does NOT work: DYLD_PRINT_TO_FILE=''
does NOT work: DYLD_ROOT_PATH=''
does NOT work: DYLD_SHARED_REGION=''
does NOT work: DYLD_INSERT_LIBRARIES=''
does NOT work: DYLD_FORCE_FLAT_NAMESPACE=''
does NOT work: DYLD_IMAGE_SUFFIX=''
does NOT work: DYLD_PRINT_OPTS=''
does NOT work: DYLD_PRINT_ENV=''
does NOT work: DYLD_PRINT_LIBRARIES=''
does NOT work: DYLD_PRINT_LIBRARIES_POST_LAUNCH=''
does NOT work: DYLD_BIND_AT_LAUNCH=''
does NOT work: DYLD_DISABLE_DOFS=''
does NOT work: DYLD_PRINT_APIS=''
does NOT work: DYLD_PRINT_BINDINGS=''
does NOT work: DYLD_PRINT_INITIALIZERS=''
does NOT work: DYLD_PRINT_REBASINGS=''
does NOT work: DYLD_PRINT_SEGMENTS=''
does NOT work: DYLD_PRINT_STATISTICS=''
does NOT work: DYLD_PRINT_DOFS=''
does NOT work: DYLD_PRINT_RPATHS=''
does NOT work: DYLD_SHARED_CACHE_DIR=''
does NOT work: DYLD_SHARED_CACHE_DONT_VALIDATE=''
does NOT work: DYLD_LIBRARY_PATH_=''
does NOT work: DYLD_LIBRARY_bar=''
does NOT work: DYLD_bar=''
does work: DYLDbar='foo'
does work: _DYLD_LIBRARY_PATH='foo'
does work: dyld_library_path='foo'
does work: dyld_bar='foo'
does NOT work: LD_LIBRARY_PATH=''
does work: LD_LIBRARY_PATH_='foo'
does work: LD_LIBRARY_baz='foo'
does work: LD_LIBRARYbaz='foo'
does work: LD_PRELOAD='foo'
does work: LD_PRELOAD_baz='foo'
does work: LD_PRELOAD_='foo'
does work: LD_LIBRARYbaz='foo'
does work: LD_baz='foo'
does work: LDbaz='foo'
does work: _LD_LIBRARY_PATH='foo'
does work: ld_library_path='foo'