LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   6.9 compiling glibc, fails on make due to undefined references in functions (https://www.linuxquestions.org/questions/linux-from-scratch-13/6-9-compiling-glibc-fails-on-make-due-to-undefined-references-in-functions-799726/)

nescalona 04-03-2010 01:17 AM

6.9 compiling glibc, fails on make due to undefined references in functions
 
I'm using the latest LFS book, compiling glibc-2.11.1 for my system (http://www.linuxfromscratch.org/lfs/...r06/glibc.html). I'm also using Matthias Benkmann's package user setup for package management. (http://www.linuxfromscratch.org/hint...nd_pkg_man.txt) That means that I am not compiling glibc as root.

This is the end of the output from make, the things it was doing when it failed. As you can see: a lot of undefined references to things with names beginning with "__sync" in functions in libc_pic.os.

Thanks!

Code:

gcc  -shared -static-libgcc -Wl,-O1  -Wl,-z,defs -Wl,-dynamic-linker=/lib/ld-linux.so.2  -B/sources/glibc-build/csu/  -Wl,--version-script=/sources/glibc-build/libc.map -Wl,-soname=libc.so.6 -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -nostdlib -nostartfiles -e __libc_main -L/sources/glibc-build -L/sources/glibc-build/math -L/sources/glibc-build/elf -L/sources/glibc-build/dlfcn -L/sources/glibc-build/nss -L/sources/glibc-build/nis -L/sources/glibc-build/rt -L/sources/glibc-build/resolv -L/sources/glibc-build/crypt -L/sources/glibc-build/nptl -Wl,-rpath-link=/sources/glibc-build:/sources/glibc-build/math:/sources/glibc-build/elf:/sources/glibc-build/dlfcn:/sources/glibc-build/nss:/sources/glibc-build/nis:/sources/glibc-build/rt:/sources/glibc-build/resolv:/sources/glibc-build/crypt:/sources/glibc-build/nptl -o /sources/glibc-build/libc.so -T /sources/glibc-build/shlib.lds /sources/glibc-build/csu/abi-note.o /sources/glibc-build/elf/soinit.os /sources/glibc-build/libc_pic.os /sources/glibc-build/elf/sofini.os /sources/glibc-build/elf/interp.os /sources/glibc-build/elf/ld.so -lgcc
/sources/glibc-build/libc_pic.os: In function `__libc_fork':
/sources/glibc-2.11.1/posix/../nptl/sysdeps/unix/sysv/linux/i386/../fork.c:79: undefined reference to `__sync_bool_compare_and_swap_4'
/sources/glibc-build/libc_pic.os: In function `__nscd_drop_map_ref':
/sources/glibc-2.11.1/nscd/nscd-client.h:320: undefined reference to `__sync_fetch_and_add_4'
/sources/glibc-build/libc_pic.os: In function `nscd_getpw_r':
/sources/glibc-2.11.1/nscd/nscd_getpw_r.c:233: undefined reference to `__sync_fetch_and_add_4'
/sources/glibc-build/libc_pic.os: In function `__nscd_drop_map_ref':
/sources/glibc-2.11.1/nscd/nscd-client.h:320: undefined reference to `__sync_fetch_and_add_4'
/sources/glibc-build/libc_pic.os: In function `nscd_getgr_r':
/sources/glibc-2.11.1/nscd/nscd_getgr_r.c:322: undefined reference to `__sync_fetch_and_add_4'
/sources/glibc-build/libc_pic.os: In function `__nscd_drop_map_ref':
/sources/glibc-2.11.1/nscd/nscd-client.h:320: undefined reference to `__sync_fetch_and_add_4'
/sources/glibc-build/libc_pic.os:/sources/glibc-2.11.1/nscd/nscd_gethst_r.c:415: more undefined references to `__sync_fetch_and_add_4' follow
/sources/glibc-build/libc_pic.os: In function `__nscd_get_map_ref':
/sources/glibc-2.11.1/nscd/nscd_helper.c:433: undefined reference to `__sync_val_compare_and_swap_4'
/sources/glibc-build/libc_pic.os: In function `*__GI___libc_freeres':
/sources/glibc-2.11.1/malloc/set-freeres.c:39: undefined reference to `__sync_bool_compare_and_swap_4'
collect2: ld returned 1 exit status
make[1]: *** [/sources/glibc-build/libc.so] Error 1
make[1]: Leaving directory `/sources/glibc-2.11.1'
make: *** [all] Error 2

Note: unlike the guy here (http://www.linuxquestions.org/questi...11-1-a-798342/), I didn't have any trouble with this when I was building the toolchain in chapter 5.

10110111 04-03-2010 01:26 AM

Maybe this will help:
http://sources.redhat.com/ml/libc-al.../msg00009.html

nescalona 04-03-2010 01:42 AM

I did pass -march=i486 to the compiler. I appended it to CFLAGS using configparms, as detailed in the link to the LFS book page in my first post.

Code:

$ case `uname -m` in
> i?86) echo "CFLAGS += -march=i486 -mtune=native -O3 -pipe" > configparms ;;
> esac

EDIT: strange. the problem disappeared, not when i recompiled the second time, but when i recompiled the third time.

maybe it was a typo? sorry to waste y'all's time.

10110111 04-03-2010 01:58 AM

OK. Test gcc with this:
Code:

cd /tmp
cat > test.c << EOF
int main()
{
int a;
return __sync_bool_compare_and_swap(&a,0,1);
}
EOF
gcc test.c -o test -march=i486

If this gives an error, then you have compiled gcc without "--with-arch=486 or higher" as said here:
http://old.nabble.com/Re:--ct-ng--build-error:-undefined-reference-to---`__sync_bool_compare_and_swap_4'-p17875951.html


All times are GMT -5. The time now is 09:11 AM.