Using gcc 4.9.3 I can using the native gcc build ASAN: # > gcc -fsanitize=address mmap.c # > However, using a ppc32 cross gcc build with crossdev I cannot: # > powerpc-g2.20-linux-gnu-gcc -fsanitize=address mmap.c /usr/libexec/gcc/powerpc-g2.20-linux-gnu/ld: warning: libstdc++.so.6, needed by /usr/lib/gcc/powerpc-g2.20-linux-gnu/4.9.3/libasan.so, not found (try using -rpath or -rpath-link) # > Adding -lstdc++ works though: # > powerpc-g2.20-linux-gnu-gcc -fsanitize=address mmap.c -lstdc++ # > Not sure if this is a bug in upstream gcc or if it has to don with how Gentoo builds cross gcc's
Upstream thinks this is our bug due to how Gentoo installs compilers. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69839
Tried to add /usr/lib/gcc/powerpc-softfloat_4.9.3-linux-gnu/4.9.3 to ldconfig like so: at /usr/powerpc-g2.20-linux-gnu/etc/ld.so.conf # ld.so.conf autogenerated by env-update; make all changes to # contents of /etc/env.d directory /usr/powerpc-g2.20-linux-gnu/lib /usr/lib/gcc/powerpc-softfloat_4.9.3-linux-gnu/4.9.3 Then sudo /usr/powerpc-g2.20-linux-gnu/sbin/ldconfig -v -C /usr/powerpc-g2.20-linux-gnu/etc/ld.so.cache -f /usr/powerpc-g2.20-linux-gnu/etc/ld.so.conf and /usr/powerpc-g2.20-linux-gnu/sbin/ldconfig -v -p -C /usr/powerpc-g2.20-linux-gnu/etc/ld.so.cache 46 libs found in cache `/usr/powerpc-g2.20-linux-gnu/etc/ld.so.cache' libz.so.1 (libc6) => /usr/powerpc-g2.20-linux-gnu/lib/libz.so.1 libutil.so.1 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libutil.so.1 libubsan.so.0 (libc6) => /usr/lib/gcc/powerpc-softfloat_4.9.3-linux-gnu/4.9.3/libubsan.so.0 libubsan.so (libc6) => /usr/lib/gcc/powerpc-softfloat_4.9.3-linux-gnu/4.9.3/libubsan.so libthread_db.so.1 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libthread_db.so.1 libstdc++.so.6 (libc6) => /usr/lib/gcc/powerpc-softfloat_4.9.3-linux-gnu/4.9.3/libstdc++.so.6 libstdc++.so (libc6) => /usr/lib/gcc/powerpc-softfloat_4.9.3-linux-gnu/4.9.3/libstdc++.so librt.so.1 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/librt.so.1 libresolv.so.2 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libresolv.so.2 libreadline.so.6 (libc6) => /usr/powerpc-g2.20-linux-gnu/lib/libreadline.so.6 libpthread.so.0 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libpthread.so.0 libpcprofile.so (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libpcprofile.so libpamc.so.0 (libc6) => /usr/powerpc-g2.20-linux-gnu/lib/libpamc.so.0 libpamc.so (libc6) => /usr/powerpc-g2.20-linux-gnu/lib/libpamc.so libpam_misc.so.0 (libc6) => /usr/powerpc-g2.20-linux-gnu/lib/libpam_misc.so.0 libpam_misc.so (libc6) => /usr/powerpc-g2.20-linux-gnu/lib/libpam_misc.so libpam.so.0 (libc6) => /usr/powerpc-g2.20-linux-gnu/lib/libpam.so.0 libpam.so (libc6) => /usr/powerpc-g2.20-linux-gnu/lib/libpam.so libnss_nisplus.so.2 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libnss_nisplus.so.2 libnss_nis.so.2 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libnss_nis.so.2 libnss_hesiod.so.2 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libnss_hesiod.so.2 libnss_files.so.2 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libnss_files.so.2 libnss_dns.so.2 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libnss_dns.so.2 libnss_db.so.2 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libnss_db.so.2 libnss_compat.so.2 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libnss_compat.so.2 libnsl.so.1 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libnsl.so.1 libncursesw.so.5 (libc6) => /usr/powerpc-g2.20-linux-gnu/lib/libncursesw.so.5 libncurses.so.5 (libc6) => /usr/powerpc-g2.20-linux-gnu/lib/libncurses.so.5 libmemusage.so (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libmemusage.so libm.so.6 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libm.so.6 libitm.so.1 (libc6) => /usr/lib/gcc/powerpc-softfloat_4.9.3-linux-gnu/4.9.3/libitm.so.1 libitm.so (libc6) => /usr/lib/gcc/powerpc-softfloat_4.9.3-linux-gnu/4.9.3/libitm.so libhistory.so.6 (libc6) => /usr/powerpc-g2.20-linux-gnu/lib/libhistory.so.6 libgcc_s.so.1 (libc6) => /usr/lib/gcc/powerpc-softfloat_4.9.3-linux-gnu/4.9.3/libgcc_s.so.1 libdl.so.2 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libdl.so.2 libcrypt.so.1 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libcrypt.so.1 libcidn.so.1 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libcidn.so.1 libc.so.6 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libc.so.6 libatomic.so.1 (libc6) => /usr/lib/gcc/powerpc-softfloat_4.9.3-linux-gnu/4.9.3/libatomic.so.1 libatomic.so (libc6) => /usr/lib/gcc/powerpc-softfloat_4.9.3-linux-gnu/4.9.3/libatomic.so libasan.so.1 (libc6) => /usr/lib/gcc/powerpc-softfloat_4.9.3-linux-gnu/4.9.3/libasan.so.1 libasan.so (libc6) => /usr/lib/gcc/powerpc-softfloat_4.9.3-linux-gnu/4.9.3/libasan.so libanl.so.1 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libanl.so.1 libSegFault.so (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libSegFault.so libBrokenLocale.so.1 (libc6, OS ABI: Linux 2.6.32) => /usr/powerpc-g2.20-linux-gnu/lib/libBrokenLocale.so.1 ld.so.1 (ELF) => /usr/powerpc-g2.20-linux-gnu/lib/ld.so.1 libasan and libsydc++ is include above but: powerpc-g2.20-linux-gnu-gcc -fsanitize=address mmap.c /usr/libexec/gcc/powerpc-g2.20-linux-gnu/ld: warning: libstdc++.so.6, needed by /usr/lib/gcc/powerpc-g2.20-linux-gnu/4.9.3/libasan.so, not found (try using -rpath or -rpath-link) No joy :( Perhaps gcc needs to pass -rpath-link under the hood to ld?
Fixing the obvious powerpc-softfloat_4.9.3-linux-gnu to powerpc-g2.20-linux-gnu error in ldconf didn't help, however: strace -o ldconf2.txt -f powerpc-g2.20-linux-gnu-gcc -fsanitize=address mmap.c did reveal: ... 22492 open("/usr/powerpc-g2.20-linux-gnu/etc/ld.so.conf", O_RDONLY) = 21 22492 fstat(21, {st_mode=S_IFREG|0644, st_size=174, ...}) = 0 22492 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb5111bf000 22492 read(21, "# ld.so.conf autogenerated by en"..., 4096) = 174 22492 read(21, "", 4096) = 0 22492 close(21) = 0 ... 22492 open("/usr/powerpc-g2.20-linux-gnu/usr/lib/gcc/powerpc-g2.20-linux-gnu/4.9.3/libstdc++.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) So ld reads /usr/powerpc-g2.20-linux-gnu/etc/ld.so.conf but prefixes every path with SYSROOT, this seems odd? Doing cd $SYSROOT/usr/lib ln -s ../../../lib/gcc gcc I created a path to /usr/powerpc-g2.20-linux-gnu/usr/lib/gcc/powerpc-g2.20-linux-gnu/4.9.3/libstdc++.so.6 and now it works :) Short story, this hack does the trick: cd /usr/powerpc-g2.20-linux-gnu/etc/env.d echo "LDPATH=/usr/lib/gcc/powerpc-g2.20-linux-gnu/4.9.3" > 05cross-gcc ROOT=/usr/powerpc-g2.20-linux-gnu/ env-update cd /usr/powerpc-g2.20-linux-gnu/usr/lib ln -s ../../../lib/gcc gcc Question is if the last symlink should be there or if this is a bugg?
(In reply to Joakim Tjernlund from comment #3) ... > > Short story, this hack does the trick: > > cd /usr/powerpc-g2.20-linux-gnu/etc/env.d > echo "LDPATH=/usr/lib/gcc/powerpc-g2.20-linux-gnu/4.9.3" > 05cross-gcc > ROOT=/usr/powerpc-g2.20-linux-gnu/ env-update > > cd /usr/powerpc-g2.20-linux-gnu/usr/lib > ln -s ../../../lib/gcc gcc > > Question is if the last symlink should be there or if this > is a bugg? Upstream thinks prefixing the paths in ld.so.conf with $sysroot is the correct behaviour. Then crossdev should be changed to add the above ld.co.conf config and create the symlink. I also note that the ld.so.conf path already present (/usr/powerpc-g2.20-linux-gnu/lib) is not needed and cases the linker to do unwanted lookups. Mike, any thoughts?
might be fixed if we resolve bug 291383 ...
Let's close it in favour of bug #549994 *** This bug has been marked as a duplicate of bug 549994 ***