Open Bug 562313 Opened 15 years ago Updated 3 years ago

allow linking browser components directly into libxul

Categories

(Firefox Build System :: General, defect)

defect

Tracking

(Not tracked)

People

(Reporter: ted, Unassigned)

References

Details

Attachments

(1 file, 7 obsolete files)

We currently ship components/libbrowsercomps.so with Firefox's binary components. We should be able to (with a little bit of build trickery) link those components directly into libxul instead. It should continue to get built as a standalone library when building --with-libxul-sdk, however.
Here's my plan: 1) add a variable that you can set in build.mk before including toolkit-tiers.mk that adds a dir to the platform tier right before building toolkit/library, use this variable in browser/build.mk to build browser/components before linking libxul 2) add a variable somewhere that makes nsStaticXULComponents include a header or something to add components to that list, include the guts of browser/components/build/nsModule.cpp in there 3) add a variable that tells libxul to link in some extra libs, link in libbrowsercomps (which will have been switched to a static lib)
This patch allows apps to: 1) Set APP_LIBXUL_DIRS before including toolkit-tiers.mk, resulting in those directories being built right before toolkit/library. 2) Set MOZ_APP_COMPONENT_INCLUDE to a header filename in confvars.sh. The header file will be included in nsStaticXULComponents.cpp and should #define APP_COMPONENT_MODULES appropriately (like MODULE(nsBrowserCompsModule)) 3) Set MOZ_APP_COMPONENT_LIBS to the name of the static library containing the app components (also in confvars.sh). Thus, the modules can get built and linked into libxul.
Attachment #442799 - Flags: review?
This patch uses the hooks described above to link browsercomps into libxul. Most of this patch is fiddling to make external vs. internal string apis work right. This built for me locally on Linux, I pushed it to try for a sanity check. (It's quite possible some of the migration or shell code needs more platform-specific string api fixes.)
Attachment #442799 - Flags: review? → review?(benjamin)
Comment on attachment 442800 [details] [diff] [review] Part 2: Link browsercomps into libxul using the hooks This patch needs work, fails on Windows and Mac.
Hrmph. Worked on my local Mac build, might just be Universal build bustage.
Fixed the Windows bustage.
Attachment #442800 - Attachment is obsolete: true
Oops, wrong patch.
Attachment #443092 - Attachment is obsolete: true
Attachment #442799 - Flags: review?(benjamin) → review+
Oops, I forgot about the second patch here. I'll test a universal build locally and finish it up.
Ah, found the Mac bustage. On Mac we symlink all the .o files from the static libs that we use to build libxul into a single directory and then link them into libuxl. Unfortunately with this patch we wound up linking two files named nsModule.o, so we were overwriting one of them and failing to link. I've renamed browser/components/build/nsModule.cpp to nsBrowserCompsModule.cpp and it looks good. I'll have an updated patch shortly.
Attachment #443093 - Attachment is obsolete: true
Accidentally hit return, but that patch builds and works on Linux/Windows/OS X. I haven't tested it in the FF+XR build config, but it's ifdefed such that it should continue to work there.
Attachment #460608 - Flags: review?(gavin.sharp) → review?(benjamin)
Hrm. I don't mean to be stop-energy now, but we could probably do this a lot simpler now by linking these into firefox.exe and using XRE_AddStaticComponent. That wouldn't involve switching on internal/external linkage, or switching the tiers around in this way. I'm going to try and work up that patch quickly and see if you find it acceptable.
Assignee: ted.mielczarek → benjamin
Attachment #460608 - Attachment is obsolete: true
Attachment #460608 - Flags: review?(benjamin)
Running this through tryserver now, but it basically statically links browsercomps when we're building standalone, and builds a binary component when we're building --with-libxul-sdk (Linux distro case)
Attachment #462897 - Flags: review?(ted.mielczarek)
(In reply to comment #13) > Created attachment 462897 [details] [diff] [review] > Link browsercomps into firefox.exe statically, rev. 1 > > Running this through tryserver now, but it basically statically links > browsercomps when we're building standalone, and builds a binary component when > we're building --with-libxul-sdk (Linux distro case) Hm, why not libxul? The problem with linking into the program is that we don't use the program on Android.. we just load libxul.
What does 'use the program' mean? Presumably you have *a* program, no?
(In reply to comment #15) > What does 'use the program' mean? Presumably you have *a* program, no? We have a fennec binary. We don't run it or package it. libxul is loaded directly from the JVM and a special loading function in nsAndroidStartup is used to set things up and call XRE_main.
Attachment #442799 - Attachment is obsolete: true
Comment on attachment 462897 [details] [diff] [review] Link browsercomps into firefox.exe statically, rev. 1 ># HG changeset patch ># Parent a0694218d21e81f84dc8278eaa78c0c869f98990 >Bug 562313 - Statically link binary browser components into firefox.exe, r?ted > >diff --git a/browser/app/Makefile.in b/browser/app/Makefile.in >--- a/browser/app/Makefile.in >+++ b/browser/app/Makefile.in >@@ -89,16 +89,22 @@ else > ifneq (,$(filter OS2 WINCE WINNT,$(OS_ARCH))) > PROGRAM = $(MOZ_APP_NAME)$(BIN_SUFFIX) > else > PROGRAM = $(MOZ_APP_NAME)-bin$(BIN_SUFFIX) > endif > > CPPSRCS = nsBrowserApp.cpp > >+LIBS += \ >+ $(call EXPAND_LIBNAME_PATH,browsercomps,../components/build) \ >+ $(call EXPAND_LIBNAME_PATH,unicharutil_external_s,$(LIBXUL_DIST)/lib) \ >+ $(LIBXUL_DIST)/lib/$(LIB_PREFIX)mozreg_s.$(LIB_SUFFIX) \ >+ $(NULL) Nit: 2-space indent, not tabs. Much nicer than my patches, certainly.
Attachment #462897 - Flags: review?(ted.mielczarek) → review+
Oh, you will need to patch package-manifest.in and removed-files.in as well. You can just snag the hunks out of attachment 460608 [details] [diff] [review].
Do you have time to update this patch, or do you want me to update it and request approval? It'd be nice to knock out one more shared library for FF4 since we have this patch in hand.
Hrm, I forgot about it. Pre-approved, or I can maybe do it later today.
Here's what I'm rebuilding for push today.
Attachment #462897 - Attachment is obsolete: true
Whoops, got an ifdef reversed. This works.
Attachment #469906 - Attachment is obsolete: true
Attachment #469916 - Flags: approval2.0+
Looks like this might need a clobber in order to build successfully the first time. By chance, it got one cycle that was a clobber: http://tinderbox.mozilla.org/showlog.cgi?log=Firefox/1282948127.1282952807.18472.gz and that went green. If bsmedberg can confirm that this makes sense (and that this has been green on tryserver at some point), then this probably needs a re-push.
The green build cycle had an orange xpcshell cycle, though: http://tinderbox.mozilla.org/showlog.cgi?log=Firefox/1282951713.1282952974.18985.gz with something failing in build/xpcshell/tests/browser/components/dirprovider/tests/unit/test_bookmark_pref.js That's not a known randomorange, and the next cycle (backout) was green for xpcshell, so it seems plausible that this orange was related to this bug.
Here's another instance of that xpcshell orange (from another build with this changeset that was lucky enough to be a clobber & build successfully): http://tinderbox.mozilla.org/showlog.cgi?log=Firefox/1282951248.1282952849.18558.gz
(In reply to comment #25) > The green build cycle had an orange xpcshell cycle, though: > http://tinderbox.mozilla.org/showlog.cgi?log=Firefox/1282951713.1282952974.18985.gz > with something failing in > build/xpcshell/tests/browser/components/dirprovider/tests/unit/test_bookmark_pref.js > > That's not a known randomorange, and the next cycle (backout) was green for > xpcshell, so it seems plausible that this orange was related to this bug. It appears that this test relies on browsercomps being loaded, but it can't be now that it's linked into the firefox binary. Looks like this patch breaks any xpcshell tests of browsercomps.
Standard8 landed my original approach in bug 597465, so we might as well just land my browser patch from here for now, and then fix things to be less crappy post-Firefox 4.
Comment on attachment 469916 [details] [diff] [review] Link browsercomps into firefox.exe statically, rev. 2.1 This was approved back in 2010, and never landed due to difficulties. Removing the approval for now. Feel free to renominate with risk v. reward if you want to see it in the tree for RC.
Attachment #469916 - Flags: approval2.0+ → approval2.0-
Assignee: benjamin → nobody
Product: Core → Firefox Build System

Binary components have all been merged into libxul a long time ago.

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: