diff mbox

Support official CLooG.org versions.

Message ID 1284107187-9883-1-git-send-email-simbuerg@googlemail.com
State New
Headers show

Commit Message

Andreas Simbürger Sept. 10, 2010, 8:26 a.m. UTC
Add support for official CLooG releases.
CLooG's configuration gets detected within 2 stages:

Stage 1: Detect the installed CLooG version.
  This is done by linking test programs against the various
  CLooG libraries. As CLooG's library sonames depend on the
  used backend, this is sufficient to detect the used backend.

  We only detect this backends, in order:
    1) CLooG-PPL (Legacy): The "old" CLooG.
    2) CLooG-ISL: The "new" CLooG.
    3) CLooG-Parma: An alternative backend, to compare it with
    CLooG-ISL.

  CLooG-Poly is not detected, as the PolyLib may conflict
  with GCC's license.

Stage 2: Version checks.
  After detecting the right configuration, we finally check
  if the installed version is usable. There are 2 different
  checks: One for CLooG-PPL (Legacy) and one for CLooG-ISL.

  * CLooG-ISL:
    As the "new" CLooG provides methods to check for its version at
    both compile and run time, we use this feature. First
    we check for the constants to verify the header's compatibility.
    Finally we verify the compatibility of our headers with
    the library that will get linked with GCC.
    As stated in autoconf's documentation, the run time check
    is not usable when cross-compiling, so we skip this check
    then.

  * CLooG-PPL (Legacy):
    This version check provides the same semantics as before.
    As CLooG-PPL (Legacy) provides the same constants as the
    official CLooG, we can use the same test program for the
    compile time check.

Tested with CLooG-ISL and CLooG-PPL (Legacy).
As for now, CLooG-Parma fails to build.

2010-08-11  Andreas Simbuerger  <simbuerg@fim.uni-passau.de>

	* configure.ac: Support official CLooG.org versions.
	* configure: Regenerate.
---
 ChangeLog.graphite |    5 +
 configure          |  369 ++++++++++++++++++++++++++++++++++++++++++----------
 configure.ac       |  149 ++++++++++++++++++----
 3 files changed, 433 insertions(+), 90 deletions(-)

Comments

Jack Howarth Sept. 10, 2010, 10:42 a.m. UTC | #1
On Fri, Sep 10, 2010 at 10:26:27AM +0200, Andreas Simbürger wrote:
> Add support for official CLooG releases.
> CLooG's configuration gets detected within 2 stages:
> 
> Stage 1: Detect the installed CLooG version.
>   This is done by linking test programs against the various
>   CLooG libraries. As CLooG's library sonames depend on the
>   used backend, this is sufficient to detect the used backend.
> 
>   We only detect this backends, in order:
>     1) CLooG-PPL (Legacy): The "old" CLooG.
>     2) CLooG-ISL: The "new" CLooG.
>     3) CLooG-Parma: An alternative backend, to compare it with
>     CLooG-ISL.
> 
>   CLooG-Poly is not detected, as the PolyLib may conflict
>   with GCC's license.
> 
> Stage 2: Version checks.
>   After detecting the right configuration, we finally check
>   if the installed version is usable. There are 2 different
>   checks: One for CLooG-PPL (Legacy) and one for CLooG-ISL.
> 
>   * CLooG-ISL:
>     As the "new" CLooG provides methods to check for its version at
>     both compile and run time, we use this feature. First
>     we check for the constants to verify the header's compatibility.
>     Finally we verify the compatibility of our headers with
>     the library that will get linked with GCC.
>     As stated in autoconf's documentation, the run time check
>     is not usable when cross-compiling, so we skip this check
>     then.
> 
>   * CLooG-PPL (Legacy):
>     This version check provides the same semantics as before.
>     As CLooG-PPL (Legacy) provides the same constants as the
>     official CLooG, we can use the same test program for the
>     compile time check.

  I thought it was agreed that we shouldn't allow cloog-ppl < 0.16
to be used to build gcc 4.6 and later in order to avoid the ABI issues
introduced with the ppl 0.11 release...

http://gcc.gnu.org/ml/gcc-patches/2010-08/msg00849.html
http://gcc.gnu.org/ml/gcc-patches/2010-08/msg00998.html
http://gcc.gnu.org/ml/gcc-patches/2010-08/msg01033.html

I read the last message as agreeing that in order to solve the issue
of maintaining coherency between the ppl ABI used to build FSF gcc and
cloog that...

1) cloog-ppl would be left incapable of building against ppl >= 0.11.
2) cloog.org would require ppl >= 0.11 to build.
3) when cloog.org support was added to gcc 4.6, the ability to build
against cloog-ppl would be depreciated.
              Jack

> 
> Tested with CLooG-ISL and CLooG-PPL (Legacy).
> As for now, CLooG-Parma fails to build.
> 
> 2010-08-11  Andreas Simbuerger  <simbuerg@fim.uni-passau.de>
> 
> 	* configure.ac: Support official CLooG.org versions.
> 	* configure: Regenerate.
> ---
>  ChangeLog.graphite |    5 +
>  configure          |  369 ++++++++++++++++++++++++++++++++++++++++++----------
>  configure.ac       |  149 ++++++++++++++++++----
>  3 files changed, 433 insertions(+), 90 deletions(-)
> 
> diff --git a/ChangeLog.graphite b/ChangeLog.graphite
> index c5edc3a..58e30e3 100644
> --- a/ChangeLog.graphite
> +++ b/ChangeLog.graphite
> @@ -1,3 +1,8 @@
> +2010-08-11  Andreas Simbuerger  <simbuerg@fim.uni-passau.de>
> +
> +	* configure.ac: Support official CLooG.org versions.
> +	* configure: Regenerate.
> +
>  2010-08-24  Sebastian Pop  <sebastian.pop@amd.com>
>  
>  	* Merge from mainline (160224:163495).
> diff --git a/configure b/configure
> index fc759d7..878b72f 100755
> --- a/configure
> +++ b/configure
> @@ -1816,6 +1816,48 @@ fi
>  
>  } # ac_fn_c_try_link
>  
> +# ac_fn_c_try_run LINENO
> +# ----------------------
> +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
> +# that executables *can* be run.
> +ac_fn_c_try_run ()
> +{
> +  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
> +  if { { ac_try="$ac_link"
> +case "(($ac_try" in
> +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
> +  *) ac_try_echo=$ac_try;;
> +esac
> +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
> +$as_echo "$ac_try_echo"; } >&5
> +  (eval "$ac_link") 2>&5
> +  ac_status=$?
> +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
> +  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
> +  { { case "(($ac_try" in
> +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
> +  *) ac_try_echo=$ac_try;;
> +esac
> +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
> +$as_echo "$ac_try_echo"; } >&5
> +  (eval "$ac_try") 2>&5
> +  ac_status=$?
> +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
> +  test $ac_status = 0; }; }; then :
> +  ac_retval=0
> +else
> +  $as_echo "$as_me: program exited with status $ac_status" >&5
> +       $as_echo "$as_me: failed program was:" >&5
> +sed 's/^/| /' conftest.$ac_ext >&5
> +
> +       ac_retval=$ac_status
> +fi
> +  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
> +  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
> +  return $ac_retval
> +
> +} # ac_fn_c_try_run
> +
>  # ac_fn_c_try_cpp LINENO
>  # ----------------------
>  # Try to preprocess conftest.$ac_ext, and return whether this succeeded.
> @@ -1940,48 +1982,6 @@ fi
>  
>  } # ac_fn_c_check_header_mongrel
>  
> -# ac_fn_c_try_run LINENO
> -# ----------------------
> -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
> -# that executables *can* be run.
> -ac_fn_c_try_run ()
> -{
> -  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
> -  if { { ac_try="$ac_link"
> -case "(($ac_try" in
> -  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
> -  *) ac_try_echo=$ac_try;;
> -esac
> -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
> -$as_echo "$ac_try_echo"; } >&5
> -  (eval "$ac_link") 2>&5
> -  ac_status=$?
> -  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
> -  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
> -  { { case "(($ac_try" in
> -  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
> -  *) ac_try_echo=$ac_try;;
> -esac
> -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
> -$as_echo "$ac_try_echo"; } >&5
> -  (eval "$ac_try") 2>&5
> -  ac_status=$?
> -  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
> -  test $ac_status = 0; }; }; then :
> -  ac_retval=0
> -else
> -  $as_echo "$as_me: program exited with status $ac_status" >&5
> -       $as_echo "$as_me: failed program was:" >&5
> -sed 's/^/| /' conftest.$ac_ext >&5
> -
> -       ac_retval=$ac_status
> -fi
> -  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
> -  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
> -  return $ac_retval
> -
> -} # ac_fn_c_try_run
> -
>  # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
>  # -------------------------------------------------------
>  # Tests whether HEADER exists and can be compiled using the include files in
> @@ -5885,8 +5885,6 @@ fi
>  
>  
>  # Check for CLOOG
> -clooglibs=" -lcloog "
> -clooginc=" -DCLOOG_PPL_BACKEND "
>  
>  
>  # Check whether --with-cloog was given.
> @@ -5919,19 +5917,19 @@ case $with_cloog in
>    "" | yes)
>      ;;
>    *)
> -    clooglibs="-L$with_cloog/lib -lcloog"
> -    clooginc="-I$with_cloog/include -DCLOOG_PPL_BACKEND "
> +    clooglibs="-L$with_cloog/lib"
> +    clooginc="-I$with_cloog/include"
>      ;;
>  esac
>  if test "x$with_cloog_include" != x; then
> -  clooginc="-I$with_cloog_include -DCLOOG_PPL_BACKEND "
> +  clooginc="-I$with_cloog_include"
>  fi
>  if test "x$with_cloog_lib" != x; then
> -  clooglibs="-L$with_cloog_lib -lcloog"
> +  clooglibs="-L$with_cloog_lib"
>  fi
>  if test "x$with_cloog$with_cloog_include$with_cloog_lib" = x && test -d ${srcdir}/cloog; then
> -  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' -lcloog '
> -  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include -DCLOOG_PPL_BACKEND '
> +  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' '
> +  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include '
>    enable_cloog_version_check=no
>  fi
>  
> @@ -5943,56 +5941,293 @@ else
>  fi
>  
>  
> -if test "x$with_cloog" != "xno" -a "${ENABLE_CLOOG_CHECK}" = "yes"; then
> -  saved_CFLAGS="$CFLAGS"
> -  CFLAGS="$CFLAGS $clooginc $gmpinc $pplinc"
> -  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version 0.15.5 (or later revision) of CLooG" >&5
> -$as_echo_n "checking for version 0.15.5 (or later revision) of CLooG... " >&6; }
> +if test "x$with_cloog" != "xno"; then
> +  # CLooG configure test programs.
> +
> +
> +
> +
> +  saved_cflags=$CFLAGS
> +  saved_libs=$LIBS
> +  saved_ldflags=$LDFLAGS
> +
> +  # Only fail if the user explicitly selected CLooG.
> +  cloog_allow_fail="no"
> +  if test "x${with_cloog}${with_cloog_include}${with_cloog_lib}" != "x" ; then
> +    cloog_allow_fail="yes"
> +  fi
> +
> +  # Stage 1: Detect the available CLooG+backend combination.
> +  clooglegacyinc="-DCLOOG_PPL_BACKEND"
> +  cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
> +  CFLAGS="${CFLAGS} ${gmpinc} ${pplinc} ${clooginc} ${cloogorginc}"
> +  LDFLAGS="${LDFLAGS} ${clooglibs}"
> +
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for installed CLooG type" >&5
> +$as_echo_n "checking for installed CLooG type... " >&6; }
> +
> +  cloog_inc=$clooglegacyinc
> +  cloog_org="no"
> +  LIBS="-lcloog"
>    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
>  /* end confdefs.h.  */
> -#include "cloog/cloog.h"
> +
> +
> +      #include <cloog/cloog.h>
> +
>  int
>  main ()
>  {
>  
> -  #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 5
> -  choke me
> -  #endif
> +      cloog_version ()
> +
> +
> +  ;
> +  return 0;
> +}
> +
> +_ACEOF
> +if ac_fn_c_try_link "$LINENO"; then :
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: CLooG-PPL (Legacy)" >&5
> +$as_echo "CLooG-PPL (Legacy)" >&6; }
> +else
> +
> +    cloog_inc=$cloogorginc
> +    cloog_org="yes"
> +    LIBS="-lcloog-isl -lisl"
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +
> +
> +      #include <cloog/cloog.h>
> +
> +int
> +main ()
> +{
> +
> +      cloog_version ()
> +
> +
> +  ;
> +  return 0;
> +}
> +
> +_ACEOF
> +if ac_fn_c_try_link "$LINENO"; then :
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: CLooG-ISL" >&5
> +$as_echo "CLooG-ISL" >&6; }
> +else
> +
> +      LIBS="-lcloog-ppl"
> +      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +
> +
> +      #include <cloog/cloog.h>
> +
> +int
> +main ()
> +{
> +
> +      cloog_version ()
> +
>  
>    ;
>    return 0;
>  }
> +
> +_ACEOF
> +if ac_fn_c_try_link "$LINENO"; then :
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: CLooG-PPL" >&5
> +$as_echo "CLooG-PPL" >&6; }
> +else
> +
> +        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }; cloog_inc= ; cloog_org= ; LIBS= ;
> +
> +fi
> +rm -f core conftest.err conftest.$ac_objext \
> +    conftest$ac_exeext conftest.$ac_ext
> +
> +fi
> +rm -f core conftest.err conftest.$ac_objext \
> +    conftest$ac_exeext conftest.$ac_ext
> +
> +fi
> +rm -f core conftest.err conftest.$ac_objext \
> +    conftest$ac_exeext conftest.$ac_ext
> +
> +  # Setup required flags for CLooG.
> +  if test "x${cloog_inc}${cloog_org}" != "x" ; then
> +    clooglibs="${clooglibs} ${LIBS}"
> +    clooginc="${clooginc} ${cloog_inc}"
> +  else
> +    clooglibs= ; clooginc= ;
> +  fi
> +
> +  CFLAGS=$saved_cflags
> +  LIBS=$saved_libs
> +  LDFLAGS=$saved_ldflags
> +
> +  # Stage 2: Version check the found CLooG.
> +  if test "${ENABLE_CLOOG_CHECK}" = "yes" \
> +    && test "${cloog_org}" = "yes" ; then
> +    saved_CFLAGS="$CFLAGS"
> +    saved_LDFLAGS="$LDFLAGS"
> +    CFLAGS="${CFLAGS} ${gmpinc} ${pplinc} ${clooginc} "
> +    LDFLAGS="${LDFLAGS} ${clooglibs} "
> +
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version 0.14.0 of CLooG (compile and run time)" >&5
> +$as_echo_n "checking for version 0.14.0 of CLooG (compile and run time)... " >&6; }
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +
> +
> +      #include <cloog/cloog.h>
> +
> +int
> +main ()
> +{
> +
> +      #if CLOOG_VERSION_MAJOR != 0
> +       || CLOOG_VERSION_MINOR != 14
> +       || CLOOG_VERSION_REVISION < 0
> +       choke me
> +      #endif
> +
> +
> +  ;
> +  return 0;
> +}
> +
>  _ACEOF
>  if ac_fn_c_try_compile "$LINENO"; then :
> +
> +      if test "$cross_compiling" = yes; then :
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (cross-compile)" >&5
> +$as_echo "yes (cross-compile)" >&6; }
> +else
>    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
>  /* end confdefs.h.  */
> -#include "cloog/cloog.h"
> +
> +
> +      #include <stdlib.h>
> +      #include <cloog/cloog.h>
> +
>  int
>  main ()
>  {
>  
> -  #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 9
> -  choke me
> -  #endif
> +      if ((cloog_version_major () != CLOOG_VERSION_MAJOR)
> +       && (cloog_version_minor () != CLOOG_VERSION_MINOR)
> +       && (cloog_version_revision () != CLOOG_VERSION_REVISION))
> +        {
> +          exit (1);
> +        }
> +
>  
>    ;
>    return 0;
>  }
> +
>  _ACEOF
> -if ac_fn_c_try_compile "$LINENO"; then :
> +if ac_fn_c_try_run "$LINENO"; then :
>    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
>  $as_echo "yes" >&6; }
>  else
> -  { $as_echo "$as_me:${as_lineno-$LINENO}: result: buggy but acceptable" >&5
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed at run time" >&5
> +$as_echo "failed at run time" >&6; }; clooglibs= ; clooginc=
> +fi
> +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
> +  conftest.$ac_objext conftest.beam conftest.$ac_ext
> +fi
> +
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed at compile time" >&5
> +$as_echo "failed at compile time" >&6; }; clooglibs= ; clooginc=
> +fi
> +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> +
> +    CFLAGS=${saved_CFLAGS}
> +    LDFLAGS=${saved_LDFLAGS}
> +  fi
> +
> +  # Version check for CLooG-PPL (Legacy).
> +  if test "${ENABLE_CLOOG_CHECK}" = "yes" \
> +    && test "${cloog_org}" = "no" ; then
> +    saved_CFLAGS="$CFLAGS"
> +    CFLAGS="$CFLAGS $clooginc $gmpinc $pplinc"
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version 0.15.5 (or later revision) of CLooG" >&5
> +$as_echo_n "checking for version 0.15.5 (or later revision) of CLooG... " >&6; }
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +
> +
> +      #include <cloog/cloog.h>
> +
> +int
> +main ()
> +{
> +
> +      #if CLOOG_VERSION_MAJOR != 0
> +       || CLOOG_VERSION_MINOR != 15
> +       || CLOOG_VERSION_REVISION < 5
> +       choke me
> +      #endif
> +
> +
> +  ;
> +  return 0;
> +}
> +
> +_ACEOF
> +if ac_fn_c_try_compile "$LINENO"; then :
> +
> +      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +
> +
> +      #include <cloog/cloog.h>
> +
> +int
> +main ()
> +{
> +
> +      #if CLOOG_VERSION_MAJOR != 0
> +       || CLOOG_VERSION_MINOR != 15
> +       || CLOOG_VERSION_REVISION < 9
> +       choke me
> +      #endif
> +
> +
> +  ;
> +  return 0;
> +}
> +
> +_ACEOF
> +if ac_fn_c_try_compile "$LINENO"; then :
> +
> +        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
> +$as_echo "yes" >&6; }
> +else
> +
> +        { $as_echo "$as_me:${as_lineno-$LINENO}: result: buggy but acceptable" >&5
>  $as_echo "buggy but acceptable" >&6; }
>  fi
>  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
>  else
> -  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +
> +      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
>  $as_echo "no" >&6; }; clooglibs= ; clooginc=
>  fi
>  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> -  CFLAGS="$saved_CFLAGS"
> +    CFLAGS="$saved_CFLAGS"
> +  fi
> +
> +  if test "${cloog_allow_fail}" = "yes" \
> +    && test "x${clooglibs}${clooginc}" = "x"; then
> +    as_fn_error "Unable to find a usable CLooG. See config.log for details." "$LINENO" 5
> +  fi
>  fi
>  
>  # Flags needed for CLOOG
> diff --git a/configure.ac b/configure.ac
> index 3d969aa..da67bbd 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1580,8 +1580,6 @@ AC_SUBST(pplinc)
>  
>  
>  # Check for CLOOG
> -clooglibs=" -lcloog "
> -clooginc=" -DCLOOG_PPL_BACKEND "
>  
>  AC_ARG_WITH(cloog, [  --with-cloog=PATH       Specify prefix directory for the installed CLooG-PPL package
>                            Equivalent to --with-cloog-include=PATH/include
> @@ -1601,19 +1599,19 @@ case $with_cloog in
>    "" | yes)
>      ;;
>    *)
> -    clooglibs="-L$with_cloog/lib -lcloog"
> -    clooginc="-I$with_cloog/include -DCLOOG_PPL_BACKEND "
> +    clooglibs="-L$with_cloog/lib"
> +    clooginc="-I$with_cloog/include"
>      ;;
>  esac
>  if test "x$with_cloog_include" != x; then
> -  clooginc="-I$with_cloog_include -DCLOOG_PPL_BACKEND "
> +  clooginc="-I$with_cloog_include"
>  fi
>  if test "x$with_cloog_lib" != x; then
> -  clooglibs="-L$with_cloog_lib -lcloog"
> +  clooglibs="-L$with_cloog_lib"
>  fi
>  if test "x$with_cloog$with_cloog_include$with_cloog_lib" = x && test -d ${srcdir}/cloog; then
> -  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' -lcloog '
> -  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include -DCLOOG_PPL_BACKEND '
> +  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' '
> +  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include '
>    enable_cloog_version_check=no
>  fi
>  
> @@ -1622,21 +1620,126 @@ AC_ARG_ENABLE(cloog-version-check,
>  ENABLE_CLOOG_CHECK=$enableval,
>  ENABLE_CLOOG_CHECK=yes)
>  
> -if test "x$with_cloog" != "xno" -a "${ENABLE_CLOOG_CHECK}" = "yes"; then
> -  saved_CFLAGS="$CFLAGS"
> -  CFLAGS="$CFLAGS $clooginc $gmpinc $pplinc"
> -  AC_MSG_CHECKING([for version 0.15.5 (or later revision) of CLooG])
> -  AC_TRY_COMPILE([#include "cloog/cloog.h"],[
> -  #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 5
> -  choke me
> -  #endif
> -  ], [AC_TRY_COMPILE([#include "cloog/cloog.h"],[
> -  #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 9
> -  choke me
> -  #endif
> -  ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])])],
> -  [AC_MSG_RESULT([no]); clooglibs= ; clooginc= ])
> -  CFLAGS="$saved_CFLAGS"
> +if test "x$with_cloog" != "xno"; then
> +  # CLooG configure test programs.
> +  m4_define([CLOOG_BACKEND_PROG],[
> +    AC_LANG_PROGRAM([
> +      #include <cloog/cloog.h>
> +      ],[
> +      cloog_version ()
> +      ]
> +    )]
> +  )
> +  m4_define([CLOOG_CHECK_CT_PROG],[
> +    AC_LANG_PROGRAM([
> +      #include <cloog/cloog.h>
> +      ], [
> +      #if CLOOG_VERSION_MAJOR != $1
> +       || CLOOG_VERSION_MINOR != $2
> +       || CLOOG_VERSION_REVISION < $3
> +       choke me
> +      #endif
> +      ]
> +    )]
> +  )
> +  m4_define([CLOOG_CHECK_RT_PROG],[
> +    AC_LANG_PROGRAM([
> +      #include <stdlib.h>
> +      #include <cloog/cloog.h>
> +      ],[
> +      if ((cloog_version_major () != CLOOG_VERSION_MAJOR)
> +       && (cloog_version_minor () != CLOOG_VERSION_MINOR)
> +       && (cloog_version_revision () != CLOOG_VERSION_REVISION))
> +        {
> +          exit (1);
> +        }
> +      ]
> +    )]
> +  )
> +
> +  saved_cflags=$CFLAGS
> +  saved_libs=$LIBS
> +  saved_ldflags=$LDFLAGS
> +
> +  # Only fail if the user explicitly selected CLooG.
> +  cloog_allow_fail="no"
> +  if test "x${with_cloog}${with_cloog_include}${with_cloog_lib}" != "x" ; then
> +    cloog_allow_fail="yes"
> +  fi
> +
> +  # Stage 1: Detect the available CLooG+backend combination.
> +  clooglegacyinc="-DCLOOG_PPL_BACKEND"
> +  cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
> +  CFLAGS="${CFLAGS} ${gmpinc} ${pplinc} ${clooginc} ${cloogorginc}"
> +  LDFLAGS="${LDFLAGS} ${clooglibs}"
> +
> +  AC_MSG_CHECKING([for installed CLooG type])
> +
> +  cloog_inc=$clooglegacyinc
> +  cloog_org="no"
> +  LIBS="-lcloog"
> +  AC_LINK_IFELSE([CLOOG_BACKEND_PROG], [AC_MSG_RESULT([CLooG-PPL (Legacy)])],[
> +    cloog_inc=$cloogorginc
> +    cloog_org="yes"
> +    LIBS="-lcloog-isl -lisl"
> +    AC_LINK_IFELSE([CLOOG_BACKEND_PROG], [AC_MSG_RESULT([CLooG-ISL])],[
> +      LIBS="-lcloog-ppl"
> +      AC_LINK_IFELSE([CLOOG_BACKEND_PROG], [AC_MSG_RESULT([CLooG-PPL])],[
> +        AC_MSG_RESULT([no]); cloog_inc= ; cloog_org= ; LIBS= ;
> +      ])
> +    ])
> +  ])
> +  
> +  # Setup required flags for CLooG.
> +  if test "x${cloog_inc}${cloog_org}" != "x" ; then
> +    clooglibs="${clooglibs} ${LIBS}"
> +    clooginc="${clooginc} ${cloog_inc}"
> +  else
> +    clooglibs= ; clooginc= ;
> +  fi
> +
> +  CFLAGS=$saved_cflags
> +  LIBS=$saved_libs
> +  LDFLAGS=$saved_ldflags
> +
> +  # Stage 2: Version check the found CLooG.
> +  if test "${ENABLE_CLOOG_CHECK}" = "yes" \
> +    && test "${cloog_org}" = "yes" ; then
> +    saved_CFLAGS="$CFLAGS"
> +    saved_LDFLAGS="$LDFLAGS"
> +    CFLAGS="${CFLAGS} ${gmpinc} ${pplinc} ${clooginc} "
> +    LDFLAGS="${LDFLAGS} ${clooglibs} "
> +    
> +    AC_MSG_CHECKING([for version 0.14.0 of CLooG (compile and run time)])
> +    AC_COMPILE_IFELSE([CLOOG_CHECK_CT_PROG(0,14,0)],[
> +      AC_RUN_IFELSE([CLOOG_CHECK_RT_PROG],
> +        [AC_MSG_RESULT([yes])],
> +        [AC_MSG_RESULT([failed at run time]); clooglibs= ; clooginc= ],
> +        [AC_MSG_RESULT([yes (cross-compile)])])],
> +      [AC_MSG_RESULT([failed at compile time]); clooglibs= ; clooginc= ])
> +    
> +    CFLAGS=${saved_CFLAGS}
> +    LDFLAGS=${saved_LDFLAGS}
> +  fi
> +
> +  # Version check for CLooG-PPL (Legacy).
> +  if test "${ENABLE_CLOOG_CHECK}" = "yes" \
> +    && test "${cloog_org}" = "no" ; then
> +    saved_CFLAGS="$CFLAGS"
> +    CFLAGS="$CFLAGS $clooginc $gmpinc $pplinc"
> +    AC_MSG_CHECKING([for version 0.15.5 (or later revision) of CLooG])
> +    AC_COMPILE_IFELSE([CLOOG_CHECK_CT_PROG(0,15,5)],[
> +      AC_COMPILE_IFELSE([CLOOG_CHECK_CT_PROG(0,15,9)],[
> +        AC_MSG_RESULT([yes])],[
> +        AC_MSG_RESULT([buggy but acceptable])])],[
> +      AC_MSG_RESULT([no]); clooglibs= ; clooginc= ])
> +    CFLAGS="$saved_CFLAGS"
> +  fi
> +
> +  if test "${cloog_allow_fail}" = "yes" \
> +    && test "x${clooglibs}${clooginc}" = "x"; then
> +    AC_MSG_ERROR([Unable to find a usable CLooG. See config.log for details.])
> +  fi
>  fi
>  
>  # Flags needed for CLOOG
> -- 
> 1.7.2.2
Tobias Grosser Sept. 10, 2010, 11:02 a.m. UTC | #2
On 09/10/2010 12:42 PM, Jack Howarth wrote:
> On Fri, Sep 10, 2010 at 10:26:27AM +0200, Andreas Simbürger wrote:
>> Add support for official CLooG releases.

 From my side this patch set looks OK. It allows us to test graphite 
with the new cloog-isl library.

I believe the patchset should also work for static linking as neither 
cloog nor isl use libstdcxx and -lisl was added as requested.

@Joseph
Was this implemented correctly?

One thing that was not included is the --with-isl flag. Currently isl is 
automatically installed with CLooG (using git). We will start discussion 
on how to release both as a tar balls and based on that add additional 
configure support to check for isl as well as the needed documentation.

I propose this transition plan:

1. Commit configure support for cloog-isl to graphite (this patch)
2. Start testing with cloog-isl internally
3. Discuss how to release cloog/isl with the cloog maintainer
4. Release beta tar balls.
5. Adapt configure support to use separate cloog/isl tarballs.
6. Move those changes to trunk and ask for wider testing.
7. Fix regressions.
8. Move to the official cloog.

Cheers
Tobi
Joseph Myers Sept. 10, 2010, 4:23 p.m. UTC | #3
On Fri, 10 Sep 2010, Tobias Grosser wrote:

> On 09/10/2010 12:42 PM, Jack Howarth wrote:
> > On Fri, Sep 10, 2010 at 10:26:27AM +0200, Andreas Simbürger wrote:
> > > Add support for official CLooG releases.
> 
> From my side this patch set looks OK. It allows us to test graphite with the
> new cloog-isl library.
> 
> I believe the patchset should also work for static linking as neither cloog
> nor isl use libstdcxx and -lisl was added as requested.
> 
> @Joseph
> Was this implemented correctly?

I think you want a build system maintainer to review the details of the 
implementation.  I can only comment on the general principles: a 
particular GCC version specifies particular versions of the libraries that 
must be used with it when Graphite-enabled (unless special options are 
used to disable the version checks), there are suitable configure options 
to say where those libraries are installed, library dependencies are 
specified explicitly so that linking with static versions of those 
libraries works, the libraries themselves can be cross compiled for the 
various supported GCC host systems, and the required versions and 
configure options are documented in install.texi.
Ralf Wildenhues Sept. 10, 2010, 5:14 p.m. UTC | #4
Hello Andreas,

I cannot approve, and this isn't a full review either, just a couple of
nits I happened to spot:

* Andreas Simbürger wrote on Fri, Sep 10, 2010 at 10:26:27AM CEST:
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1580,8 +1580,6 @@ AC_SUBST(pplinc)
>  
>  
>  # Check for CLOOG
> -clooglibs=" -lcloog "
> -clooginc=" -DCLOOG_PPL_BACKEND "
>  
>  AC_ARG_WITH(cloog, [  --with-cloog=PATH       Specify prefix directory for the installed CLooG-PPL package
>                            Equivalent to --with-cloog-include=PATH/include
> @@ -1601,19 +1599,19 @@ case $with_cloog in
>    "" | yes)
>      ;;
>    *)
> -    clooglibs="-L$with_cloog/lib -lcloog"
> -    clooginc="-I$with_cloog/include -DCLOOG_PPL_BACKEND "
> +    clooglibs="-L$with_cloog/lib"
> +    clooginc="-I$with_cloog/include"
>      ;;
>  esac
>  if test "x$with_cloog_include" != x; then

This isn't new with your patch (so not a reason for rejection anyway),
but testing for empty variables rather than unset ones,
      test ${with_cloog_include+set} != set

will not let users override the logic with an empty setting.  That's ok,
it's normally overridable with something like a single space, but might
be less intuitive than necessary.

> -  clooginc="-I$with_cloog_include -DCLOOG_PPL_BACKEND "
> +  clooginc="-I$with_cloog_include"
>  fi
>  if test "x$with_cloog_lib" != x; then
> -  clooglibs="-L$with_cloog_lib -lcloog"
> +  clooglibs="-L$with_cloog_lib"
>  fi
>  if test "x$with_cloog$with_cloog_include$with_cloog_lib" = x && test -d ${srcdir}/cloog; then
> -  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' -lcloog '
> -  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include -DCLOOG_PPL_BACKEND '
> +  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' '
> +  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include '
>    enable_cloog_version_check=no
>  fi
>  
> @@ -1622,21 +1620,126 @@ AC_ARG_ENABLE(cloog-version-check,
>  ENABLE_CLOOG_CHECK=$enableval,
>  ENABLE_CLOOG_CHECK=yes)
>  
> -if test "x$with_cloog" != "xno" -a "${ENABLE_CLOOG_CHECK}" = "yes"; then
> -  saved_CFLAGS="$CFLAGS"
> -  CFLAGS="$CFLAGS $clooginc $gmpinc $pplinc"
> -  AC_MSG_CHECKING([for version 0.15.5 (or later revision) of CLooG])
> -  AC_TRY_COMPILE([#include "cloog/cloog.h"],[
> -  #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 5
> -  choke me
> -  #endif
> -  ], [AC_TRY_COMPILE([#include "cloog/cloog.h"],[
> -  #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 9
> -  choke me
> -  #endif
> -  ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])])],
> -  [AC_MSG_RESULT([no]); clooglibs= ; clooginc= ])
> -  CFLAGS="$saved_CFLAGS"
> +if test "x$with_cloog" != "xno"; then
> +  # CLooG configure test programs.

I'd use dnl rather than # for comments that pertain to m4 constructs
rather than shell ones (that way they don't look misplaced in the
configure output).

> +  m4_define([CLOOG_BACKEND_PROG],[
> +    AC_LANG_PROGRAM([
> +      #include <cloog/cloog.h>
> +      ],[
> +      cloog_version ()
> +      ]
> +    )]
> +  )
> +  m4_define([CLOOG_CHECK_CT_PROG],[
> +    AC_LANG_PROGRAM([
> +      #include <cloog/cloog.h>
> +      ], [
> +      #if CLOOG_VERSION_MAJOR != $1
> +       || CLOOG_VERSION_MINOR != $2
> +       || CLOOG_VERSION_REVISION < $3

Without escaping the two newlines this looks like it will always result
in a compile error, because the second and third line will be eaten by
the compiler, not the preprocessor.

> +       choke me
> +      #endif
> +      ]
> +    )]
> +  )
> +  m4_define([CLOOG_CHECK_RT_PROG],[
> +    AC_LANG_PROGRAM([
> +      #include <stdlib.h>
> +      #include <cloog/cloog.h>
> +      ],[
> +      if ((cloog_version_major () != CLOOG_VERSION_MAJOR)
> +       && (cloog_version_minor () != CLOOG_VERSION_MINOR)
> +       && (cloog_version_revision () != CLOOG_VERSION_REVISION))
> +        {
> +          exit (1);
> +        }
> +      ]
> +    )]
> +  )
> +
> +  saved_cflags=$CFLAGS
> +  saved_libs=$LIBS
> +  saved_ldflags=$LDFLAGS
> +
> +  # Only fail if the user explicitly selected CLooG.
> +  cloog_allow_fail="no"
> +  if test "x${with_cloog}${with_cloog_include}${with_cloog_lib}" != "x" ; then
> +    cloog_allow_fail="yes"
> +  fi
> +
> +  # Stage 1: Detect the available CLooG+backend combination.
> +  clooglegacyinc="-DCLOOG_PPL_BACKEND"
> +  cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
> +  CFLAGS="${CFLAGS} ${gmpinc} ${pplinc} ${clooginc} ${cloogorginc}"
> +  LDFLAGS="${LDFLAGS} ${clooglibs}"
> +
> +  AC_MSG_CHECKING([for installed CLooG type])
> +
> +  cloog_inc=$clooglegacyinc
> +  cloog_org="no"
> +  LIBS="-lcloog"

I don't think LIBS should ever be completely overridden.  The user may
be smarter that we and know that on her exotic system, -lfoo is always
needed in addition to, say, -lc; I suggest to replace this with
     LIBS="-lcloog $saved_LIBS"

(several instances), and adjust the followup code (you assign LIBS to
clooglibs, which is wrong in this case).

> +  AC_LINK_IFELSE([CLOOG_BACKEND_PROG], [AC_MSG_RESULT([CLooG-PPL (Legacy)])],[
> +    cloog_inc=$cloogorginc
> +    cloog_org="yes"
> +    LIBS="-lcloog-isl -lisl"
> +    AC_LINK_IFELSE([CLOOG_BACKEND_PROG], [AC_MSG_RESULT([CLooG-ISL])],[
> +      LIBS="-lcloog-ppl"
> +      AC_LINK_IFELSE([CLOOG_BACKEND_PROG], [AC_MSG_RESULT([CLooG-PPL])],[
> +        AC_MSG_RESULT([no]); cloog_inc= ; cloog_org= ; LIBS= ;
> +      ])
> +    ])
> +  ])
> +  
> +  # Setup required flags for CLooG.
> +  if test "x${cloog_inc}${cloog_org}" != "x" ; then
> +    clooglibs="${clooglibs} ${LIBS}"
> +    clooginc="${clooginc} ${cloog_inc}"
> +  else
> +    clooglibs= ; clooginc= ;
> +  fi
> +
> +  CFLAGS=$saved_cflags
> +  LIBS=$saved_libs
> +  LDFLAGS=$saved_ldflags
> +
> +  # Stage 2: Version check the found CLooG.
> +  if test "${ENABLE_CLOOG_CHECK}" = "yes" \
> +    && test "${cloog_org}" = "yes" ; then
> +    saved_CFLAGS="$CFLAGS"
> +    saved_LDFLAGS="$LDFLAGS"
> +    CFLAGS="${CFLAGS} ${gmpinc} ${pplinc} ${clooginc} "
> +    LDFLAGS="${LDFLAGS} ${clooglibs} "
> +    
> +    AC_MSG_CHECKING([for version 0.14.0 of CLooG (compile and run time)])
> +    AC_COMPILE_IFELSE([CLOOG_CHECK_CT_PROG(0,14,0)],[
> +      AC_RUN_IFELSE([CLOOG_CHECK_RT_PROG],
> +        [AC_MSG_RESULT([yes])],
> +        [AC_MSG_RESULT([failed at run time]); clooglibs= ; clooginc= ],
> +        [AC_MSG_RESULT([yes (cross-compile)])])],

As far as I can see, there is no way to override this test, say, for
cross-compile cases where your guess is wrong.  The usual way to allow
an override is to use a cache variable, e.g.,
     AC_CACHE_CHECK([for version 0.14.0 of CLooG],
                    [gcc_cv_cloog_rt_0_14_0],
       [AC_RUN_IFELSE([...],
                      [gcc_cv_cloog_rt_0_14_0=yes],
                      [gcc_cv_cloog_rt_0_14_0=no],
                      [gcc_cv_cloog_rt_0_14_0="guessing yes"])])
     if test "$gcc_cv_cloog_rt_0_14_0" = ...
or
     case $gcc_cv_cloog_rt_0_14_0 in
     ...

You can also cache the other tests (using other variable names, of
course), but for runtime tests it is the most important.  Just be sure
that the third argument of AC_CACHE_CHECK doesn't have side effects
other than setting the cache variable.

> +      [AC_MSG_RESULT([failed at compile time]); clooglibs= ; clooginc= ])
> +    
> +    CFLAGS=${saved_CFLAGS}
> +    LDFLAGS=${saved_LDFLAGS}
> +  fi
> +
> +  # Version check for CLooG-PPL (Legacy).
> +  if test "${ENABLE_CLOOG_CHECK}" = "yes" \
> +    && test "${cloog_org}" = "no" ; then
> +    saved_CFLAGS="$CFLAGS"
> +    CFLAGS="$CFLAGS $clooginc $gmpinc $pplinc"
> +    AC_MSG_CHECKING([for version 0.15.5 (or later revision) of CLooG])
> +    AC_COMPILE_IFELSE([CLOOG_CHECK_CT_PROG(0,15,5)],[
> +      AC_COMPILE_IFELSE([CLOOG_CHECK_CT_PROG(0,15,9)],[
> +        AC_MSG_RESULT([yes])],[
> +        AC_MSG_RESULT([buggy but acceptable])])],[
> +      AC_MSG_RESULT([no]); clooglibs= ; clooginc= ])
> +    CFLAGS="$saved_CFLAGS"
> +  fi
> +
> +  if test "${cloog_allow_fail}" = "yes" \
> +    && test "x${clooglibs}${clooginc}" = "x"; then
> +    AC_MSG_ERROR([Unable to find a usable CLooG. See config.log for details.])
> +  fi
>  fi

Cheers,
Ralf
Andreas Simbürger Sept. 10, 2010, 6:34 p.m. UTC | #5
On 09/10/2010 07:14 PM, Ralf Wildenhues wrote:
> Hello Andreas,
> 
> I cannot approve, and this isn't a full review either, just a couple of
> nits I happened to spot:
> 
> * Andreas Simbürger wrote on Fri, Sep 10, 2010 at 10:26:27AM CEST:
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -1580,8 +1580,6 @@ AC_SUBST(pplinc)
>>  
>>  
>>  # Check for CLOOG
>> -clooglibs=" -lcloog "
>> -clooginc=" -DCLOOG_PPL_BACKEND "
>>  
>>  AC_ARG_WITH(cloog, [  --with-cloog=PATH       Specify prefix directory for the installed CLooG-PPL package
>>                            Equivalent to --with-cloog-include=PATH/include
>> @@ -1601,19 +1599,19 @@ case $with_cloog in
>>    "" | yes)
>>      ;;
>>    *)
>> -    clooglibs="-L$with_cloog/lib -lcloog"
>> -    clooginc="-I$with_cloog/include -DCLOOG_PPL_BACKEND "
>> +    clooglibs="-L$with_cloog/lib"
>> +    clooginc="-I$with_cloog/include"
>>      ;;
>>  esac
>>  if test "x$with_cloog_include" != x; then
> 
> This isn't new with your patch (so not a reason for rejection anyway),
> but testing for empty variables rather than unset ones,
>       test ${with_cloog_include+set} != set
> 
> will not let users override the logic with an empty setting.  That's ok,
> it's normally overridable with something like a single space, but might
> be less intuitive than necessary.
>

Thanks for pointing this out :-)

>> -  clooginc="-I$with_cloog_include -DCLOOG_PPL_BACKEND "
>> +  clooginc="-I$with_cloog_include"
>>  fi
>>  if test "x$with_cloog_lib" != x; then
>> -  clooglibs="-L$with_cloog_lib -lcloog"
>> +  clooglibs="-L$with_cloog_lib"
>>  fi
>>  if test "x$with_cloog$with_cloog_include$with_cloog_lib" = x && test -d ${srcdir}/cloog; then
>> -  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' -lcloog '
>> -  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include -DCLOOG_PPL_BACKEND '
>> +  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' '
>> +  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include '
>>    enable_cloog_version_check=no
>>  fi
>>  
>> @@ -1622,21 +1620,126 @@ AC_ARG_ENABLE(cloog-version-check,
>>  ENABLE_CLOOG_CHECK=$enableval,
>>  ENABLE_CLOOG_CHECK=yes)
>>  
>> -if test "x$with_cloog" != "xno" -a "${ENABLE_CLOOG_CHECK}" = "yes"; then
>> -  saved_CFLAGS="$CFLAGS"
>> -  CFLAGS="$CFLAGS $clooginc $gmpinc $pplinc"
>> -  AC_MSG_CHECKING([for version 0.15.5 (or later revision) of CLooG])
>> -  AC_TRY_COMPILE([#include "cloog/cloog.h"],[
>> -  #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 5
>> -  choke me
>> -  #endif
>> -  ], [AC_TRY_COMPILE([#include "cloog/cloog.h"],[
>> -  #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 9
>> -  choke me
>> -  #endif
>> -  ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])])],
>> -  [AC_MSG_RESULT([no]); clooglibs= ; clooginc= ])
>> -  CFLAGS="$saved_CFLAGS"
>> +if test "x$with_cloog" != "xno"; then
>> +  # CLooG configure test programs.
> 
> I'd use dnl rather than # for comments that pertain to m4 constructs
> rather than shell ones (that way they don't look misplaced in the
> configure output).
> 
>> +  m4_define([CLOOG_BACKEND_PROG],[
>> +    AC_LANG_PROGRAM([
>> +      #include <cloog/cloog.h>
>> +      ],[
>> +      cloog_version ()
>> +      ]
>> +    )]
>> +  )
>> +  m4_define([CLOOG_CHECK_CT_PROG],[
>> +    AC_LANG_PROGRAM([
>> +      #include <cloog/cloog.h>
>> +      ], [
>> +      #if CLOOG_VERSION_MAJOR != $1
>> +       || CLOOG_VERSION_MINOR != $2
>> +       || CLOOG_VERSION_REVISION < $3
> 
> Without escaping the two newlines this looks like it will always result
> in a compile error, because the second and third line will be eaten by
> the compiler, not the preprocessor.
> 

That is confusing now. I have to admit you're right. However I tested it
with both cloog-isl and cloog-ppl and it worked like a charm.
Interesting. I will fix that.

>> +       choke me
>> +      #endif
>> +      ]
>> +    )]
>> +  )
>> +  m4_define([CLOOG_CHECK_RT_PROG],[
>> +    AC_LANG_PROGRAM([
>> +      #include <stdlib.h>
>> +      #include <cloog/cloog.h>
>> +      ],[
>> +      if ((cloog_version_major () != CLOOG_VERSION_MAJOR)
>> +       && (cloog_version_minor () != CLOOG_VERSION_MINOR)
>> +       && (cloog_version_revision () != CLOOG_VERSION_REVISION))
>> +        {
>> +          exit (1);
>> +        }
>> +      ]
>> +    )]
>> +  )
>> +
>> +  saved_cflags=$CFLAGS
>> +  saved_libs=$LIBS
>> +  saved_ldflags=$LDFLAGS
>> +
>> +  # Only fail if the user explicitly selected CLooG.
>> +  cloog_allow_fail="no"
>> +  if test "x${with_cloog}${with_cloog_include}${with_cloog_lib}" != "x" ; then
>> +    cloog_allow_fail="yes"
>> +  fi
>> +
>> +  # Stage 1: Detect the available CLooG+backend combination.
>> +  clooglegacyinc="-DCLOOG_PPL_BACKEND"
>> +  cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
>> +  CFLAGS="${CFLAGS} ${gmpinc} ${pplinc} ${clooginc} ${cloogorginc}"
>> +  LDFLAGS="${LDFLAGS} ${clooglibs}"
>> +
>> +  AC_MSG_CHECKING([for installed CLooG type])
>> +
>> +  cloog_inc=$clooglegacyinc
>> +  cloog_org="no"
>> +  LIBS="-lcloog"
> 
> I don't think LIBS should ever be completely overridden.  The user may
> be smarter that we and know that on her exotic system, -lfoo is always
> needed in addition to, say, -lc; I suggest to replace this with
>      LIBS="-lcloog $saved_LIBS"
> 
> (several instances), and adjust the followup code (you assign LIBS to
> clooglibs, which is wrong in this case).
> 

I though i could avoid introducing another variable by "hijacking" LIBS.

>> +  AC_LINK_IFELSE([CLOOG_BACKEND_PROG], [AC_MSG_RESULT([CLooG-PPL (Legacy)])],[
>> +    cloog_inc=$cloogorginc
>> +    cloog_org="yes"
>> +    LIBS="-lcloog-isl -lisl"
>> +    AC_LINK_IFELSE([CLOOG_BACKEND_PROG], [AC_MSG_RESULT([CLooG-ISL])],[
>> +      LIBS="-lcloog-ppl"
>> +      AC_LINK_IFELSE([CLOOG_BACKEND_PROG], [AC_MSG_RESULT([CLooG-PPL])],[
>> +        AC_MSG_RESULT([no]); cloog_inc= ; cloog_org= ; LIBS= ;
>> +      ])
>> +    ])
>> +  ])
>> +  
>> +  # Setup required flags for CLooG.
>> +  if test "x${cloog_inc}${cloog_org}" != "x" ; then
>> +    clooglibs="${clooglibs} ${LIBS}"
>> +    clooginc="${clooginc} ${cloog_inc}"
>> +  else
>> +    clooglibs= ; clooginc= ;
>> +  fi
>> +
>> +  CFLAGS=$saved_cflags
>> +  LIBS=$saved_libs
>> +  LDFLAGS=$saved_ldflags
>> +
>> +  # Stage 2: Version check the found CLooG.
>> +  if test "${ENABLE_CLOOG_CHECK}" = "yes" \
>> +    && test "${cloog_org}" = "yes" ; then
>> +    saved_CFLAGS="$CFLAGS"
>> +    saved_LDFLAGS="$LDFLAGS"
>> +    CFLAGS="${CFLAGS} ${gmpinc} ${pplinc} ${clooginc} "
>> +    LDFLAGS="${LDFLAGS} ${clooglibs} "
>> +    
>> +    AC_MSG_CHECKING([for version 0.14.0 of CLooG (compile and run time)])
>> +    AC_COMPILE_IFELSE([CLOOG_CHECK_CT_PROG(0,14,0)],[
>> +      AC_RUN_IFELSE([CLOOG_CHECK_RT_PROG],
>> +        [AC_MSG_RESULT([yes])],
>> +        [AC_MSG_RESULT([failed at run time]); clooglibs= ; clooginc= ],
>> +        [AC_MSG_RESULT([yes (cross-compile)])])],
> 
> As far as I can see, there is no way to override this test, say, for
> cross-compile cases where your guess is wrong.  The usual way to allow
> an override is to use a cache variable, e.g.,
>      AC_CACHE_CHECK([for version 0.14.0 of CLooG],
>                     [gcc_cv_cloog_rt_0_14_0],
>        [AC_RUN_IFELSE([...],
>                       [gcc_cv_cloog_rt_0_14_0=yes],
>                       [gcc_cv_cloog_rt_0_14_0=no],
>                       [gcc_cv_cloog_rt_0_14_0="guessing yes"])])
>      if test "$gcc_cv_cloog_rt_0_14_0" = ...
> or
>      case $gcc_cv_cloog_rt_0_14_0 in
>      ...
> 
> You can also cache the other tests (using other variable names, of
> course), but for runtime tests it is the most important.  Just be sure
> that the third argument of AC_CACHE_CHECK doesn't have side effects
> other than setting the cache variable.

This is something i don't get right now. The testing goes:
 1) Test the compilation.
 2) If successful: Test the runtime. If cross-compiling: Ignore the
runtime check and go on.

What is the advantage of providing an override to a test that is ignored
anyways when cross-compiling?

> 
>> +      [AC_MSG_RESULT([failed at compile time]); clooglibs= ; clooginc= ])
>> +    
>> +    CFLAGS=${saved_CFLAGS}
>> +    LDFLAGS=${saved_LDFLAGS}
>> +  fi
>> +
>> +  # Version check for CLooG-PPL (Legacy).
>> +  if test "${ENABLE_CLOOG_CHECK}" = "yes" \
>> +    && test "${cloog_org}" = "no" ; then
>> +    saved_CFLAGS="$CFLAGS"
>> +    CFLAGS="$CFLAGS $clooginc $gmpinc $pplinc"
>> +    AC_MSG_CHECKING([for version 0.15.5 (or later revision) of CLooG])
>> +    AC_COMPILE_IFELSE([CLOOG_CHECK_CT_PROG(0,15,5)],[
>> +      AC_COMPILE_IFELSE([CLOOG_CHECK_CT_PROG(0,15,9)],[
>> +        AC_MSG_RESULT([yes])],[
>> +        AC_MSG_RESULT([buggy but acceptable])])],[
>> +      AC_MSG_RESULT([no]); clooglibs= ; clooginc= ])
>> +    CFLAGS="$saved_CFLAGS"
>> +  fi
>> +
>> +  if test "${cloog_allow_fail}" = "yes" \
>> +    && test "x${clooglibs}${clooginc}" = "x"; then
>> +    AC_MSG_ERROR([Unable to find a usable CLooG. See config.log for details.])
>> +  fi
>>  fi
> 
> Cheers,
> Ralf

Thanks for reviewing! :-)

Cheers,
Andreas
Sebastian Pop Sept. 10, 2010, 6:57 p.m. UTC | #6
On Fri, Sep 10, 2010 at 05:42, Jack Howarth <howarth@bromo.med.uc.edu> wrote:
> 1) cloog-ppl would be left incapable of building against ppl >= 0.11.

cloog-ppl-0.15.10 does not have this restriction anymore.

> 2) cloog.org would require ppl >= 0.11 to build.

Correct.
Cloog-parma depends on ppl-0.11, I don't think that
this is a hard dependence, i.e. maybe it can also be
built with ppl-0.10.

> 3) when cloog.org support was added to gcc 4.6, the ability to build
> against cloog-ppl would be depreciated.

This is step number 8 from Tobias' plan.

Sebastian
Jack Howarth Sept. 10, 2010, 7:27 p.m. UTC | #7
On Fri, Sep 10, 2010 at 01:57:58PM -0500, Sebastian Pop wrote:
> On Fri, Sep 10, 2010 at 05:42, Jack Howarth <howarth@bromo.med.uc.edu> wrote:
> > 1) cloog-ppl would be left incapable of building against ppl >= 0.11.
> 
> cloog-ppl-0.15.10 does not have this restriction anymore.

That is scary. Doesn't this open us up to the following scenario?

1) User installs ppl 0.10.2
2) User installs cloog-ppl 0.15.9 built against ppl 0.10.2
3) User installs gcc 4.5.x or trunk built against both ppl 0.10.2 and cloog-ppl 0.15.9.
4) User 'upgrades' ppl to 0.11
5) User 'upgrades' cloog to 0.15.10 built against ppl 0.11

The user now ends up running a gcc release built directly against ppl 0.10.2
and cloog-ppl 0.15.9 but now running against ppl 0.11 via cloog-ppl 0.15.10.
FSF gcc should have some way to sanity check at run time via cloog that it
was built with the same ppl ABI as the cloog it is linked against.
       Jack

> 
> > 2) cloog.org would require ppl >= 0.11 to build.
> 
> Correct.
> Cloog-parma depends on ppl-0.11, I don't think that
> this is a hard dependence, i.e. maybe it can also be
> built with ppl-0.10.
> 
> > 3) when cloog.org support was added to gcc 4.6, the ability to build
> > against cloog-ppl would be depreciated.
> 
> This is step number 8 from Tobias' plan.
> 
> Sebastian
Ralf Wildenhues Sept. 11, 2010, 8:02 a.m. UTC | #8
* Andreas Simbuerger wrote on Fri, Sep 10, 2010 at 08:34:50PM CEST:
> On 09/10/2010 07:14 PM, Ralf Wildenhues wrote:

> >> +      AC_RUN_IFELSE([CLOOG_CHECK_RT_PROG],
> >> +        [AC_MSG_RESULT([yes])],
> >> +        [AC_MSG_RESULT([failed at run time]); clooglibs= ; clooginc= ],
> >> +        [AC_MSG_RESULT([yes (cross-compile)])])],
> > 
> > As far as I can see, there is no way to override this test, say, for
> > cross-compile cases where your guess is wrong.  The usual way to allow
> > an override is to use a cache variable, e.g.,
> >      AC_CACHE_CHECK([for version 0.14.0 of CLooG],
> >                     [gcc_cv_cloog_rt_0_14_0],
> >        [AC_RUN_IFELSE([...],
> >                       [gcc_cv_cloog_rt_0_14_0=yes],
> >                       [gcc_cv_cloog_rt_0_14_0=no],
> >                       [gcc_cv_cloog_rt_0_14_0="guessing yes"])])
> >      if test "$gcc_cv_cloog_rt_0_14_0" = ...
> > or
> >      case $gcc_cv_cloog_rt_0_14_0 in
> >      ...
> > 
> > You can also cache the other tests (using other variable names, of
> > course), but for runtime tests it is the most important.  Just be sure
> > that the third argument of AC_CACHE_CHECK doesn't have side effects
> > other than setting the cache variable.
> 
> This is something i don't get right now. The testing goes:
>  1) Test the compilation.
>  2) If successful: Test the runtime. If cross-compiling: Ignore the
> runtime check and go on.
> 
> What is the advantage of providing an override to a test that is ignored
> anyways when cross-compiling?

Yeah, maybe you're right in that an override is overkill in this case.
(Generally, runtime tests without cache guard trigger a raised eyebrow
because they might get users stuck.  I wonder whether we can let
autoconf warn about them.)

Cheers,
Ralf
Andreas Simbürger Sept. 11, 2010, 10:12 a.m. UTC | #9
On 09/11/2010 10:02 AM, Ralf Wildenhues wrote:
> * Andreas Simbuerger wrote on Fri, Sep 10, 2010 at 08:34:50PM CEST:
>> On 09/10/2010 07:14 PM, Ralf Wildenhues wrote:
> 
>>>> +      AC_RUN_IFELSE([CLOOG_CHECK_RT_PROG],
>>>> +        [AC_MSG_RESULT([yes])],
>>>> +        [AC_MSG_RESULT([failed at run time]); clooglibs= ; clooginc= ],
>>>> +        [AC_MSG_RESULT([yes (cross-compile)])])],
>>>
>>> As far as I can see, there is no way to override this test, say, for
>>> cross-compile cases where your guess is wrong.  The usual way to allow
>>> an override is to use a cache variable, e.g.,
>>>      AC_CACHE_CHECK([for version 0.14.0 of CLooG],
>>>                     [gcc_cv_cloog_rt_0_14_0],
>>>        [AC_RUN_IFELSE([...],
>>>                       [gcc_cv_cloog_rt_0_14_0=yes],
>>>                       [gcc_cv_cloog_rt_0_14_0=no],
>>>                       [gcc_cv_cloog_rt_0_14_0="guessing yes"])])
>>>      if test "$gcc_cv_cloog_rt_0_14_0" = ...
>>> or
>>>      case $gcc_cv_cloog_rt_0_14_0 in
>>>      ...
>>>
>>> You can also cache the other tests (using other variable names, of
>>> course), but for runtime tests it is the most important.  Just be sure
>>> that the third argument of AC_CACHE_CHECK doesn't have side effects
>>> other than setting the cache variable.
>>
>> This is something i don't get right now. The testing goes:
>>  1) Test the compilation.
>>  2) If successful: Test the runtime. If cross-compiling: Ignore the
>> runtime check and go on.
>>
>> What is the advantage of providing an override to a test that is ignored
>> anyways when cross-compiling?
> 
> Yeah, maybe you're right in that an override is overkill in this case.
> (Generally, runtime tests without cache guard trigger a raised eyebrow
> because they might get users stuck.  I wonder whether we can let
> autoconf warn about them.)

Ah thanks. I played around with some of your suggestions the rest of the
day and will have an updated patch soon. Thank you again for having
a quick look. :-)
> 
> Cheers,
> Ralf

Cheers,
Andreas
diff mbox

Patch

diff --git a/ChangeLog.graphite b/ChangeLog.graphite
index c5edc3a..58e30e3 100644
--- a/ChangeLog.graphite
+++ b/ChangeLog.graphite
@@ -1,3 +1,8 @@ 
+2010-08-11  Andreas Simbuerger  <simbuerg@fim.uni-passau.de>
+
+	* configure.ac: Support official CLooG.org versions.
+	* configure: Regenerate.
+
 2010-08-24  Sebastian Pop  <sebastian.pop@amd.com>
 
 	* Merge from mainline (160224:163495).
diff --git a/configure b/configure
index fc759d7..878b72f 100755
--- a/configure
+++ b/configure
@@ -1816,6 +1816,48 @@  fi
 
 } # ac_fn_c_try_link
 
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_c_try_run ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+       $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=$ac_status
+fi
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  return $ac_retval
+
+} # ac_fn_c_try_run
+
 # ac_fn_c_try_cpp LINENO
 # ----------------------
 # Try to preprocess conftest.$ac_ext, and return whether this succeeded.
@@ -1940,48 +1982,6 @@  fi
 
 } # ac_fn_c_check_header_mongrel
 
-# ac_fn_c_try_run LINENO
-# ----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
-# that executables *can* be run.
-ac_fn_c_try_run ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
-  { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: program exited with status $ac_status" >&5
-       $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_retval=$ac_status
-fi
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-  return $ac_retval
-
-} # ac_fn_c_try_run
-
 # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
 # -------------------------------------------------------
 # Tests whether HEADER exists and can be compiled using the include files in
@@ -5885,8 +5885,6 @@  fi
 
 
 # Check for CLOOG
-clooglibs=" -lcloog "
-clooginc=" -DCLOOG_PPL_BACKEND "
 
 
 # Check whether --with-cloog was given.
@@ -5919,19 +5917,19 @@  case $with_cloog in
   "" | yes)
     ;;
   *)
-    clooglibs="-L$with_cloog/lib -lcloog"
-    clooginc="-I$with_cloog/include -DCLOOG_PPL_BACKEND "
+    clooglibs="-L$with_cloog/lib"
+    clooginc="-I$with_cloog/include"
     ;;
 esac
 if test "x$with_cloog_include" != x; then
-  clooginc="-I$with_cloog_include -DCLOOG_PPL_BACKEND "
+  clooginc="-I$with_cloog_include"
 fi
 if test "x$with_cloog_lib" != x; then
-  clooglibs="-L$with_cloog_lib -lcloog"
+  clooglibs="-L$with_cloog_lib"
 fi
 if test "x$with_cloog$with_cloog_include$with_cloog_lib" = x && test -d ${srcdir}/cloog; then
-  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' -lcloog '
-  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include -DCLOOG_PPL_BACKEND '
+  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' '
+  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include '
   enable_cloog_version_check=no
 fi
 
@@ -5943,56 +5941,293 @@  else
 fi
 
 
-if test "x$with_cloog" != "xno" -a "${ENABLE_CLOOG_CHECK}" = "yes"; then
-  saved_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS $clooginc $gmpinc $pplinc"
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version 0.15.5 (or later revision) of CLooG" >&5
-$as_echo_n "checking for version 0.15.5 (or later revision) of CLooG... " >&6; }
+if test "x$with_cloog" != "xno"; then
+  # CLooG configure test programs.
+
+
+
+
+  saved_cflags=$CFLAGS
+  saved_libs=$LIBS
+  saved_ldflags=$LDFLAGS
+
+  # Only fail if the user explicitly selected CLooG.
+  cloog_allow_fail="no"
+  if test "x${with_cloog}${with_cloog_include}${with_cloog_lib}" != "x" ; then
+    cloog_allow_fail="yes"
+  fi
+
+  # Stage 1: Detect the available CLooG+backend combination.
+  clooglegacyinc="-DCLOOG_PPL_BACKEND"
+  cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
+  CFLAGS="${CFLAGS} ${gmpinc} ${pplinc} ${clooginc} ${cloogorginc}"
+  LDFLAGS="${LDFLAGS} ${clooglibs}"
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for installed CLooG type" >&5
+$as_echo_n "checking for installed CLooG type... " >&6; }
+
+  cloog_inc=$clooglegacyinc
+  cloog_org="no"
+  LIBS="-lcloog"
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include "cloog/cloog.h"
+
+
+      #include <cloog/cloog.h>
+
 int
 main ()
 {
 
-  #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 5
-  choke me
-  #endif
+      cloog_version ()
+
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: CLooG-PPL (Legacy)" >&5
+$as_echo "CLooG-PPL (Legacy)" >&6; }
+else
+
+    cloog_inc=$cloogorginc
+    cloog_org="yes"
+    LIBS="-lcloog-isl -lisl"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+      #include <cloog/cloog.h>
+
+int
+main ()
+{
+
+      cloog_version ()
+
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: CLooG-ISL" >&5
+$as_echo "CLooG-ISL" >&6; }
+else
+
+      LIBS="-lcloog-ppl"
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+      #include <cloog/cloog.h>
+
+int
+main ()
+{
+
+      cloog_version ()
+
 
   ;
   return 0;
 }
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: CLooG-PPL" >&5
+$as_echo "CLooG-PPL" >&6; }
+else
+
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }; cloog_inc= ; cloog_org= ; LIBS= ;
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+
+  # Setup required flags for CLooG.
+  if test "x${cloog_inc}${cloog_org}" != "x" ; then
+    clooglibs="${clooglibs} ${LIBS}"
+    clooginc="${clooginc} ${cloog_inc}"
+  else
+    clooglibs= ; clooginc= ;
+  fi
+
+  CFLAGS=$saved_cflags
+  LIBS=$saved_libs
+  LDFLAGS=$saved_ldflags
+
+  # Stage 2: Version check the found CLooG.
+  if test "${ENABLE_CLOOG_CHECK}" = "yes" \
+    && test "${cloog_org}" = "yes" ; then
+    saved_CFLAGS="$CFLAGS"
+    saved_LDFLAGS="$LDFLAGS"
+    CFLAGS="${CFLAGS} ${gmpinc} ${pplinc} ${clooginc} "
+    LDFLAGS="${LDFLAGS} ${clooglibs} "
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version 0.14.0 of CLooG (compile and run time)" >&5
+$as_echo_n "checking for version 0.14.0 of CLooG (compile and run time)... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+      #include <cloog/cloog.h>
+
+int
+main ()
+{
+
+      #if CLOOG_VERSION_MAJOR != 0
+       || CLOOG_VERSION_MINOR != 14
+       || CLOOG_VERSION_REVISION < 0
+       choke me
+      #endif
+
+
+  ;
+  return 0;
+}
+
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
+
+      if test "$cross_compiling" = yes; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (cross-compile)" >&5
+$as_echo "yes (cross-compile)" >&6; }
+else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include "cloog/cloog.h"
+
+
+      #include <stdlib.h>
+      #include <cloog/cloog.h>
+
 int
 main ()
 {
 
-  #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 9
-  choke me
-  #endif
+      if ((cloog_version_major () != CLOOG_VERSION_MAJOR)
+       && (cloog_version_minor () != CLOOG_VERSION_MINOR)
+       && (cloog_version_revision () != CLOOG_VERSION_REVISION))
+        {
+          exit (1);
+        }
+
 
   ;
   return 0;
 }
+
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_run "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: buggy but acceptable" >&5
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed at run time" >&5
+$as_echo "failed at run time" >&6; }; clooglibs= ; clooginc=
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed at compile time" >&5
+$as_echo "failed at compile time" >&6; }; clooglibs= ; clooginc=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+    CFLAGS=${saved_CFLAGS}
+    LDFLAGS=${saved_LDFLAGS}
+  fi
+
+  # Version check for CLooG-PPL (Legacy).
+  if test "${ENABLE_CLOOG_CHECK}" = "yes" \
+    && test "${cloog_org}" = "no" ; then
+    saved_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS $clooginc $gmpinc $pplinc"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version 0.15.5 (or later revision) of CLooG" >&5
+$as_echo_n "checking for version 0.15.5 (or later revision) of CLooG... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+      #include <cloog/cloog.h>
+
+int
+main ()
+{
+
+      #if CLOOG_VERSION_MAJOR != 0
+       || CLOOG_VERSION_MINOR != 15
+       || CLOOG_VERSION_REVISION < 5
+       choke me
+      #endif
+
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+      #include <cloog/cloog.h>
+
+int
+main ()
+{
+
+      #if CLOOG_VERSION_MAJOR != 0
+       || CLOOG_VERSION_MINOR != 15
+       || CLOOG_VERSION_REVISION < 9
+       choke me
+      #endif
+
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: buggy but acceptable" >&5
 $as_echo "buggy but acceptable" >&6; }
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }; clooglibs= ; clooginc=
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  CFLAGS="$saved_CFLAGS"
+    CFLAGS="$saved_CFLAGS"
+  fi
+
+  if test "${cloog_allow_fail}" = "yes" \
+    && test "x${clooglibs}${clooginc}" = "x"; then
+    as_fn_error "Unable to find a usable CLooG. See config.log for details." "$LINENO" 5
+  fi
 fi
 
 # Flags needed for CLOOG
diff --git a/configure.ac b/configure.ac
index 3d969aa..da67bbd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1580,8 +1580,6 @@  AC_SUBST(pplinc)
 
 
 # Check for CLOOG
-clooglibs=" -lcloog "
-clooginc=" -DCLOOG_PPL_BACKEND "
 
 AC_ARG_WITH(cloog, [  --with-cloog=PATH       Specify prefix directory for the installed CLooG-PPL package
                           Equivalent to --with-cloog-include=PATH/include
@@ -1601,19 +1599,19 @@  case $with_cloog in
   "" | yes)
     ;;
   *)
-    clooglibs="-L$with_cloog/lib -lcloog"
-    clooginc="-I$with_cloog/include -DCLOOG_PPL_BACKEND "
+    clooglibs="-L$with_cloog/lib"
+    clooginc="-I$with_cloog/include"
     ;;
 esac
 if test "x$with_cloog_include" != x; then
-  clooginc="-I$with_cloog_include -DCLOOG_PPL_BACKEND "
+  clooginc="-I$with_cloog_include"
 fi
 if test "x$with_cloog_lib" != x; then
-  clooglibs="-L$with_cloog_lib -lcloog"
+  clooglibs="-L$with_cloog_lib"
 fi
 if test "x$with_cloog$with_cloog_include$with_cloog_lib" = x && test -d ${srcdir}/cloog; then
-  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' -lcloog '
-  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include -DCLOOG_PPL_BACKEND '
+  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' '
+  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include '
   enable_cloog_version_check=no
 fi
 
@@ -1622,21 +1620,126 @@  AC_ARG_ENABLE(cloog-version-check,
 ENABLE_CLOOG_CHECK=$enableval,
 ENABLE_CLOOG_CHECK=yes)
 
-if test "x$with_cloog" != "xno" -a "${ENABLE_CLOOG_CHECK}" = "yes"; then
-  saved_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS $clooginc $gmpinc $pplinc"
-  AC_MSG_CHECKING([for version 0.15.5 (or later revision) of CLooG])
-  AC_TRY_COMPILE([#include "cloog/cloog.h"],[
-  #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 5
-  choke me
-  #endif
-  ], [AC_TRY_COMPILE([#include "cloog/cloog.h"],[
-  #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 9
-  choke me
-  #endif
-  ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])])],
-  [AC_MSG_RESULT([no]); clooglibs= ; clooginc= ])
-  CFLAGS="$saved_CFLAGS"
+if test "x$with_cloog" != "xno"; then
+  # CLooG configure test programs.
+  m4_define([CLOOG_BACKEND_PROG],[
+    AC_LANG_PROGRAM([
+      #include <cloog/cloog.h>
+      ],[
+      cloog_version ()
+      ]
+    )]
+  )
+  m4_define([CLOOG_CHECK_CT_PROG],[
+    AC_LANG_PROGRAM([
+      #include <cloog/cloog.h>
+      ], [
+      #if CLOOG_VERSION_MAJOR != $1
+       || CLOOG_VERSION_MINOR != $2
+       || CLOOG_VERSION_REVISION < $3
+       choke me
+      #endif
+      ]
+    )]
+  )
+  m4_define([CLOOG_CHECK_RT_PROG],[
+    AC_LANG_PROGRAM([
+      #include <stdlib.h>
+      #include <cloog/cloog.h>
+      ],[
+      if ((cloog_version_major () != CLOOG_VERSION_MAJOR)
+       && (cloog_version_minor () != CLOOG_VERSION_MINOR)
+       && (cloog_version_revision () != CLOOG_VERSION_REVISION))
+        {
+          exit (1);
+        }
+      ]
+    )]
+  )
+
+  saved_cflags=$CFLAGS
+  saved_libs=$LIBS
+  saved_ldflags=$LDFLAGS
+
+  # Only fail if the user explicitly selected CLooG.
+  cloog_allow_fail="no"
+  if test "x${with_cloog}${with_cloog_include}${with_cloog_lib}" != "x" ; then
+    cloog_allow_fail="yes"
+  fi
+
+  # Stage 1: Detect the available CLooG+backend combination.
+  clooglegacyinc="-DCLOOG_PPL_BACKEND"
+  cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
+  CFLAGS="${CFLAGS} ${gmpinc} ${pplinc} ${clooginc} ${cloogorginc}"
+  LDFLAGS="${LDFLAGS} ${clooglibs}"
+
+  AC_MSG_CHECKING([for installed CLooG type])
+
+  cloog_inc=$clooglegacyinc
+  cloog_org="no"
+  LIBS="-lcloog"
+  AC_LINK_IFELSE([CLOOG_BACKEND_PROG], [AC_MSG_RESULT([CLooG-PPL (Legacy)])],[
+    cloog_inc=$cloogorginc
+    cloog_org="yes"
+    LIBS="-lcloog-isl -lisl"
+    AC_LINK_IFELSE([CLOOG_BACKEND_PROG], [AC_MSG_RESULT([CLooG-ISL])],[
+      LIBS="-lcloog-ppl"
+      AC_LINK_IFELSE([CLOOG_BACKEND_PROG], [AC_MSG_RESULT([CLooG-PPL])],[
+        AC_MSG_RESULT([no]); cloog_inc= ; cloog_org= ; LIBS= ;
+      ])
+    ])
+  ])
+  
+  # Setup required flags for CLooG.
+  if test "x${cloog_inc}${cloog_org}" != "x" ; then
+    clooglibs="${clooglibs} ${LIBS}"
+    clooginc="${clooginc} ${cloog_inc}"
+  else
+    clooglibs= ; clooginc= ;
+  fi
+
+  CFLAGS=$saved_cflags
+  LIBS=$saved_libs
+  LDFLAGS=$saved_ldflags
+
+  # Stage 2: Version check the found CLooG.
+  if test "${ENABLE_CLOOG_CHECK}" = "yes" \
+    && test "${cloog_org}" = "yes" ; then
+    saved_CFLAGS="$CFLAGS"
+    saved_LDFLAGS="$LDFLAGS"
+    CFLAGS="${CFLAGS} ${gmpinc} ${pplinc} ${clooginc} "
+    LDFLAGS="${LDFLAGS} ${clooglibs} "
+    
+    AC_MSG_CHECKING([for version 0.14.0 of CLooG (compile and run time)])
+    AC_COMPILE_IFELSE([CLOOG_CHECK_CT_PROG(0,14,0)],[
+      AC_RUN_IFELSE([CLOOG_CHECK_RT_PROG],
+        [AC_MSG_RESULT([yes])],
+        [AC_MSG_RESULT([failed at run time]); clooglibs= ; clooginc= ],
+        [AC_MSG_RESULT([yes (cross-compile)])])],
+      [AC_MSG_RESULT([failed at compile time]); clooglibs= ; clooginc= ])
+    
+    CFLAGS=${saved_CFLAGS}
+    LDFLAGS=${saved_LDFLAGS}
+  fi
+
+  # Version check for CLooG-PPL (Legacy).
+  if test "${ENABLE_CLOOG_CHECK}" = "yes" \
+    && test "${cloog_org}" = "no" ; then
+    saved_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS $clooginc $gmpinc $pplinc"
+    AC_MSG_CHECKING([for version 0.15.5 (or later revision) of CLooG])
+    AC_COMPILE_IFELSE([CLOOG_CHECK_CT_PROG(0,15,5)],[
+      AC_COMPILE_IFELSE([CLOOG_CHECK_CT_PROG(0,15,9)],[
+        AC_MSG_RESULT([yes])],[
+        AC_MSG_RESULT([buggy but acceptable])])],[
+      AC_MSG_RESULT([no]); clooglibs= ; clooginc= ])
+    CFLAGS="$saved_CFLAGS"
+  fi
+
+  if test "${cloog_allow_fail}" = "yes" \
+    && test "x${clooglibs}${clooginc}" = "x"; then
+    AC_MSG_ERROR([Unable to find a usable CLooG. See config.log for details.])
+  fi
 fi
 
 # Flags needed for CLOOG