This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, libiberty] Fix build regression
* Anthony Green wrote on Fri, Nov 19, 2010 at 11:09:36PM CET:
> This patch fixes a recent libiberty build regression discussed in this
> thread:
> http://gcc.gnu.org/ml/gcc-patches/2010-11/msg01998.html
>
> If we know we aren't going to be able to build executables, simply emit
> a warning saying that we can't link (instead of exiting with an error),
> and mention that we're assuming prctl does not exist for this target.
>
> Ok to commit?
A better fix is to actually allow the answer to the test to be correct
even in the no-link case. For that, cache the test result. It may then
be useful to move the test to a more appropriate place, such as after
the code that sets all the cache variables based on $host in the no-link
case. That way port maintainers can enter the right answers for this
test there, and if not given users can still configure toplevel with
.../configure target_configargs=libiberty_cv_prctl_PR_SET_NAME=yes
or so.
Here's how a cached version of the test would look like (untested!),
including a couple more fixlets:
AC_CACHE_CHECK([for prctl PR_SET_NAME],
[libiberty_cv_prctl_PR_SET_NAME],
[AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[#include <sys/prctl.h>]],
[[return (prctl(PR_SET_NAME, "foo") == 0) ? 0 : 1;]])],
[libiberty_cv_prctl_PR_SET_NAME=yes],
[libiberty_cv_prctl_PR_SET_NAME=no])])
if test "$libiberty_cv_prctl_PR_SET_NAME" = yes; then
AC_DEFINE(HAVE_PRCTL_SET_NAME, 1,
[Define if you have prctl PR_SET_NAME]))
fi
Thanks,
Ralf
> 2010-11-19 Anthony Green <green@moxielogic.com>
>
> * configure.ac: Don't run link tests if we can't build
> executables.
> * configure: Rebuilt.
> --- libiberty/configure.ac (revision 166958)
> +++ libiberty/configure.ac (working copy)
> @@ -538,15 +538,20 @@
> AC_SUBST(CHECK)
> AC_SUBST(target_header_dir)
>
> -# check for prctl PR_SET_NAME
> -AC_LINK_IFELSE([AC_LANG_SOURCE([[
> -#include <sys/prctl.h>
> -int main()
> -{
> - return (prctl(PR_SET_NAME, "foo") == 0) ? 0 : 1;
> -}
> -]])], AC_DEFINE(HAVE_PRCTL_SET_NAME, 1,
> - [Define if you have prctl PR_SET_NAME]))
> +if test x$gcc_no_link = xyes; then
> + AC_MSG_WARN([
> +*** Cannot link executables. Assuming target does not have prctl function.])
> +else
> + # check for prctl PR_SET_NAME
> + AC_LINK_IFELSE([AC_LANG_SOURCE([[
> + #include <sys/prctl.h>
> + int main()
> + {
> + return (prctl(PR_SET_NAME, "foo") == 0) ? 0 : 1;
> + }
> + ]])], AC_DEFINE(HAVE_PRCTL_SET_NAME, 1,
> + [Define if you have prctl PR_SET_NAME]))
> +fi
>
> case "${host}" in
> *-*-cygwin* | *-*-mingw*)