Closed Bug 277818 Opened 20 years ago Closed 17 years ago

Remove runtime dependency on libstdc++.so

Categories

(Firefox Build System :: General, enhancement, P3)

x86
Linux
enhancement

Tracking

(Not tracked)

RESOLVED WONTFIX
mozilla1.9alpha1

People

(Reporter: darin.moz, Assigned: benjamin)

Details

Remove runtime dependency on libstdc++.so

For minimo, we already link against libsupc++.a instead of requiring
libstdc++.so.  It seems that this (or something similar) would be beneficial for
our regular linux builds as well since libstdc++.so ABI compatibility can be a
pain.  

libsupc++.a seems to pull in some extra code having to do with exception
handling that is not needed by mozilla, so it might be worth it to create our
own static library that only implements the functions that we actually need
(like operator new, operator delete, the array versions, and anything else).

Just for kicks I built xpcom with CXX=gcc and linked an object file created from
the following source:

extern "C"
__attribute__ ((visibility ("hidden")))
int __cxa_pure_virtual() { abort(); return 0; }
                                                                               
             
extern "C"
__attribute__ ((visibility ("hidden")))
void *operator new(size_t s) { return malloc(s); }
                                                                               
             
extern "C"
__attribute__ ((visibility ("hidden")))
void operator delete(void *p) { return free(p); }
                                                                               
             
extern "C"
__attribute__ ((visibility ("hidden")))
void *operator new[](size_t s) { return malloc(s); }
                                                                               
             
extern "C"
__attribute__ ((visibility ("hidden")))
void operator delete[](void *p) { return free(p); }

It seemed to work just fine.  Perhaps we could create this special object file
as part of the build process under mozilla/config, and then include it on the
link line with each DSO and executable that we generate.
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.8beta
maybe i'll get around to implementing this during the 1.9 cycle.
Severity: normal → enhancement
Target Milestone: mozilla1.8beta1 → mozilla1.9alpha1
Target Milestone: mozilla1.9alpha1 → ---
Assignee: darin → nobody
Status: ASSIGNED → NEW
Assignee: nobody → benjamin
Priority: -- → P3
Product: Mozilla Application Suite → Core
Target Milestone: --- → mozilla1.9alpha
If I run ldd against 'minimo' executable it still displays libstdc++6.so as a runtime dependecy (see bellow)

...
    libgconf-2.so.4 => /usr/lib/libgconf-2.so.4 (0xb76c4000)
    libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0xb76c0000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb75f0000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb75e8000)
    libc.so.6 => /lib/libc.so.6 (0xb74c9000)
    /lib/ld-linux.so.2 (0xb7fe8000)
...

I am building 'minimo' with default linux_x86 mozconfig file (minimo/config/mozconfig/linux_x86) and I've noticed that last two lines (which seems to do the trick you mentioned previously) are commented out (see http://lxr.mozilla.org/mozilla1.8/source/minimo/config/mozconfig/linux_x86#23). If I added then again, minimo build fails trolling lots of new/delete undefined reference like this:

._ZN13nsPluginArrayD0Ev+0x49): undefined reference to `operator delete[](void*)'
../../dist/lib/components/libgklayout.a(nsPluginArray.o): In function `nsPluginElement::~nsPluginElement()':nsPluginArray.cpp:(.text._ZN15nsPluginElementD2Ev+0x57): undefined reference to `operator delete[](void*)'
../../dist/lib/components/libgklayout.a(nsPluginArray.o): In function `nsPluginElement::~nsPluginElement()':nsPluginArray.cpp:(.text._ZN15nsPluginElementD1Ev+0x57): undefined reference to `operator delete[](void*)'
../../dist/lib/components/libgklayout.a(nsPluginArray.o):nsPluginArray.cpp:(.text._ZN15nsPluginElementD0Ev+0x57): more undefined references to `operator delete[](void*)' follow
../../dist/lib/components/libgklayout.a(nsPluginArray.o): In function `nsPluginArray::GetPlugins()':nsPluginArray.cpp:(.text._ZN13nsPluginArray10GetPluginsEv+0x25): undefined reference to `operator new[](unsigned int)'
../../dist/lib/components/libgklayout.a(nsPluginArray.o): In function `nsPluginArray::Refresh(int)':nsPluginArray.cpp:(.text._ZN13nsPluginArray7RefreshEi+0x114): undefined reference to `operator delete[](void*)'
../../dist/lib/components/libgklayout.a(nsPluginArray.o): In function `nsPluginElement::GetMimeTypes()':nsPluginArray.cpp:(.text._ZN15nsPluginElement12GetMimeTypesEv+0x30): undefined reference to `operator new[](unsigned int)'
../../dist/lib/components/libgklayout.a(nsGrid.o): In function `nsGrid::FreeMap()':nsGrid.cpp:(.text._ZN6nsGrid7FreeMapEv+0x2e): undefined reference to `operator delete[](void*)'
:nsGrid.cpp:(.text._ZN6nsGrid7FreeMapEv+0x59): undefined reference to `operator delete[](void*)'
:nsGrid.cpp:(.text._ZN6nsGrid7FreeMapEv+0x83): undefined reference to `operator delete[](void*)'
../../dist/lib/components/libgklayout.a(nsGrid.o): In function `nsGrid::BuildCellMap(int, int, nsGridCell**)':nsGrid.cpp:(.text._ZN6nsGrid12BuildCellMapEiiPP10nsGridCell+0x46): undefined reference to `operator delete[](void*)'
:nsGrid.cpp:(.text._ZN6nsGrid12BuildCellMapEiiPP10nsGridCell+0x83): undefined reference to `operator delete[](void*)'
:nsGrid.cpp:(.text._ZN6nsGrid12BuildCellMapEiiPP10nsGridCell+0x91): undefined reference to `operator new[](unsigned int)'
../../dist/lib/components/libgklayout.a(nsGrid.o): In function `nsGrid::BuildRows(nsIFrame*, int, nsGridRow**, int)':nsGrid.cpp:(.text._ZN6nsGrid9BuildRowsEP8nsIFrameiPP9nsGridRowi+0x3c): undefined reference to `operator delete[](void*)'
:nsGrid.cpp:(.text._ZN6nsGrid9BuildRowsEP8nsIFrameiPP9nsGridRowi+0x87): undefined reference to `operator delete[](void*)'
:nsGrid.cpp:(.text._ZN6nsGrid9BuildRowsEP8nsIFrameiPP9nsGridRowi+0x95): undefined reference to `operator new[](unsigned int)'
:nsGrid.cpp:(.text._ZN6nsGrid9BuildRowsEP8nsIFrameiPP9nsGridRowi+0x116): undefined reference to `operator delete[](void*)'
:nsGrid.cpp:(.text._ZN6nsGrid9BuildRowsEP8nsIFrameiPP9nsGridRowi+0x124): undefined reference to `operator new[](unsigned int)'
../../dist/lib/components/libgklayout.a(nsXULSortService.o): In function `XULSortServiceImpl::SortContainer(nsIContent*, _sortStruct*, int)':nsXULSortService.cpp:(.text._ZN18XULSortServiceImpl13SortContainerEP10nsIContentP11_sortStructi+0x5f): undefined reference to `operator new[](unsigned int)'
:nsXULSortService.cpp:(.text._ZN18XULSortServiceImpl13SortContainerEP10nsIContentP11_sortStructi+0x5b8): undefined reference to `operator delete[](void*)'
../../dist/lib/components/libgklayout.a(nsBlockBandData.o): In function `nsBlockBandData::~nsBlockBandData()':nsBlockBandData.cpp:(.text._ZN15nsBlockBandDataD2Ev+0x19): undefined reference to `operator delete[](void*)'
../../dist/lib/components/libgklayout.a(nsBlockBandData.o): In function `nsBlockBandData::~nsBlockBandData()':nsBlockBandData.cpp:(.text._ZN15nsBlockBandDataD1Ev+0x19): undefined reference to `operator delete[](void*)'
../../dist/lib/components/libgklayout.a(nsBlockBandData.o): In function `nsBlockBandData::GetBandData(int, int)':nsBlockBandData.cpp:(.text._ZN15nsBlockBandData11GetBandDataEii+0x69): undefined reference to `operator delete[](void*)'
:nsBlockBandData.cpp:(.text._ZN15nsBlockBandData11GetBandDataEii+0x83): undefined reference to `operator new[](unsigned int)'

you said it was working before, So, How could I get it working back ?

PS: I am running from MOZILLA_1_8_BRANCH
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → WONTFIX
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.