Closed Bug 1379536 Opened 9 years ago Closed 9 years ago

Standalone SpiderMonkey should not use @executable_path in install_name on macOS

Categories

(Core :: JavaScript Engine, defect)

52 Branch
All
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox-esr52 --- fixed
firefox57 --- fixed

People

(Reporter: ptomato, Assigned: ptomato)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 3 obsolete files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Steps to reproduce: Building SpiderMonkey as a standalone library on macOS, the built .dylib's install_name should be an absolute path. If it uses @executable_path which is currently the case, then you can't run any programs that link to the .dylib unless they are installed into the same directory as the .dylib. Actual results: Running any program that links to the built SpiderMonkey .dylib crashes with 'Library not loaded: (incorrect path here) Reason: image not found'
Component: Untriaged → JavaScript Engine
OS: Unspecified → Mac OS X
Product: Firefox → Core
Hardware: Unspecified → All
This patch makes it work for me, but it probably needs some magic to only have the change take effect when building standalone.
Blocks: 1379541
Blocks: sm-embedding
Comment on attachment 8884710 [details] [diff] [review] 0002-build-Fix-library-install-name-on-macOS.patch Review of attachment 8884710 [details] [diff] [review]: ----------------------------------------------------------------- Mike, can you comment on whether this is the right approach or, if not, what would be the right approach?
Attachment #8884710 - Flags: feedback?(mh+mozilla)
Comment on attachment 8884710 [details] [diff] [review] 0002-build-Fix-library-install-name-on-macOS.patch Review of attachment 8884710 [details] [diff] [review]: ----------------------------------------------------------------- The install name needs to stay as it is. Otherwise, you just break e.g. running the shell from the build directory. Plus, that obviously totally breaks Firefox. Anyways, the right thing to do is to change the install name at `make install` time, with install_name_tool.
Attachment #8884710 - Flags: feedback?(mh+mozilla) → feedback-
Attachment #8884710 - Attachment is obsolete: true
Attachment #8889009 - Flags: review?(mh+mozilla)
Comment on attachment 8889009 [details] [diff] [review] Fix library install_name on macOS Review of attachment 8889009 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/Makefile.in @@ +220,5 @@ > endif > ifneq (,$(SHARED_LIBRARY)) > $(SYSINSTALL) $(SHARED_LIBRARY) $(DESTDIR)$(libdir) > +ifeq ($(OS_ARCH),Darwin) > + install_name_tool -id $(abspath $(libdir)/$(SHARED_LIBRARY)) $(DESTDIR)$(libdir)/$(SHARED_LIBRARY) That is not the full story. This is useful for anything that would link against that system-installed library, but as long as js is still installed, it needs to be adjusted too, presumably with install_name_tool -change. @@ +226,5 @@ > endif > ifneq (,$(IMPORT_LIBRARY)) > $(SYSINSTALL) $(IMPORT_LIBRARY) $(DESTDIR)$(libdir) > +ifeq ($(OS_ARCH),Darwin) > + install_name_tool -id $(abspath $(libdir)/$(IMPORT_LIBRARY)) $(DESTDIR)$(libdir)/$(IMPORT_LIBRARY) This is effectively dead code, as import libraries are a windows-only thing.
Attachment #8889009 - Flags: review?(mh+mozilla)
(In reply to Mike Hommey [:glandium] from comment #5) > Comment on attachment 8889009 [details] [diff] [review] > Fix library install_name on macOS > > Review of attachment 8889009 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: js/src/Makefile.in > @@ +220,5 @@ > > endif > > ifneq (,$(SHARED_LIBRARY)) > > $(SYSINSTALL) $(SHARED_LIBRARY) $(DESTDIR)$(libdir) > > +ifeq ($(OS_ARCH),Darwin) > > + install_name_tool -id $(abspath $(libdir)/$(SHARED_LIBRARY)) $(DESTDIR)$(libdir)/$(SHARED_LIBRARY) > > That is not the full story. This is useful for anything that would link > against that system-installed library, but as long as js is still installed, > it needs to be adjusted too, presumably with install_name_tool -change. Since I have a patch pending on bug 1339931 to stop installing the js shell, would you be OK leaving this as-is and landing this patch after that one? > @@ +226,5 @@ > > endif > > ifneq (,$(IMPORT_LIBRARY)) > > $(SYSINSTALL) $(IMPORT_LIBRARY) $(DESTDIR)$(libdir) > > +ifeq ($(OS_ARCH),Darwin) > > + install_name_tool -id $(abspath $(libdir)/$(IMPORT_LIBRARY)) $(DESTDIR)$(libdir)/$(IMPORT_LIBRARY) > > This is effectively dead code, as import libraries are a windows-only thing. Not so dead as you might think, maybe - $(IMPORT_LIBRARY) is apparently set on macOS as well to the same thing as $(SHARED_LIBRARY). So without this, the import library install rule overwrote the installed library that had its install name adjusted, with another copy of the unadjusted one. Maybe the solution is to adjust the install name before installing, I'll change the patch to do that instead.
Note that for backport to esr52, the patch must be applied to js/src/Makefile.in instead of js/src/build/Makefile.in.
Attachment #8889009 - Attachment is obsolete: true
Attachment #8890016 - Flags: review?(mh+mozilla)
(In reply to Philip Chimento [:ptomato] from comment #6) > (In reply to Mike Hommey [:glandium] from comment #5) > > Comment on attachment 8889009 [details] [diff] [review] > > Fix library install_name on macOS > > > > Review of attachment 8889009 [details] [diff] [review]: > > ----------------------------------------------------------------- > > > > ::: js/src/Makefile.in > > @@ +220,5 @@ > > > endif > > > ifneq (,$(SHARED_LIBRARY)) > > > $(SYSINSTALL) $(SHARED_LIBRARY) $(DESTDIR)$(libdir) > > > +ifeq ($(OS_ARCH),Darwin) > > > + install_name_tool -id $(abspath $(libdir)/$(SHARED_LIBRARY)) $(DESTDIR)$(libdir)/$(SHARED_LIBRARY) > > > > That is not the full story. This is useful for anything that would link > > against that system-installed library, but as long as js is still installed, > > it needs to be adjusted too, presumably with install_name_tool -change. > > Since I have a patch pending on bug 1339931 to stop installing the js shell, > would you be OK leaving this as-is and landing this patch after that one? Fair enough. > > @@ +226,5 @@ > > > endif > > > ifneq (,$(IMPORT_LIBRARY)) > > > $(SYSINSTALL) $(IMPORT_LIBRARY) $(DESTDIR)$(libdir) > > > +ifeq ($(OS_ARCH),Darwin) > > > + install_name_tool -id $(abspath $(libdir)/$(IMPORT_LIBRARY)) $(DESTDIR)$(libdir)/$(IMPORT_LIBRARY) > > > > This is effectively dead code, as import libraries are a windows-only thing. > > Not so dead as you might think, maybe - $(IMPORT_LIBRARY) is apparently set > on macOS as well to the same thing as $(SHARED_LIBRARY). So without this, > the import library install rule overwrote the installed library that had its > install name adjusted, with another copy of the unadjusted one. > > Maybe the solution is to adjust the install name before installing, I'll > change the patch to do that instead. Huh, please don't. File a separate bug for the above paragraph instead, we shouldn't do that in the first place.
Attachment #8890016 - Flags: review?(mh+mozilla)
Depends on: 1384308
Depends on: 1339931
Note that for backport to esr52, the patch must be applied to js/src/Makefile.in instead of js/src/build/Makefile.in.
Attachment #8890016 - Attachment is obsolete: true
Comment on attachment 8890101 [details] [diff] [review] Fix library install_name on macOS OK, this one should do the trick, but needs to land after bug 1339931.
Attachment #8890101 - Flags: review?(mh+mozilla)
Comment on attachment 8890101 [details] [diff] [review] Fix library install_name on macOS Going to leave the js shell installed after all, so I'll redo this patch to work the install_name magic on it as well.
Attachment #8890101 - Flags: review?(mh+mozilla)
Comment on attachment 8890101 [details] [diff] [review] Fix library install_name on macOS Actually, the js shell appears to link statically to the js library. In any case, otool -L shows no libmozjs to change with install_name_tool. So, I think the previous version of this patch is good after all.
Attachment #8890101 - Flags: review?(mh+mozilla)
Attachment #8890101 - Flags: review?(mh+mozilla) → review+
Assignee: nobody → philip.chimento
Pushed by ryanvm@gmail.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/0959abdc7a87 Fix library install_name on macOS. r=glandium
Keywords: checkin-needed
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
Comment on attachment 8890101 [details] [diff] [review] Fix library install_name on macOS [Approval Request Comment] If this is not a sec:{high,crit} bug, please state case for ESR consideration: This is a build fix for standalone SpiderMonkey on macOS. User impact if declined: None to Firefox users, but embedders will need to patch the ESR tarball for compiling on macOS. Fix Landed on Version: 57 Risk to taking this patch (and alternatives if risky): Very low risk, only affects "make install" String or UUID changes made by this patch: None See https://wiki.mozilla.org/Release_Management/ESR_Landing_Process for more info.
Attachment #8890101 - Flags: approval-mozilla-esr52?
Comment on attachment 8890101 [details] [diff] [review] Fix library install_name on macOS packaging fix for spidermonkey, esr52.4+
Attachment #8890101 - Flags: approval-mozilla-esr52? → approval-mozilla-esr52+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: