[vbox-dev] Remove a hack in bsd which disable -O2 in VBoxSVC
Howard Su
howard0su at gmail.com
Thu Feb 10 20:09:58 PST 2011
On Fri, Feb 11, 2011 at 11:01 AM, Howard Su <howard0su at gmail.com> wrote:
> The odd link error in freebsd is due to a GCC bug.
> (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37770)
>
> The following patch is just a hack which shows the fix. I think the
> real fix should remove nsModuleComponentInfoEx type, which is an
> overkill to me.
>
> -Jun
>
> Index: src/VBox/Main/src-server/xpcom/server.cpp
> ===================================================================
> --- src/VBox/Main/src-server/xpcom/server.cpp (revision 35903)
> +++ src/VBox/Main/src-server/xpcom/server.cpp (working copy)
> @@ -662,24 +662,7 @@
>
> ////////////////////////////////////////////////////////////////////////////////
>
> -static const nsModuleComponentInfoEx components[] =
> -{
> - nsModuleComponentInfoEx(
> - "VirtualBox component",
> - CLSID_VirtualBox,
> - NS_VIRTUALBOX_CONTRACTID,
> - VirtualBoxConstructor, // constructor function
> - NULL, // registration function
> - NULL, // deregistration function
> - VirtualBoxClassFactory::FactoryDestructor, // factory
> destructor function
> - NS_CI_INTERFACE_GETTER_NAME(VirtualBox),
> - NULL, // language helper
> - &NS_CLASSINFO_NAME(VirtualBox),
> - 0, // flags
> - VirtualBoxClassFactory::FactoryConstructor // factory
> constructor function
> - )
> -};
> -
> +static const nsModuleComponentInfoEx components[1];
> /////////////////////////////////////////////////////////////////////////////
>
> /**
> @@ -716,6 +699,22 @@
> PRUint32 count)
> {
> nsresult rc = NS_OK;
> + components[0] = new nsModuleComponentInfoEx(
> + "VirtualBox component",
> + CLSID_VirtualBox,
> + NS_VIRTUALBOX_CONTRACTID,
> + VirtualBoxConstructor, // constructor function
> + NULL, // registration function
> + NULL, // deregistration function
> + VirtualBoxClassFactory::FactoryDestructor, // factory
> destructor function
> + NS_CI_INTERFACE_GETTER_NAME(VirtualBox),
> + NULL, // language helper
> + &NS_CLASSINFO_NAME(VirtualBox),
> + 0, // flags
> + VirtualBoxClassFactory::FactoryConstructor // factory
> constructor function
> + );
> +
> +
> const nsModuleComponentInfoEx *info = aComponents;
> for (PRUint32 i = 0; i < count && NS_SUCCEEDED(rc); i++, info++)
> {
> Index: src/VBox/Main/Makefile.kmk
> ===================================================================
> --- src/VBox/Main/Makefile.kmk (revision 35903)
> +++ src/VBox/Main/Makefile.kmk (working copy)
> @@ -247,7 +247,7 @@
> ## @todo We're disabling optimizations on FreeBSD to work around strange linker
> # errors in release builds. Figure out why and how to work
> around it in a
> # more optimal fashion.
> -VBoxSVC_CXXFLAGS.freebsd = -O0
> +#VBoxSVC_CXXFLAGS.freebsd = -O0
>
> VBoxSVC_INCS = \
> include \
>
>
> --
> -Howard
>
Basically, you can not initialize a static structure with a ctor of a class.
a better fix will be:
Index: src/VBox/Main/src-server/xpcom/server.cpp
===================================================================
--- src/VBox/Main/src-server/xpcom/server.cpp (revision 35903)
+++ src/VBox/Main/src-server/xpcom/server.cpp (working copy)
@@ -662,24 +662,7 @@
////////////////////////////////////////////////////////////////////////////////
-static const nsModuleComponentInfoEx components[] =
-{
- nsModuleComponentInfoEx(
- "VirtualBox component",
- CLSID_VirtualBox,
- NS_VIRTUALBOX_CONTRACTID,
- VirtualBoxConstructor, // constructor function
- NULL, // registration function
- NULL, // deregistration function
- VirtualBoxClassFactory::FactoryDestructor, // factory
destructor function
- NS_CI_INTERFACE_GETTER_NAME(VirtualBox),
- NULL, // language helper
- &NS_CLASSINFO_NAME(VirtualBox),
- 0, // flags
- VirtualBoxClassFactory::FactoryConstructor // factory
constructor function
- )
-};
-
+static const nsModuleComponentInfoEx components[1];
/////////////////////////////////////////////////////////////////////////////
/**
@@ -711,29 +694,36 @@
* of the out-of-proc server.
*/
static nsresult
-RegisterSelfComponents(nsIComponentRegistrar *registrar,
- const nsModuleComponentInfoEx *aComponents,
- PRUint32 count)
+RegisterSelfComponents(nsIComponentRegistrar *registrar)
{
nsresult rc = NS_OK;
- const nsModuleComponentInfoEx *info = aComponents;
- for (PRUint32 i = 0; i < count && NS_SUCCEEDED(rc); i++, info++)
- {
- /* skip components w/o a constructor */
- if (!info->mConstructor)
- continue;
+ const nsModuleComponentInfoEx info(
+ "VirtualBox component",
+ CLSID_VirtualBox,
+ NS_VIRTUALBOX_CONTRACTID,
+ VirtualBoxConstructor, // constructor function
+ NULL, // registration function
+ NULL, // deregistration function
+ VirtualBoxClassFactory::FactoryDestructor, // factory
destructor function
+ NS_CI_INTERFACE_GETTER_NAME(VirtualBox),
+ NULL, // language helper
+ &NS_CLASSINFO_NAME(VirtualBox),
+ 0, // flags
+ VirtualBoxClassFactory::FactoryConstructor // factory
constructor function
+ );
+
+
/* create a new generic factory for a component and register it */
nsIGenericFactory *factory;
- rc = NS_NewGenericFactoryEx(&factory, info);
+ rc = NS_NewGenericFactoryEx(&factory, &info);
if (NS_SUCCEEDED(rc))
{
- rc = registrar->RegisterFactory(info->mCID,
- info->mDescription,
- info->mContractID,
+ rc = registrar->RegisterFactory(info.mCID,
+ info.mDescription,
+ info.mContractID,
factory);
factory->Release();
}
- }
return rc;
}
@@ -941,8 +931,7 @@
}
registrar->AutoRegister(nsnull);
- rc = RegisterSelfComponents(registrar, components,
- NS_ARRAY_LENGTH (components));
+ rc = RegisterSelfComponents(registrar);
if (NS_FAILED(rc))
{
RTMsgError("Failed to register server components! (rc=%Rhrc)", rc);
Index: src/VBox/Main/Makefile.kmk
===================================================================
--- src/VBox/Main/Makefile.kmk (revision 35903)
+++ src/VBox/Main/Makefile.kmk (working copy)
@@ -247,7 +247,7 @@
## @todo We're disabling optimizations on FreeBSD to work around strange linker
# errors in release builds. Figure out why and how to work
around it in a
# more optimal fashion.
-VBoxSVC_CXXFLAGS.freebsd = -O0
+#VBoxSVC_CXXFLAGS.freebsd = -O0
VBoxSVC_INCS = \
include \
--
-Howard
More information about the vbox-dev
mailing list