On 01/19/2012 10:06 AM, Jakub Jelinek wrote:
While the linker test is done using the target linker (it uses default linker flags btw, so in case a linker would be buggy for one target and not for a different target also supported by the same linker, it would be a problem, but let's assume that the linker is either buggy or not for all targets it supports), AC_PREPROC_IFELSE is done using the host compiler. For cross-compiling we would need to check the target libc headers.
Ah, right, so the patch is okay.
For glibc we could certainly do something similar to the case "$target" in *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu) [# glibc 2.4 and later provides __stack_chk_fail and # either __stack_chk_guard, or TLS access to stack guard canary. if test -f $target_header_dir/features.h \ && $EGREP '^[ ]*#[ ]*define[ ]+__GNU_LIBRARY__[ ]+([1-9][0-9]|[6-9])' \ $target_header_dir/features.h> /dev/null; then if $EGREP '^[ ]*#[ ]*define[ ]+__GLIBC__[ ]+([1-9][0-9]|[3-9])' \ $target_header_dir/features.h> /dev/null; then gcc_cv_libc_provides_ssp=yes elif $EGREP '^[ ]*#[ ]*define[ ]+__GLIBC__[ ]+2' \ $target_header_dir/features.h> /dev/null \ && $EGREP '^[ ]*#[ ]*define[ ]+__GLIBC_MINOR__[ ]+([1-9][0-9]|[4-9])' \ $target_header_dir/features.h> /dev/null; then gcc_cv_libc_provides_ssp=yes fi fi]
Or something like (cat $target_header_dir/features.h; echo glibc_so_ver=__GNU_LIBRARY__ echo glibc_ver=__GLIBC__ echo glibc_minor_ver=__GLIBC_MINOR__) | gcc -x c - | \ grep ^glibc.*ver= > glibc-ver.sh . glibc.sh which could be moved more easily to a helper macro. Paolo