Closed Bug 334866 Opened 14 years ago Closed 14 years ago

Protect against GCC bug 26905 which causes non-relocatable DSOs

Categories

(Firefox Build System :: General, defect)

x86
Linux
defect
Not set

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: benjamin, Assigned: benjamin)

References

()

Details

Attachments

(2 files)

GCC bug 26905 is that class-level visibility declarations do not override pragma visibility specifications. This means that we're generating non-PLT relocations in our DSOs on i386, and x86_64 won't link at all. I have a configure test which appears to protect against this.
Attachment #219195 - Flags: review? → review?(bryner)
Attachment #219195 - Flags: review?(bryner) → review+
Attached patch Fix typoSplinter Review
Attachment #219438 - Flags: review?(bryner)
Attachment #219438 - Flags: review?(bryner) → review+
Typo fix checked in.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Should this go in on the 1.8 branch?  I just lost a bit of time fighting with this using my trunk-tuned mozconfigs.
Flags: blocking1.8.1?
Attachment #219195 - Flags: approval1.8.1+
Attachment #219438 - Flags: approval1.8.1+
Flags: blocking1.8.1? → blocking1.8.1+
Whiteboard: [checkin needed]
This patch does not apply cleanly against 1.8 and I don't particularly want to spend the time to port it.
patch doesn't apply, only affects developers working with newer GCCs, not going to block on this
Flags: blocking1.8.1+ → blocking1.8.1-
Does this really need a checkin on the branch, considering comment 5?
Whiteboard: [checkin needed] → [checkin needed (1.8 branch)]
no
Whiteboard: [checkin needed (1.8 branch)]
It does apply cleanly on firefox 2.0b1 source...
Depends on: 359036
Depends on: 353150
apparantly, I was running into the bug, but the configure test did not detect it (xulrunner trunk from last week). gcc 4.1.0 on SuSE 10.1 x64.
config.cache:ac_cv_visibility_pragma=${ac_cv_visibility_pragma=yes}

Using the example XPCOM component and Makefile from iosart and dougt's book:
c++ -Wall -Os -o MyComponent.so -include mozilla-config.h -DXPCOM_GLUE -DMOZILLA_STRICT_API -I /usr/src/mozilla/xulrunner/debug/dist/sdk//include -L /usr/src/mozilla/xulrunner/debug/dist/sdk//lib  -fno-rtti -fno-exceptions -Wall -Wconversion -Wpointer-arith -Wcast-align -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wno-long-long -pedantic -fshort-wchar -pthread -pipe -shared -fPIC   MyComponent.cpp MyComponentModule.cpp
/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../x86_64-suse-linux/bin/ld: /tmp/ccFATfU2.o: relocation R_X86_64_PC32 against `NS_TableDrivenQI(void*, QITableEntry const*, nsID const&, void**)' can not be used when making a shared object; recompile with -fPIC
/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../x86_64-suse-linux/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make: *** [build] Fehler 1

I'll recompile with "ac_cv_visibility_pragma=no" in .mozconfig as suggested by
http://benjamin.smedbergs.us/blog/2006-03-28/gcc-and-visibility-one-step-forward-hit-a-brick-wall/
and report whether that fixed it.
> I'll recompile with "ac_cv_visibility_pragma=no" in .mozconfig

No, that made matters worse. Now Mozilla doesn't even compile anymore. It does without that flag (I retested with another compile).

Error, for both opt and debug:
/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../x86_64-suse-linux/bin/ld: ../../dist/lib/components/libgklayout.a(nsCanvasRenderingContext2D.o): relocation R_X86_64_PC32 against `_moz_cairo_new_path' can not be used when making a shared object; recompile with -fPIC
/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../x86_64-suse-linux/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
gmake[3]: *** [libxul.so] Fehler 1
gmake[3]: Leaving directory `/mnt/media/mozilla/xulrunner/novisdebug/toolkit/library'

mozconfig used:
ac_add_options --enable-application=xulrunner
mk_add_options MOZ_CO_PROJECT=xulrunner
#build
ac_add_options --enable-optimize=-Os --disable-debug
#ac_add_options --disable-optimize --enable-debug
ac_add_options --disable-static --enable-shared
#components
ac_add_options --enable-extensions=default,inspector,venkman,webservices,xml-rpc
,xmlterm,xmlextras,cview
#doesn't work: sql,webdav,canvas3d,jssh
ac_add_options --disable-javaxpcom

#bug 334866
ac_cv_visibility_pragma=no


In all cases (with and without ac_cv_visibility_pragma=no), I am getting the error mentioned in my last comment when trying to compile my own XPCOM module outside the Mozilla tree.
> c++ -Wall -Os -o MyComponent.so -include mozilla-config.h -DXPCOM_GLUE
> -DMOZILLA_STRICT_API -I /usr/src/mozilla/xulrunner/debug/dist/sdk//include -L
> /usr/src/mozilla/xulrunner/debug/dist/sdk//lib  -fno-rtti -fno-exceptions -Wall
> -Wconversion -Wpointer-arith -Wcast-align -Woverloaded-virtual -Wsynth
> -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wno-long-long -pedantic
> -fshort-wchar -pthread -pipe -shared -fPIC   MyComponent.cpp
> MyComponentModule.cpp

I don't see you linking against -lxpcomglue, which would leave missing symbols. These are reported with the misleading "relocation X can't be used" error message.

Please let's use a new bug for new issues, in any case. The cairo-libxul linkage error may be a real bug in libxul.
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.