GCC4.0 – relocation R_X86_64_PC32 against `memcpy@@GLIBC_2.2.5′ can not be used

There is a bug in GCC 4.0 (and 4.0.1 and 4.1) which breaks the Mozilla/Firefox/Thunderbird build on x86_64 and various other processors: GCC is treating the builtin functions such as “memset” and “memcpy” as having hidden visibility in certain circumstances that are hard to figure out. GCC bug 20297 covers the issue, though the patch in the bug doesn’t fix all the problems and I haven’t seen any action by the GCC maintainers to get the patch landed or fixed. I tried to provide a patch to detect this bug in Mozilla bug 307168, but apparently my configure test is not good enough to catch all instances of the bug.

In the meantime, if you experience the error “relocation R_X86_64_PC32 against `memcpy@@GLIBC_2.2.5′ can not be used” or something similar while building mozilla, use the following hackaround:

ac_cv_visibility_pragma=no path/to/mozilla/configure --enable-options-here

or put this in your mozconfig:

ac_cv_visibility_pragma=no (Don’t prefix this with ac_add_options!)

Atom Feed for Comments 17 Responses to “GCC4.0 – relocation R_X86_64_PC32 against `memcpy@@GLIBC_2.2.5′ can not be used”

  1. gandalf Says:

    Thankssssssssss! Finally, I’ll be able to do coding on my laptop *^^*

  2. James Curbo's Weblog Says:

    Error building Firefox on Linux amd64

    I’ve been trying to build Firefox on Debian amd64 for a while and keep getting the same error, a compiler error containing ‘relocation R_X86_64_PC32 against `memcpy@@GLIBC_2.2.5′. Benjamin Smedberg wrote about a solution so I thought I’d at leas…

  3. James Says:

    thunderbird-1.5rc1 compiles but unfortunately it won’t run. :-(
    It always shows an “Thunderbird is already running, but is not responding…” dialog even after rebooting.


  4. James Says:

    Yay, it worked for “firefox-1.5rc1″.
    I am running a compiled 64-bit version right now.
    Hopefully I can fix thunderbird.

  5. nau10 Says:

    I also have a “Thunderbird is already running, but is not responding…” message. did you get any resolution about this?

  6. Martin Mueller Says:

    Thanks a lot, Ben — with your hints I was able to compile Thunderbird 1.5rc1 on my SuSE 10.0, x86_64 system!
    Regarding the “not responding” issues: Have you guys tried removing the file .parentlock (or so) in your profile directory? It sometimes stays there when TB chrashes…

  7. Peter Says:

    Thanks a lot for your tip! Thunderbird compile is running now!

  8. oneir Says:

    thanks for that tip, but the compilation of firefox 1.5 is still bombing for me. (It does proceed much further than before and I don’t see the ‘relocation R_X86_64_PC32 against `memcpy@@GLIBC_2.2.5′ error anymore).

    Now there is this error:
    nsAppShell.cpp: In member function ‘virtual nsresult nsAppShell::ListenToEventQueue(nsIEventQueue*, PRBool)’:
    nsAppShell.cpp:230: error: cast from ‘void*’ to ‘gint’ loses precision
    nsAppShell.cpp:237: error: cast from ‘void*’ to ‘gint’ loses precision
    nsAppShell.cpp:242: error: cast from ‘void*’ to ‘guint’ loses precision
    gmake[4]: *** [nsAppShell.o] Error 1
    gmake[4]: Leaving directory `/usr/local/src/mozilla/widget/src/gtk2′
    gmake[3]: *** [libs] Error 2
    gmake[3]: Leaving directory `/usr/local/src/mozilla/widget/src’
    gmake[2]: *** [libs] Error 2
    gmake[2]: Leaving directory `/usr/local/src/mozilla/widget’
    gmake[1]: *** [tier_9] Error 2
    gmake[1]: Leaving directory `/usr/local/src/mozilla’
    make: *** [default] Error 2

    This is on the AMD64x2 cpu, using Mandriva compiled kernel 2.6.12-14mdksmp
    and gcc-4.0.1 packages supplied by the same vendor. The mozconfig options were as follows (uncommenting the commented lines has had no effect)

    ac_add_options –enable-application=browser
    #ac_add_options –enable-optimize
    ac_add_options –disable-debug
    ac_add_options –enable-default-toolkit=gtk2
    ac_add_options –enable-xft
    #ac_add_options –enable-static
    #ac_add_options –disable-shared
    ac_add_options –enable-extensions=default

    Somehow I get the feeling that I bought the best processor only to have the worst support from the opensource/freesoftware community.

  9. Benjamin Smedberg Says:

    oneir, the source is using the GPOINTER_TO_INT macro, which should handle the 64-bit pointer conversions (compilation works on my AMD64 machine FC4 with gcc4.02). http://lxr.mozilla.org/mozilla/source/widget/src/gtk2/nsAppShell.cpp#230

  10. Mark Hammond Says:

    I had a similar problem the only fix I could find was to completely remove firefox and redo. I found instructions on how to clean out a firefox install here:

  11. Jeff Shaklon Says:

    Thanks for the Firefox fix and link to the lister.com website. I followed the link above and now firefox is working again.

  12. BSBlog » Blog Archive » GCC and visibility: one step forward, hit a brick wall Says:

    [...] A while back, I posted a workaround that lets Mozilla compile and link properly, working around a bug that is present in GCC 4. I am happy to report that the GCC bug has been fixed on the GCC trunk, 4.1 branch, and 4.0 branch (it should appear in GCC4.0.4 and 4.1.1). I was very excited and immediately went off to build my own GCC and try to build XULRunner with it. No dice! Linking failed in toolkit/library with a similar error as before: [...]

  13. Building firefox and mozilla tools on an AMD64 @ IONCANNON Says:

    [...] Recently I was trying to build firefox from source along with XULRunner so that I could try out JavaXPCOM. The first problem I ran into was a GCC 4 bug that breaks the build. Luckily someone out there had an easy fix for the problem (see GCC4.0 – relocation R_X86_64_PC32 against memcpy@@GLIBC_2.2.5 can not be used). After getting that problem fixed an a little fight with setting up XULRunner I got a very simple program working. That is when the 2nd problem showed up. When I tried to use some of the GUI functions I started getting core dumps from within GTK2. At that point I gave up and moved to my laptop. The same code worked right off using my laptop. [...]

  14. Werner Flamme Says:

    Ben, this tip works like a charm :-) I finally managed to get over the ‘memset’ hurdle ;-). I use SUSE Linux x86_64 and had to remove the line “ac_add_options –enable-optimize” to get it running. (gcc version 4.0.3 20051024 (prerelease)) Thank you!

  15. Michael Says:

    PHP-5.2.0 source compile fails on AMD64 (ubuntu606) with MySQL-5.0.27 from source with this error:
    /usr/bin/ld: /usr/local/mysql/lib/mysql/libmysqld.a(mf_qsort.o): relocation R_X86_64_PC32 against `memcpy@@GLIBC_2.2.5′ can not be used when making a shared object; recompile with -fPIC

    These things always make me realize how much more I need to learn. Meanwhile I’m stuck with guessing with options to remove. MySQLI is my next guess.

  16. pgf Says:

    Hello and THANK YOU….

    clfs, blfs pages need to link to your page… thanks again.

  17. fccaner Says:

    Hello, and thanks a lot… I guess the people who left these messages above are the only people who compile mozilla products other than the mozilla developers… or others who compile them are much smarter (which I doubt).
    Thanks again.

Leave a Reply