Closed
Bug 577831
Opened 15 years ago
Closed 15 years ago
Document how component authors are supposed to interact with mozalloc
Categories
(Core :: XPCOM, defect)
Tracking
()
RESOLVED
FIXED
Tracking | Status | |
---|---|---|
blocking2.0 | --- | beta5+ |
People
(Reporter: benjamin, Assigned: cjones)
References
Details
Attachments
(1 file)
708 bytes,
patch
|
benjamin
:
review+
|
Details | Diff | Splinter Review |
From mozilla.dev.embedding:
I have tryed to compile my xpcom extension dll with the firefox 4
changes.
I have take the xulrunner-2.0b2pre.en-US.win32.sdk and made a mozilla
folder with some headerfiles from mozilla-central.
When i compile i get the following errors:
c:\programme\gecko-sdk2.0b2\include\mozilla/mozalloc.h(107) : error
C3646: 'NS_ATTR_MALLOC' : unknown override specifier
c:\programme\gecko-sdk2.0b2\include\mozilla/mozalloc.h(107) : error
C3646: 'NS_WARN_UNUSED_RESULT' : unknown override specifier
ModuleUtils.h -> Module.h -> nsID.h -> nscore.h -> mozalloc.h
with Option MOZ_NO_MOZALLOC i get linker erros like this:
xpcomglue_s.lib(nsISupportsImpl.obj) : error LNK2001: unresolved
external symbol __imp__moz_xmalloc
xpcomglue_s.lib(nsISupportsImpl.obj) : error LNK2001: unresolved
external symbol __imp__moz_free
The first error is because embedders don't get everything from mozilla-config.h. They only get stuff that is listed explicitly in xpcom-config.h. Any of the AC_DEFINE stuff from configure that is required by nscore.h should be added to xpcom-config.h.
But it doesn't sound like external component authors ought to be using mozalloc by default, and in that case MOZ_NO_MOZALLOC should probably be the default for them. We need to figure out why it doesn't work.
I have updated the xpcom-config.h with the two missing macros and enabled mozalloc.
with following result:
Linking...
Creating library C:\VS2005\Projects\mastervol\xpcom-vol_v2\Release\test.lib and object C:\VS2005\Projects\mastervol\xpcom-vol_v2\Release\test.exp
mastervol-impl.obj : error LNK2001: unresolved external symbol __imp__moz_xmalloc
xpcomglue_s.lib(nsISupportsImpl.obj) : error LNK2001: unresolved external symbol __imp__moz_xmalloc
mastervol-impl.obj : error LNK2001: unresolved external symbol __imp__moz_free
xpcomglue_s.lib(nsISupportsImpl.obj) : error LNK2001: unresolved external symbol __imp__moz_free
At next i have linked against mozalloc.lib, this gets a working dll. My extension works now with firefox 4.
If you have fix this, i can recompile the dll to check how it works.
Thanks to --BDS.
Comment 2•15 years ago
|
||
Where to get the mozalloc.lib?
I am facing similar error.
1>xpcomglue_s.lib(GenericFactory.obj) : error LNK2019: unresolved external symbol __imp__moz_xmalloc referenced in function "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
1>xpcomglue_s.lib(nsVersionComparator.obj) : error LNK2001: unresolved external symbol __imp__moz_xmalloc
1>xpcomglue_s.lib(nsComponentManagerUtils.obj) : error LNK2001: unresolved external symbol __imp__moz_xmalloc
1>xpcomglue_s.lib(GenericModule.obj) : error LNK2001: unresolved external symbol __imp__moz_xmalloc
1>xpcomglue_s.lib(nsGREGlue.obj) : error LNK2001: unresolved external symbol __imp__moz_xmalloc
1>xpcomglue_s.lib(nsISupportsImpl.obj) : error LNK2001: unresolved external symbol __imp__moz_xmalloc
1>xpcomglue_s.lib(nsCOMPtr.obj) : error LNK2001: unresolved external symbol __imp__moz_xmalloc
1>xpcomglue_s.lib(GenericFactory.obj) : error LNK2019: unresolved external symbol __imp__moz_free referenced in function "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)
1>xpcomglue_s.lib(nsVersionComparator.obj) : error LNK2001: unresolved external symbol __imp__moz_free
1>xpcomglue_s.lib(nsComponentManagerUtils.obj) : error LNK2001: unresolved external symbol __imp__moz_free
1>xpcomglue_s.lib(GenericModule.obj) : error LNK2001: unresolved external symbol __imp__moz_free
1>xpcomglue_s.lib(nsGREGlue.obj) : error LNK2001: unresolved external symbol __imp__moz_free
1>xpcomglue_s.lib(nsISupportsImpl.obj) : error LNK2001: unresolved external symbol __imp__moz_free
1>xpcomglue_s.lib(nsCOMPtr.obj) : error LNK2001: unresolved external symbol __imp__moz_free
1>xpcomglue_s.lib(nsVersionComparator.obj) : error LNK2019: unresolved external symbol __imp__moz_strdup referenced in function "int __cdecl NS_CompareVersions(char const *,char const *)" (?NS_CompareVersions@@YAHPBD0@Z)
In Short: You have to download the sourcecode with mercurial (hg) and Setup your build enviroment with the Mozilla Build package.
Here you get instructions:
https://developer.mozilla.org/en/build_documentation
for windows:
https://developer.mozilla.org/En/Developer_Guide/Build_Instructions/Windows_Prerequisites
Comment 5•15 years ago
|
||
I am having the same issue on Win32 (should the platform filed be updated?), and I was able to work-around the link errors using the solution suggested by TheRave (building minefield, editing xpcom-config.h, and linking mozalloc.lib).
I seem to have deeper problems however, since now I get MFC related link errors for new and delete symbols (my DLL uses MFC).
Hopefully these errors are due to linking against mozalloc.lib, and will go away once this bug is resolved. (I am able to build my DLL without issues against Gecko 1.9.2.)
Comment 7•15 years ago
|
||
This is a critical issue, (I think so). As Firefox 4 is gaining more ground, the addon developers are in search for compiling their addons for Firefox 4. Not only their is no proper documentation of what needs to be done (apart from the docs, that says changes coming in Gecko 2), but also the xpcom can't be linked, due to this issue.
Linking against mozalloc.lib, is also not a solution, as my dll also uses COM and MFC heavily, which have their own resource allocation and freeing routines.
Is there a way to build a component without linking against mozalloc.lib?
I want to use "NS_IMPL_MOZILLA192_NSGETMODULE()" which is working great
as long as "mozalloc.dll" is found.
Assignee | ||
Comment 9•15 years ago
|
||
Attachment #463246 -
Flags: review?(benjamin)
Reporter | ||
Updated•15 years ago
|
Attachment #463246 -
Flags: review?(benjamin) → review+
Assignee | ||
Updated•15 years ago
|
blocking2.0: --- → ?
Comment 10•15 years ago
|
||
On top of this issue, it appears that a win64 version of Firefox 4 is going to be released (nightly builds have a win64 target).
This means a win64 target for xulrunner-sdk builds would be extremely helpful/required.
Comment 11•15 years ago
|
||
I have a binary component created at win32 by VS 2005.
Using xulrunner-2.0b2pre I got same error.
I downloaded new xulrunner but by version xulrunner-2.0b4pre (not formally released), there is no "mozalloc.lib" although I have found "mozalloc.dll" and some mozalloc source files(.h, .cpp)
I searched and get clue from this bug that I have to compile firefox sourcecode to get it. So I did this by below guide
https://developer.mozilla.org/En/Simple_Firefox_build
It is successful, and I got "mozalloc.lib"
Then I successfully compiled my binary component and it works well in firefox 4.0b2
The new problem is that, the component did not work in Firefox 3.6, event I have used extra macro NS_IMPL_MOZILLA192_NSGETMODULE as the sameple nsSampleModule.cpp given by
https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2.0
Not sure if only me have this issue. But if everyone has it, it may be a problem of NS_IMPL_MOZILLA192_NSGETMODULE or something else.
For convenience, here is the link to "mozalloc.lib" that I compiled.
http://downloads.mozdev.org/supertabmode/mozalloc.lib
Comment 12•15 years ago
|
||
Just tried updating my binary xpcom components for firefox 4 and encountered the same issues.
As Firefox 4 is approaching and the add-on authors need to modify their code, it would be great if the documentation could be a bit more detailed, and point to an sdk that could be used for this.
- https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2.0 should probably have more info about what sdk should be used, what tweaks would need to be done to the code etc.
- https://developer.mozilla.org/en/how_to_build_a_binary_xpcom_component_using_visual_studio might need to be adjusted as well
- https://developer.mozilla.org/en/gecko_sdk should have links to an sdk that could be used for this.
Please let me know if I can help in any way to identify and/or resolve the remaining issues (either in the sdk itself or the documentation). Would be great to have everything ironed out well ahead of the Release Candidate.
Reporter | ||
Updated•15 years ago
|
blocking2.0: ? → beta5+
Reporter | ||
Comment 13•15 years ago
|
||
http://hg.mozilla.org/mozilla-central/rev/323d65ae8bce
I'll send a note to md.extensions about the current situation.
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 14•15 years ago
|
||
Thanks for landing this.
Comment 15•15 years ago
|
||
Assignee | ||
Comment 16•15 years ago
|
||
Added a note to https://developer.mozilla.org/en/XPCOM_Glue.
Comment 17•15 years ago
|
||
I have filed a new bug with a patch attached that will create xpcomglue_s_nomozalloc for developers to use:
https://bugzilla.mozilla.org/show_bug.cgi?id=586523
Comment 18•14 years ago
|
||
Very annoying, this is not fixed in the actual xul-runner sdk yet.
c:\programme\gecko-sdk2.0b2\include\mozilla/mozalloc.h(107) : error
C3646: 'NS_ATTR_MALLOC' : unknown override specifier
c:\programme\gecko-sdk2.0b2\include\mozilla/mozalloc.h(107) : error
C3646: 'NS_WARN_UNUSED_RESULT' : unknown override specifier
The first error is because embedders don't get everything from
mozilla-config.h. They only get stuff that is listed explicitly in
xpcom-config.h. Any of the AC_DEFINE stuff from configure that is required by
nscore.h should be added to xpcom-config.h.
Comment 19•14 years ago
|
||
A define of MOZ_NO_MOZALLOC in visual studio or
#define NS_ATTR_MALLOC
#define NS_WARN_UNUSED_RESULT
in [module-name].h
and linking to mozalloc.lib works in xulrunner 5 sdk
You need to log in
before you can comment on or make changes to this bug.
Description
•