So... you've decided, for one reason or another, that you need to build a UXP application. Maybe you are testing out somebody's new UXP-based application, for which no binaries yet exist. Maybe you intend to run a supported application on an unsupported computer architecture. Maybe you have very specific needs for the application. Or maybe you're just a Gentoo freak... (I sympathize with all four categories!)
But there's one problem: You have hardware which is mostly capable of compiling the application, but falls juuust a little short of compiling the whole thing. Or maybe you are building the application on a 32-bit system. Whatever the reason, the result is the same: The compilation of UXP almost completes, but a major failure occurs in the linking process.
So now (especially considering that old and slow hardware) you've just blown 3 hours compiling UXP for nothing. Grrr! Once you regain your sanity, read this article; it may just help you.
The solution
Chances are, if you're compiling an application for yourself, you probably are not compiling it for debugging per se; you just have other special needs. If you are compiling it for debugging, then stop reading here, because this howto does not cover those bases.
Still here? Okay, now we can talk about the solution.
The solution is to "strip" the unneeded symbols out of the compiled but unlinked code -- known as object code -- before the main UXP library is linked. You see, all of the object files UXP is composed of may add up to over 2 GB of disk space. The linker needs to read all of those files into memory and produce a combined, linked library from those separate files. Normally, the "stripping" of unneeded parts of the object files occurs after the linking is done. But my hack will show you how to do this before the linking is done, to save memory and speed up the linking process too. In my tests, stripping the objects files prior to linking reduced the disk usage of the object files by a factor of 10.
Method #1: If you've already gotten most of the way through a build
If you've already gotten most of the way through a build, then the process is easy, at least on UNIX-like operating systems. If you have a terminal open and the shell is in the directory where the application is located, you can run the following one-liner:
Code: Select all
find obj-* -name '*.o' -type f -exec strip --strip-unneeded {} \;
WARNING! Do not use strip on the object files without any command line switch! If you do, the linking process will fail and you will have to start all over!
Once this process is done (it should take a few seconds), rerun the build and see if the linking succeeds this time.
Method #2: If you're just starting out a build
If you're just starting out a build, nothing could be easier. Just open the file 'platform/config/rules.mk' under the application's source tree, using your favorite text editor. When it opens, scroll down to the section which reads:
Code: Select all
ifndef XP_MACOSX
dtrace -x nolibs -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(shell $(EXPAND_LIBS) $(MOZILLA_PROBE_LIBS))
endif
Code: Select all
ifdef ENABLE_STRIP
ifneq ($(strip $(STATIC_LIBS)),)
$(EXPAND_LIBS_EXEC) -- $(STRIP) --strip-unneeded $(STATIC_LIBS)
endif # $(STATIC_LIBS) != ""
endif # ENABLE_STRIP
Code: Select all
$(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(SUB_SHLOBJS) $(DTRACE_PROBE_OBJ) $(MOZILLA_PROBE_LIBS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(STATIC_LIBS) $(RUST_STATIC_LIB_FOR_SHARED_LIB) $(SHARED_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(EXTRA_LIBS) $(OS_LIBS) $(SHLIB_LDENDFILE)
@$(RM) $(DTRACE_PROBE_OBJ)
else # ! DTRACE_LIB_DEPENDENT
Code: Select all
ifdef ENABLE_STRIP
ifneq ($(strip $(STATIC_LIBS)),)
$(EXPAND_LIBS_EXEC) -- $(STRIP) --strip-unneeded $(STATIC_LIBS)
endif # $(STATIC_LIBS) != ""
endif # ENABLE_STRIP
Now start the build process as usual and you should be good to go!