when gcc is built --with-build-sysroot then $CC for the target libs includes --sysroot, but when the test is run for these target libs CC=xgcc is used without --sysroot libstdc++ tests have special workaround to pass build time CC and CFLAGS settings to the test system, same for libgfortran, but libatomic or libgomp tests fail when --with-build-sysroot is used. it was reported earlier but i could not find it in bugzilla: https://gcc.gnu.org/ml/gcc-patches/2013-05/msg01181.html the root cause is that the dejagnu 'find_gcc' function is used as CC in the tests which is wrong if any special flag (like --sysroot) is needed for compilation/linking.
a workaround is passing EXTRA_DEJAGNU_SITE_CONFIG=foo.exp to make, where foo.exp has set GCC_UNDER_TEST "build-dir/gcc/xgcc -Bbuild-dir/gcc --sysroot build-sysroot"
I wonder if this is related to bug 79885 at all?