http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51140

             Bug #: 51140
           Summary: libstdc++-v3/libsupc++/eh_tm.cc:48: undefined
                    reference to `___sync_sub_and_fetch_4'
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: cestra...@gmail.com
              Host: i386-pc-mingw32
            Target: i386-pc-mingw32
             Build: i386-pc-mingw32


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)

Reply via email to