I think so.
I just traced through some of our configure goop. I'm nowhere close to
being an expert on this stuff, so don't trust anything I say here. But I
think the most relevant part is:
https://searchfox.org/mozilla-central/rev/a40ef31fc9af34a99ceda6d65cdc4573d52b83d2/js/src/old-configure.in#1239-1252
--disable-jemalloc will clear out MOZ_MEMORY, which from the above
configure snippet will result in MOZ_GLUE_IN_PROGRAM being set to the
empty string for JS_STANDALONE (mozjs). MOZ_GLUE_IN_PROGRAM can be read
as "mozglue is linked into the executable *as opposed to the library*",
and you want it in the library.
The magic unicorn in the build system will then look at
MOZ_GLUE_IN_PROGRAM, and if it is clear, be chopped up and processed
into glue to compensate and will no longer be able to help you. As a
result, mozglue will not be linked into the library. (We don't give out
the unicorn glue, sorry; that stuff is valuable.)
Uh... sorry, having a lot of trouble tracking down how this affects
things. That's the best explanation I have at the moment.
I'll try harder.
https://searchfox.org/mozilla-central/rev/a40ef31fc9af34a99ceda6d65cdc4573d52b83d2/build/gecko_templates.mozbuild#39-50
seems to be where the unicorn-chopping must happen. I have no idea how
'mozglue' gets set there, but you can see that if the magic unicorn set
it to 'library' before dying and MOZ_GLUE_IN_PROGRAM is clear, then
you'll end up with USE_LIBS including 'mozglue'. I'll take it on faith
that USE_LIBS will result in the right thing happening.
GeckoBinary seems an odd thing to use for configuring building for a
*library*, but the unicorn was probably a little occupied with its
impending doom to worry about that, and
https://searchfox.org/mozilla-central/rev/a40ef31fc9af34a99ceda6d65cdc4573d52b83d2/build/docs/defining-binaries.rst#326-345
seems to confirm.
https://searchfox.org/mozilla-central/rev/a40ef31fc9af34a99ceda6d65cdc4573d52b83d2/build/gecko_templates.mozbuild#99-110
shows that GeckoSharedLibrary does indeed use it. I guess my brain
associates "binary" with "executable", but this code appears to use
"Program" for that.
And sure enough,
https://searchfox.org/mozilla-central/rev/a40ef31fc9af34a99ceda6d65cdc4573d52b83d2/js/src/build/moz.build#25-26
uses GeckoSharedLibrary (the actual library name mozjs appears to be set
here:
https://searchfox.org/mozilla-central/rev/a40ef31fc9af34a99ceda6d65cdc4573d52b83d2/js/src/old-configure.in#1589
)
Anyway: yes, --disable-jemalloc should be adequate to get the linking
correct. And our tarball sucks, in that it produces a mozjs depending on
weak symbols in a library that it does not provide, which results in
things linking happily but then trying to call null pointers when you
call any of those weak symbols. Not only should we switch the tarball's
default, we should also add a canary call (or simple null pointer test)
that gives some clue as to what's actually going wrong if you end up in
this configuration.