Bug 51140 - libstdc++-v3/libsupc++/eh_tm.cc:48: undefined reference to `___sync_sub_and_fetch_4'
Summary: libstdc++-v3/libsupc++/eh_tm.cc:48: undefined reference to `___sync_sub_and_f...
Status: RESOLVED DUPLICATE of bug 51181
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-15 12:35 UTC by Cesar Strauss
Modified: 2011-11-22 21:32 UTC (History)
3 users (show)

See Also:
Host: i386-pc-mingw32
Target: i386-pc-mingw32
Build: i386-pc-mingw32
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cesar Strauss 2011-11-15 12:35:05 UTC
Building 4.7.0 (trunk) on i368-pc-mingw32 fails with:

Creating library file: .libs/libstdc++.dll.a../libsupc++/.libs/libsupc++convenience.a(eh_tm.o): In function `free_any_cxa_exception':
c:\projetos\gcc\bld\svn\bld\mingw32\libstdc++-v3\libsupc++/../../../../../../gcc-svn/libstdc++-v3/libsupc++/eh_tm.cc:48: undefined reference to `___sync_sub_and_fetch_4'
collect2.exe: error: ld returned 1 exit status

make[5]: *** [libstdc++.la] Error 1
make[5]: Leaving directory `/projetos/gcc/bld/svn/bld/mingw32/libstdc++-v3/src'
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory `/projetos/gcc/bld/svn/bld/mingw32/libstdc++-v3'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/projetos/gcc/bld/svn/bld/mingw32/libstdc++-v3'
make[2]: *** [all-stage1-target-libstdc++-v3] Error 2
make[2]: Leaving directory `/projetos/gcc/bld/svn/bld'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/projetos/gcc/bld/svn/bld'
make: *** [all] Error 2

The line in question is:

  if (__sync_sub_and_fetch (&h->referenceCount, 1) == 0)

There is another use of __sync_sub_and_fetch in libstdc++-v3/libsupc++/eh_tm.cc, and there it is guarded by a #ifdef _GLIBCXX_ATOMIC_BUILTINS_4, which is undefined in my case. I guess this guard is missing from eh_tm.cc.

$ gcc -v
Using built-in specs.
COLLECT_GCC=\mingw\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.5.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.5.2/configure --enable-languages=c,c++,ada,fortran,obj
c,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgo
mp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-r
untime-libs --disable-werror --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.5.2 (GCC)
Comment 1 Cesar Strauss 2011-11-15 12:39:50 UTC
(In reply to comment #0)
> There is another use of __sync_sub_and_fetch in
> libstdc++-v3/libsupc++/eh_tm.cc,

I meant libstdc++-v3/libsupc++/eh_throw.cc.

> and there it is guarded by a #ifdef  _GLIBCXX_ATOMIC_BUILTINS_4,
> which is undefined in my case. I guess this guard
> is missing from eh_tm.cc.
Comment 2 Jonathan Wakely 2011-11-15 13:12:20 UTC
That guard should be added to eh_tm.cc but ...

don't build for i386-* because that targets the 80386 processor, which doesn't have the required atomic operations, and I *really doubt you're running on an 80386 so there's no reason to unnecessary cripple your code.

you should configure for i486-pc-mingw32 or better, whatever is the lowest spec you want to be able to run the generated code on
Comment 3 Paolo Carlini 2011-11-18 00:06:59 UTC
I suppose this is a duplicate of PR51181
Comment 4 Cesar Strauss 2011-11-22 21:32:33 UTC
(In reply to comment #3)
> I suppose this is a duplicate of PR51181

Indeed. The fix for PR51181 also fixed the build failure I reported here.

Thanks,
Cesar

*** This bug has been marked as a duplicate of bug 51181 ***