undefined reference to sync_fetch_and_add_4

会有一股神秘感。 提交于 2019-12-01 20:45:50

Using -march=i486 flag did the trick for me.

Try using a more recent GCC compiler (e.g. GCC 4.6). I tried to compile with gcc -S -O3 -m32 -fverbose-asm sync-3.c the test file gcc/testsuite/gcc.c-torture/compile/sync-3.c and it works. My gcc (on Debian/Sid/AMD64) is the system gcc 4.6.2 compiler.

hahah! there are 5+ "standard atomic libs" (+kernel support) that's hardly atom ic if you ask me. but ignore it, is all a timely distraction.

so your building, ie glibc and get that error (i did)

glibc-2.11.x expects gcc-4.4.x to define it internally, and you have gcc sans bu ilt-in atomic, likely you didnt specify arch that gcc accepts (due to lacky dire ctions). were glibc likes 786, gcc wants 386 and figures 786 maybe. use "nativ e" should do it. opt(march) and opt(mtune) ARE NON OPTIONAL gcc builds wrong w/ o them (likely)

you won't find a header or libfoo that defines it (per say)

for linux-gnu you might use (a simple for moi build)

cd gcc-4.4.foo
./configure --with-glibc-version=2.11 --enable-threads=posix \
--disable-cloog --disable-ppl --disable-libssp --enable-__cxa_atexit \
--disable-rpath --disable-nls --disable-bootstrp --disable-multilib \
--with-system-libunwind

IMPORTANT: if you build gcc w/o mtune march right, gcc wont define sync_fetch_and_add (p.s. glibc sync_fetch_and_add_4 is just macro for sync_fetch_and_add which, aga in, glibc expects is defined)

also if you replace gcc-3.foo with gcc-4.4.foo and are compiling you may need:

[ -n "$newgnu" ] && CFLAGS="$CFLAGS -march=native -mtune=native "
[ -n "$newgnu" ] && \
CFLAGS="$CFLAGS -std=gnu89 " && CPPFLAGS="$CPPFLAGS -std=gnu89 "

i newly need this (newgnu) to build binutils-ver/: -Wstrict-aliasing=0

cd glibc-2.foo/
./configure  --with-headers=/usr/src/linux/usr/include \
--enable-kernel=2.2.foo \
--disable-profile --disable-sanity-checks --with-tls \
--disable-rpath --disable-nls
  • thanks guy in holland for posting --std that might be an issue for gcc upgraders !

  • no thanks to comittees continually changing and also creating "standards" that make depends problems in gcc :( use .h or .c appropriately for foo "builtin" to add features you want in your code like everyone else !!

have fun :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!