Closed
Bug 262218
Opened 21 years ago
Closed 21 years ago
libxpcom.so should only export frozen symbols
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla1.8beta1
People
(Reporter: darin.moz, Assigned: darin.moz)
Details
(Whiteboard: [ready to land])
Attachments
(1 file, 3 obsolete files)
146.42 KB,
patch
|
benjamin
:
review+
bryner
:
superreview+
|
Details | Diff | Splinter Review |
libxpcom.so should only export frozen symbols.
I believe that we should rename libxpcom.so to libxpcom-private.so (or whatever
name we like), and create a new libxpcom.so that only exports frozen symbols.
libxpcom.so should have a direct link time dependency on libxpcom-private.so.
libxpcom.so would simply forward all calls to libxpcom-private.so, making it
nothing more than a shim library.
This is imperative because we too often find folks improperly linking to
libxpcom.so for non-frozen symbols because they forget to put -lxpcomglue before
-lxpcom on the link line. We should be providing better documentation of course
to combat this problem as well, but we can also improve the technology to
encourage proper usage.
Going forward, this would give us the option to replace libxpcom-private.so with
libgecko.so (or libxul.so -- whatever you want to call it) that includes not
just the core xpcom code but all of Gecko. DSO consolidation is important to
improving the performance of Gecko when not statically linked, and if
applications link to libxpcom.so, then those applications would be able to
pre-bind to Gecko while still having an indirect link time dependency on it.
I believe that this may be "the ticket" to building a performant version of
Firefox that loads an embeddable version of Gecko.
Assignee | ||
Comment 1•21 years ago
|
||
XPTC_InvokeByIndex and friends are interesting non-frozen exports. We really
should think about either freezing the typelib system. Shaver?
Assignee | ||
Comment 2•21 years ago
|
||
... either ..., or live with having language bindings be tightly coupled to the
Gecko version with access to private interfaces, privy to libxpcom-private.so, etc.
Assignee | ||
Updated•21 years ago
|
Target Milestone: --- → mozilla1.8beta
Comment 3•21 years ago
|
||
Freezing the typelib system is no small job. I would consider it, along with an
overhaul of our current typelib types, for mozilla2. For now, I think we
language-binding authors really just end up taking our lumps.
(I'd also like to make some extensions to that API before freezing it, to reduce
the thunk-count for some common operations.)
Assignee | ||
Comment 4•21 years ago
|
||
this patch is just a first pass. i'd still need to patch all of the fun
packaging scripts. but, this works. everything that is in libxpcom.so today
is moved to libxpcom_core.so, and libxpcom.so contains nothing but frozen
symbols.
in order for this stub library to work properly, all of the actual definitions
of the symbols need to be renamed internally. so, with some preprocessor fu i
managed to make all of the internal versions of the functions end with "_P". i
keyed off of MOZILLA_STRICT_API to control whether or not the function names
get mapped to the _P versions.
if anyone has a better suggestion for how to do this, please let me know.
Comment 5•21 years ago
|
||
Comment on attachment 160614 [details] [diff] [review]
v0 patch
>Index: xpcom/build/nsXPCOM.h
>+// Map frozen functions to private symbol names if not using strict API.
>+#ifndef MOZILLA_STRICT_API
>+# define NS_InitXPCOM2 NS_InitXPCOM2_P
I think we should be using an "opt-in" define, instead of the opt-out
MOZILLA_STRICT_API
/me suggests XPCOM_UNFROZEN_API
Secondly, you changed XPCOM_LIBS to use the "_core" lib, but we will (hopefully
soon) start having some components/programs that only use the frozen API and
can link directly against libxpcom. Maybe we should add another
configure/Makefile var for that case now?
Assignee | ||
Comment 6•21 years ago
|
||
> I think we should be using an "opt-in" define, instead of the opt-out
> MOZILLA_STRICT_API
>
> /me suggests XPCOM_UNFROZEN_API
That would be nice, but we wouldn't want to define XPCOM_UNFROZEN_API in
mozilla-config.h because that is something users of the Gecko SDK have to
include in order to use the Gecko SDK. I guess it would not be hard to arrange
for that with some rules.mk hacking.
However, it might be even better if we modified the headers included in the
Gecko SDK in such a way to force the definition of MOZILLA_STRICT_API (and
probably XPCOM_GLUE as well).
Basically, to correctly use the Gecko SDK today, one has to define
MOZILLA_STRICT_API and XPCOM_GLUE, so I'm not really adding a new requirement
with this patch. I'm causing users of the Gecko SDK who do not define
MOZILLA_STRICT_API and XPCOM_GLUE to see a link time error about missing
symbols. That's better than the status quo IMO.
> Secondly, you changed XPCOM_LIBS to use the "_core" lib, but we will (hopefully
> soon) start having some components/programs that only use the frozen API and
> can link directly against libxpcom. Maybe we should add another
> configure/Makefile var for that case now?
Those components/programs should be built on top of dist/sdk only. We should
probably invent a makefile variable that enables components/programs in the tree
to be easily built against just what is provided under dist/sdk.
In short, changing XPCOM_LIBS seems appropriate to me assuming we have another
set of makefile variables that get enabled when building against dist/sdk.
Comment 7•21 years ago
|
||
Wouldn't we just add -DXPCOM_UNFROZEN_API to our CFLAGS for the Mozilla build,
and be done?
Assignee | ||
Comment 8•21 years ago
|
||
> Wouldn't we just add -DXPCOM_UNFROZEN_API to our CFLAGS for the Mozilla build,
> and be done?
Sure, but what do we do about MOZILLA_STRICT_API and XPCOM_GLUE, which should be
specified by those using the Gecko SDK? Those using the Gecko SDK need to
define those anyways, so why not piggy back on those defines?
Perhaps we should simply deprecate MOZILLA_STRICT_API and XPCOM_GLUE, and switch
everything over to XPCOM_UNFROZEN_API. I'll go with that unless someone has a
better suggestion.
Comment 9•21 years ago
|
||
It is not always necessary to use XPCOM_GLUE when using the SDK: components can
safely link directly against xpcom.dll instead of using the glue.
Assignee | ||
Comment 10•21 years ago
|
||
(In reply to comment #9)
> It is not always necessary to use XPCOM_GLUE when using the SDK: components can
> safely link directly against xpcom.dll instead of using the glue.
you're right! in fact, XPCOM_GLUE only affects nscore.h, which defines NS_COM.
on platforms such as linux, defining XPCOM_GLUE has no real affect. on windows
however defining XPCOM_GLUE means that one must link not to xpcomglue.a but to
xpcomglue_s.a. i mistook XPCOM_GLUE for meaning that one is linking to either
version of the glue library, but that is not the case.
ok, forget i mentioned XPCOM_GLUE :)
let XPCOM_UNFROZEN_API mean !MOZILLA_STRICT_API, and we are done.
Assignee | ||
Comment 11•21 years ago
|
||
here's a complete version of the patch sans XPCOM_UNFROZEN_API. (i plan on
implementing that define, and deprecating MOZILLA_STRICT_API, in a follow-up
patch.) i still contend that you must define MOZILLA_STRICT_API today in order
to use the Gecko SDK, so additional dependency on that define is no worse off.
i need to figure out a good way to undefine the globally defined
XPCOM_UNFROZEN_API for certain modules (xpfe/bootstrap, etc.) within our source
tree before i go down that path, so i'd prefer to keep it to a follow-up patch.
this patch also includes changes to make mozilla-bin use the new string API
from the Gecko SDK instead of linking a copy of libstring.a -- it's about time
;)
Assignee | ||
Updated•21 years ago
|
Attachment #160614 -
Attachment is obsolete: true
Assignee | ||
Comment 12•21 years ago
|
||
it looks like some powerplant project files will also need to be updated for
this change, but i don't know exactly how to do that.
Assignee | ||
Updated•21 years ago
|
Attachment #161109 -
Flags: review?(bsmedberg)
Comment 13•21 years ago
|
||
those projects are bit-rotting already. nobody is actively maintaining the
carbon powerplant embedding layer. i guess conrad "owns" that, i'll cc him.
Comment 14•21 years ago
|
||
Comment on attachment 161109 [details] [diff] [review]
v1 patch
>Index: xpcom/build/nsXPCOMPrivate.h
>+// Map frozen functions to private symbol names if not using strict API.
>+#ifndef MOZILLA_STRICT_API
>+# define NS_RegisterXPCOMExitRoutine NS_RegisterXPCOMExitRoutine_P
>+# define NS_UnregisterXPCOMExitRoutine NS_UnregisterXPCOMExitRoutine_P
>+# define NS_GetFrozenFunctions NS_GetFrozenFunctions_P
>+#endif
The exitroutine stuff is not frozen, right? I don't think it should be, unless
there's a usage I missed.
>Index: embedding/qa/testembed/Tests.cpp
Is this an accident? seems unrelated
>Index: xpinstall/packager/xpcom-win.pkg
>+bin\xpcomcor.dll
I thought we were using xpcom_core.dll on windows...
>Index: xpfe/bootstrap/nsStringSupport.h
>+#define EmptyCString() nsCString()
>+#define EmptyString() nsString()
Does this actually work? I didn't think you were allowed to declare macros with
an empty paramlist. I would prefer either
#define EmptyCString nsCString
or
typedef nsCString EmptyCString
r=me if you remove the exitrountine, or else a really good explanation why
you're treating it like a frozen function.
Attachment #161109 -
Flags: review?(bsmedberg) → review+
Comment 15•21 years ago
|
||
I like nsStringSupport.h, a neat trick ;)
+ void AssignWithConversion(const char *data)
+ {
+ NS_CStringToUTF16(nsEmbedCString(data), NS_CSTRING_ENCODING_ASCII,
*this);
+ }
+ void AssignLiteral(const char *data)
+ {
+ AssignWithConversion(data);
+ }
maybe it would be better to implement the non-deprecated function
(AssignLiteral) directly, and the deprecated one (AssignWithConversion) using
AssignLiteral... (or both using a new AssignASCII)
Assignee | ||
Comment 16•21 years ago
|
||
> The exitroutine stuff is not frozen, right? I don't think it should be, unless
> there's a usage I missed.
they would appear to be private, frozen xpcom apis (much like
NS_GetFrozenFunctions). the glue library uses those functions, so if you link
against xpcomglue.a, you will have a libxpcom.so dependency on the exit routine
stuff in your code. perhaps those functions should be documented as frozen! ;)
notice: those functions are included in the return value from NS_GetFrozenFunctions.
> >Index: embedding/qa/testembed/Tests.cpp
>
> Is this an accident? seems unrelated
yeah, that's unrelated. sorry, ignore that.
> >Index: xpinstall/packager/xpcom-win.pkg
>
> >+bin\xpcomcor.dll
oops.. thanks for catching that.
> >+#define EmptyCString() nsCString()
> >+#define EmptyString() nsString()
>
> Does this actually work? I didn't think you were allowed to declare macros
> with an empty paramlist.
It works for me with GCC, and I think MSVC wouldn't mind either. But, I can
change it if you think it breaks some preprocessor.
Assignee | ||
Comment 17•21 years ago
|
||
> maybe it would be better to implement the non-deprecated function
> (AssignLiteral) directly, and the deprecated one (AssignWithConversion) using
> AssignLiteral... (or both using a new AssignASCII)
sure, i could flip those around. np.
Comment 18•21 years ago
|
||
(In reply to comment #16)
> > The exitroutine stuff is not frozen, right? I don't think it should be, unless
> > there's a usage I missed.
>
> they would appear to be private, frozen xpcom apis (much like
> NS_GetFrozenFunctions).
Has any version of the glue linked against them directly, or only through
NS_GetFrozenFunctions? It turns out they are marked frozen-but-internal,
http://lxr.mozilla.org/mozilla/source/xpcom/build/nsXPCOMPrivate.h#59
> It works for me with GCC, and I think MSVC wouldn't mind either. But, I can
> change it if you think it breaks some preprocessor.
I don't care, I guess, as long as you watch ports for sillyness.
Comment 19•21 years ago
|
||
I don't think C++ says much about how the preprocessor should handle this.
Leaves it up to the implementation's preprocessor. MSVC 6/7 handles it fine,
appears to treat it as if it didn't have parens.
It makes me a little nervous to use EmptyString as a macro. I think that's
potentially a common name someone could get bitten if they chose to use that
elsewhere. Anyone who has used Win32 can appreciate the dangers.
Comment 20•21 years ago
|
||
There's nothing wrong with empty formal parameter lists in C pre-processor
macros and I know of no bugs in any C or C++ implementations. However, dbradley
has a point. The way to avoid trouble is this:
#define EmptyCString nsCString
Then even if we invade some other EmptyCString's namespace, we'll only change
the symbol that the compiler and linker (and debugger) sees, and nothing should
break at build-time.
/be
Comment 21•21 years ago
|
||
> Then even if we invade some other EmptyCString's namespace, we'll only change
> the symbol that the compiler and linker (and debugger) sees, and nothing
> should break at build-time.
I'm assuming the other namespace is static, or somehow sealed in its own library
so that the two nsCString symbols that result (ours and the other namespace's
once the preprocessor has replaced EmptyCString with nsCString) don't collide.
Name collision on nsCString is less likely than on EmptyCString due to the ns,
so it's not a big worry in the cases where static and library sealing (weak
symbols or whatever) don't apply.
/be
Assignee | ||
Comment 22•21 years ago
|
||
> Has any version of the glue linked against them directly, or only through
> NS_GetFrozenFunctions? It turns out they are marked frozen-but-internal,
> http://lxr.mozilla.org/mozilla/source/xpcom/build/nsXPCOMPrivate.h#59
no, directly. grep for ExitRoutine in xpcom/glue and see for yourself ;-)
in fact, if i build a component and link with -lxpcomglue -lxpcom, then i will
have dependencies on the ExitRoutine stuff from my component. i.e., they are
frozen ;-)(In reply to comment #19)
> It makes me a little nervous to use EmptyString as a macro. I think that's
> potentially a common name someone could get bitten if they chose to use that
> elsewhere.
please note that this header file is not for general purpose use. it is for
xpfe/bootstrap only. there might be value in providing a generic, full featured
version of nsStringSupport.h for use by embedders and component authors so that
they can use the "familiar" internal mozilla string API while depending on only
the frozen mozilla string ABI, but that's outside the scope of this bug ;-)
Assignee | ||
Comment 23•21 years ago
|
||
it turns out that we need to make XPCOM_LIBS include both -lxpcom and
-lxpcom_core to ensure that libxpcom is loaded into memory for use by plugins
and extensions.
new patch coming up.
Assignee | ||
Comment 24•21 years ago
|
||
revised per previous comment
Attachment #161109 -
Attachment is obsolete: true
Assignee | ||
Comment 25•21 years ago
|
||
ok, this patch includes changes to make mfcembed use only frozen strings.
i've also moved nsStringAPI.cpp into the stub library (xpcom.dll) instead of
having thunks for each of the string API functions. there did not seem to be
much need to compile nsStringAPI.cpp into xpcom_core.
Attachment #161899 -
Attachment is obsolete: true
Assignee | ||
Updated•21 years ago
|
Attachment #162233 -
Flags: superreview?(bryner)
Attachment #162233 -
Flags: review?(bsmedberg)
Assignee | ||
Comment 26•21 years ago
|
||
Ugh.. this patch requires a slight modification to build under OSX. It is
necessary when linking libxpcom.dylib to include on the link line all of the
NSPR libraries even though no NSPR methods are used by libxpcom.dylib itself.
Instead, it appears that the linker needs to process all of the dependencies
when linking.
Ok, no problem, but...
This means that the Gecko SDK needs to include libxpcom_core.dylib under OSX.
Or else it means that we need to ship a dummy libxpcom.dylib that has no
dependencies. I'm presuming that at runtime OSX is able to deal with the
dependency of a dependent DYLIB changing. Hmm...
Comment 27•21 years ago
|
||
Comment on attachment 162233 [details] [diff] [review]
v2 patch
As you wish, change _IMPL_NS_STRINGAPI as well as _IMPL_NS_COM and
_IMPL_NS_COM_OBSOLETE to avoid the reserved-for-compilers underscore prefix.
Attachment #162233 -
Flags: review?(bsmedberg) → review+
Updated•21 years ago
|
Attachment #162233 -
Flags: superreview?(bryner) → superreview+
Assignee | ||
Updated•21 years ago
|
Whiteboard: [ready to land]
Assignee | ||
Comment 28•21 years ago
|
||
> As you wish, change _IMPL_NS_STRINGAPI as well as _IMPL_NS_COM and
> _IMPL_NS_COM_OBSOLETE to avoid the reserved-for-compilers underscore prefix.
underscore issue is quite pervasive in xpcom... punting to bug 266011 :-)
Status: NEW → ASSIGNED
Assignee | ||
Comment 29•21 years ago
|
||
fixed-on-trunk
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 30•21 years ago
|
||
I had to disable mfcembed in static builds as a result of this patch. We have
to decide if it is worth it to support static builds of mfcembed -- afterall,
mfcembed is supposed to be an example of how to properly embed gecko! ;-)
![]() |
||
Comment 31•21 years ago
|
||
Either this patch or the patch for bug 263957 or the patch for bug 263903 caused
a Tp regression on btek...
Comment 32•21 years ago
|
||
(In reply to comment #11)
> this patch also includes changes to make mozilla-bin use the new string API
> from the Gecko SDK instead of linking a copy of libstring.a -- it's about time
> ;)
Does this mean nsStringStats can get rid of the test for zero alloc count in the
dtor?
(http://lxr.mozilla.org/seamonkey/source/xpcom/string/src/nsSubstring.cpp#72)
![]() |
||
Comment 33•21 years ago
|
||
Ok, all the performance tests on luna regressed as well (Tp, Tdhtml, Ts, Txul).
Ts regressed on comet, and Txul went up on beast.
Chances are, this patch is the reason, since the other two patches really should
not have affected Tdhtml.
Assignee | ||
Comment 34•21 years ago
|
||
Yeah, it really can only be this patch that affected our perf numbers. I'm not
sure how since libxpcom.so is not on any critical paths, or so I would have thought.
One possibility is that gklayout and friends are somehow using symbols from
libxpcom.so instead of directly using libxpcom_core.so. It is true that I'm
linking all components against libxpcom.so in addition to libxpcom_core.so, so
it is possible that something odd is happening.
It's hard to imagine that the addition of a virtually unused libxpcom.so would
cause this kind of regression. Hmm...
Assignee | ||
Comment 35•21 years ago
|
||
Hmm... previously all of the string symbols were being loaded from mozilla-bin,
whereas now they are all being loaded from libxpcom_core.so. I wonder if that
could somehow be affecting performance. Hmm...
Assignee | ||
Comment 36•21 years ago
|
||
i filed bug 266071 to track the perf regression issue.
Comment 37•21 years ago
|
||
tinderbox is in flames by build of Camino.
I think that it is necessary to add libxpcom_core to a Xcode project file.
http://lxr.mozilla.org/mozilla/source/camino/Camino.xcode/
Comment 38•21 years ago
|
||
Something in the last 10 days broke my mingw, and I'm blaming this.
c:/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp: In static member function
`static nsresult nsNativeAppSupportWin::GetCmdLineArgs(BYTE*,
nsICmdLineService**)':
c:/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp:1916: `isspace' undeclared
(first use this function)
c:/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp:1916: (Each undeclared
identifier is reported only once for each function it appears in.)
Comment 39•21 years ago
|
||
neil: add a #include for <ctype.h> in nsNativeAppSupportWin.cpp
Comment 40•21 years ago
|
||
This bug may have also caused the 2nd problem in Bug #266087
Comment 41•21 years ago
|
||
(In reply to comment #39)
>neil: add a #include for <ctype.h> in nsNativeAppSupportWin.cpp
Checked in.
Comment 42•21 years ago
|
||
(In reply to comment #39)
> neil: add a #include for <ctype.h> in nsNativeAppSupportWin.cpp
That didn't fix it for me, however Darin over in
http://bugzilla.mozilla.org/show_bug.cgi?id=266087#c5
has checked in a fix for nsWindowCreator.cpp
Comment 43•21 years ago
|
||
Bug 266214 comment 4 suggests that the fix here broke the FF trunk installer in
bug 266149, and caused the smoketest blocker Seamonkey bug 266214 (browser will
not launch after install).
Comment 44•21 years ago
|
||
Darin or Mike: xpcom/build/nsOS2VACLegacy.cpp is linked into XPCOMCOR.DLL
instead of XPCOM.DLL. This causes a SYS2070 in npoji6.dll (IBM Java 1.3 plugin)
on termination. Please move the source to XPCOM.DLL.
Comment 45•21 years ago
|
||
the nsStringSupport changes here caused bug 266563 / bug 267313
You need to log in
before you can comment on or make changes to this bug.
Description
•