Open Bug 578692 Opened 14 years ago Updated 2 years ago

Use @loader_path instead of @executable_path in internal name of dylib

Categories

(NSPR :: NSPR, defect, P2)

x86
macOS

Tracking

(Not tracked)

4.10.2

People

(Reporter: ted, Unassigned)

References

Details

Attachments

(1 file, 1 obsolete file)

OS X 10.4's dyld added support for @loader_path in the internal name of dylibs, which is similar to @executable_path, except that it refers to the directory containing the module that loaded your module, not just the executable. So, for example, if some executable from another directory were linked with libxul, with libxul linked to NSPR, currently things would not load because @executable_path would not contain NSPR. However, if we used @loader_path, NSPR could be loaded because it's located next to libxul.

I'm not sure if we need to support 10.3 or earlier. If so, I can modify this patch to only use @loader_path when targeting 10.4 or newer.
Ted: NSPR dropped support for Mac OS X 10.3 in NSPR 4.8.
Note that the change you proposed is a semantic change.
It is equivalent to the LOAD_WITH_ALTERED_SEARCH_PATH
flag for the LoadLibraryEx Win32 function:
http://msdn.microsoft.com/en-us/library/ms684179(VS.85).aspx

So there is some concern of breaking backward compatibility,
but in most cases I've found the @loader_path sematics to
be more desirable.
Attached patch Use @loader_path (obsolete) — Splinter Review
Apparently I had written the patch to support pre-10.4 anyway and forgotten about it. I can drop that if we don't need it. I agree that it's a semantic change, but it seems likely that @loader_path is the more useful behavior. Also, it's always possible to use install_name_tool to change it after-the-fact, so it shouldn't be hard for consumers to change the behavior.
Assignee: wtc → ted.mielczarek
Status: NEW → ASSIGNED
Attachment #457337 - Flags: review?(wtc)
Comment on attachment 457337 [details] [diff] [review]
Use @loader_path

Thanks for the patch.  Your "Mac OS X >= 10.4" test is incorrect.
You must check the major version as well (it's not guaranteed to
be 10 forever).

Nit: please indent by 4 spaces in nsprpub/configure.in.

You can fix both problems by simply hardcoding @loader_path/$@.
But you're welcome to fix the "Mac OS X >= 10.4" test.
Attachment #457337 - Flags: review?(wtc) → review-
No longer blocks: 557225
Assignee: ted.mielczarek → nobody
Status: ASSIGNED → NEW
attempt at correctly detectign >= 10.4
of course, even with this patch, I can't run tests out of the obj dir:

$ ./obj-x86_64-apple-darwin10.8.0/nsprpub/pr/tests/getai -?
dyld: Library not loaded: @loader_path/libplc4.dylib
  Referenced from: /Users/rstory/src/mozilla/clean-osx/./obj-x86_64-apple-darwin10.8.0/nsprpub/pr/tests/getai
  Reason: image not found
Trace/BPT trap

$ otool -L obj-x86_64-apple-darwin10.8.0/nsprpub/pr/tests/getai
obj-x86_64-apple-darwin10.8.0/nsprpub/pr/tests/getai:
        @loader_path/libplc4.dylib (compatibility version 1.0.0, current version 1.0.0)
        @loader_path/libnspr4.dylib (compatibility version 1.0.0, current version 1.0.0)
        /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 625.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)

but it works if I make a symlink in obj*/dist/bin...
Attachment #457337 - Attachment is obsolete: true
Priority: -- → P2
Target Milestone: --- → 4.10.2
Depends on: 1059504
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: