unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#24657: Autoconf macro GUILE_PROGS only looks for guile without version suffix even if given version - patch included
@ 2016-10-10  9:45 Freja Nordsiek
  2017-02-23  9:43 ` Andy Wingo
  0 siblings, 1 reply; 5+ messages in thread
From: Freja Nordsiek @ 2016-10-10  9:45 UTC (permalink / raw)
  To: 24657

[-- Attachment #1: Type: text/plain, Size: 6942 bytes --]

While trying to build a package that uses guile with autotools, I
found a problem in the provided GUILE_PROGS macro.

The macro searches for the executables guile, guild, guile-config, and
guile-tools. The problem is that even if the macro is given the
version, it only looks for guile, guild, etc. with no version suffix.
Version suffixes are commonly used by GNU/Linux distros to allow
parallel installations of guile 1.8 and 2.0 (and 2.2 if it is there as
well). Though typically one of them, whichever the distro considers to
be primary, will have no suffix and will be just plain suffixless
guile, guild, etc. I installed 2.1.4 (effective version 2.2) from
source with the suffix '-2.2' to use the same style and not risk
collisions with the guile already on my system (2.0 is the default). I
imagine that others may do this sort of thing as well.

Anyhow, GUILE_PROGS looks for suffixless guile and then compares its
effective version to what was provided as an argument or set in the
variable GUILE_EFFECTIVE_VERSION earlier by the GUILE_PKG macro.

On a system with parallel guile installations with use of version
suffixes, this means that the desired version of guile cannot be
targetted unless that one happens to be suffixless (or have a
suffixless symlink). If there is no suffixless guile, then the macro
fails outright. If there is one and it is pointing to a version
different than given as an argument or through the variable
GUILE_EFFECTIVE_VERSION, it throws an error.

For example, on my system (Fedora 24), guile 2.0 is installed without
suffix and with a 'guile2' symlink by a package from the main
repository. I have installed the latest version of guile using the
sources on the git (2.1.4) in parallel using the suffix '-2.2' meaning
its guile executable is 'guile-2.2'. If I use autoconf with the
provided guile.m4 in the same directory as the following configure.ac
looking for guile 2.2 with GUILE_PROGS


    AC_INIT([guile_autoconf_test], [0.1], [])
    m4_include([guile.m4])
    GUILE_PROGS([2.2])
    AC_OUTPUT


I get the following output from the resulting configure script


    checking for guile... /usr/bin/guile
    checking for Guile version >= 2.2... configure: error: Guile 2.2
required, but 2.0.11 found


If I instead run GUILE_PKG first and use the GUILE_EFFECTIVE_VERSION set by it


    AC_INIT([guile_autoconf_test], [0.1], [])
    m4_include([guile.m4])
    GUILE_PKG([2.2])
    GUILE_PROGS
    dnl Get the same results if I do GUILE_PROGS([2.2])
    AC_OUTPUT


I get a similar error from the configure script


    checking for pkg-config... /usr/bin/pkg-config
    checking pkg-config is at least version 0.9.0... yes
    configure: checking for guile 2.2
    configure: found guile 2.2
    checking for guile... /usr/bin/guile
    configure: error: found development files for Guile 2.2, but
/usr/bin/guile has effective version 2.0


Looking at the beginning of the GUILE_PROGS macro in guile.m4 from guile 2.1.4


    AC_DEFUN([GUILE_PROGS],
     [AC_PATH_PROG(GUILE,guile)
      _guile_required_version="m4_default([$1], [$GUILE_EFFECTIVE_VERSION])"
      if test -z "$_guile_required_version"; then
        _guile_required_version=2.0
      fi
      if test "$GUILE" = "" ; then
          AC_MSG_ERROR([guile required but not found])
      fi
      AC_SUBST(GUILE)


The problem comes from AC_PATH_PROG(GUILE,guile) in the very first
line and then the error 5 and 6 lines below it when it fails. Further
on in the macro, if guile is found, it checks its version against the
provided version or against 2.0.

I've written a patch that makes GUILE_PROGS first look for the
specified version (or default version) of guile first with the version
suffix '-X.Y', and if that fails looks for it with the version suffix
'X.Y' (no dash, unlike the first one), and if that fails looks for it
without any version suffix. If it finds guile in this way, it then
compares the versions. The patched version then uses the same suffix
(or lack there of) when finding guild, guile-config, and guile-tools.

I've attached the patch against the current development version of
guile (well, assuming someone hasn't committed in the last half hour).
It changes the macro and updated the documentation as well (the
documentation builds successfully).

The beginning of the GUILE_PROGS macro is changed to


    AC_DEFUN([GUILE_PROGS],
     [_guile_required_version="m4_default([$1], [$GUILE_EFFECTIVE_VERSION])"
      if test -z "$_guile_required_version"; then
        _guile_required_version=2.0
      fi
      _guile_suffix=-$_guile_required_version
      AC_PATH_PROG(GUILE,[guile$_guile_suffix])
      if test "$GUILE" = "" ; then
          _guile_suffix=$_guile_required_version
          AC_PATH_PROG(GUILE,[guile$_guile_suffix])
          if test "$GUILE" = "" ; then
              _guile_suffix=
              AC_PATH_PROG(GUILE,[guile$_guile_suffix])
              if test "$GUILE" = "" ; then
                  AC_MSG_ERROR([guile required but not found])
              fi
          fi
      fi
      AC_SUBST(GUILE)


Then, the previous configure.ac except with the new autoconf macro
file named new_guile.m4


    AC_INIT([guile_autoconf_test], [0.1], [])
    m4_include([new_guile.m4])
    GUILE_PKG([2.2])
    GUILE_PROGS
    AC_OUTPUT


The configure script succeeds at finding guile 2.2


    checking for pkg-config... /usr/bin/pkg-config
    checking pkg-config is at least version 0.9.0... yes
    configure: checking for guile 2.2
    configure: found guile 2.2
    checking for guile-2.2... /usr/local/bin/guile-2.2
    checking for Guile version >= 2.2... 2.1.4
    checking for guild-2.2... /usr/local/bin/guild-2.2
    checking for guile-config-2.2... /usr/local/bin/guile-config-2.2
    configure: creating ./config.status


If configure.ac is changed to not use GUILE_PKG and look for guile
1.8, which is not on my system,


    AC_INIT([guile_autoconf_test], [0.1], [])
    m4_include([new_guile.m4])
    GUILE_PROGS([1.8])
    AC_OUTPUT


The configure tries to find guile-1.8 and then guile1.8
unsuccessfully. It then finds guile, whose version (2.0) is at least
1.8 so configure considers that a success (whether that would be
considered a bug or a feature is up for debate but that is for another
time).


    checking for guile-1.8... no
    checking for guile1.8... no
    checking for guile... /usr/bin/guile
    checking for Guile version >= 1.8... 2.0.11
    checking for guild... /usr/bin/guild
    checking for guile-config... /usr/bin/guile-config
    configure: creating ./config.status



An alternative way to fix the issue would be to instead make
GUILE_PROGS take one or more arbitrary suffixes to try as inputs.
Another alternative would be to look for all executables that begin
with the string 'guile' and check the version of each one till one is
successful. The latter one seems like it would take quite a bit of
work to implement and test.


Freja Nordsiek

[-- Attachment #2: 0001-Fixed-specific-version-of-guile-search-in-autoconf-m.patch --]
[-- Type: text/x-patch, Size: 2841 bytes --]

From 7e6d8d989e5778e2508f1ce6235a883764fadd31 Mon Sep 17 00:00:00 2001
From: Freja Nordsiek <fnordsie@gmail.com>
Date: Mon, 10 Oct 2016 15:50:19 +0700
Subject: [PATCH] Fixed specific version of guile search in autoconf macro
 GUILE_PROGS.

* meta/guile.m4 (GUILE_PROGS):
Search for guile with suffixes first ('-X.Y' and 'X.Y' where X.Y denotes
the version) before searching for guile with no suffix.
---
 meta/guile.m4 | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/meta/guile.m4 b/meta/guile.m4
index 9fd4f1a..6d69bb9 100644
--- a/meta/guile.m4
+++ b/meta/guile.m4
@@ -181,7 +181,12 @@ AC_DEFUN([GUILE_SITE_DIR],
 #
 # This macro looks for programs @code{guile} and @code{guild}, setting
 # variables @var{GUILE} and @var{GUILD} to their paths, respectively.
-# If @code{guile} is not found, signal an error.
+# The macro will attempt to find @code{guile} with the suffix of
+# @code{-X.Y}, followed by looking for it with the suffix @code{X.Y}, and
+# then fall back to looking for @code{guile} with no suffix. If
+# @code{guile} is still not found, signal an error. The suffix, if any,
+# that was required to find @code{guile} will be used for @code{guild}
+# as well.
 #
 # By default, this macro will search for the latest stable version of
 # Guile (e.g. 2.0). x.y or x.y.z versions can be specified. If an older
@@ -198,13 +203,22 @@ AC_DEFUN([GUILE_SITE_DIR],
 # The variables are marked for substitution, as by @code{AC_SUBST}.
 #
 AC_DEFUN([GUILE_PROGS],
- [AC_PATH_PROG(GUILE,guile)
-  _guile_required_version="m4_default([$1], [$GUILE_EFFECTIVE_VERSION])"
+ [_guile_required_version="m4_default([$1], [$GUILE_EFFECTIVE_VERSION])"
   if test -z "$_guile_required_version"; then
     _guile_required_version=2.0
   fi
+  _guile_suffix=-$_guile_required_version
+  AC_PATH_PROG(GUILE,[guile$_guile_suffix])
   if test "$GUILE" = "" ; then
-      AC_MSG_ERROR([guile required but not found])
+      _guile_suffix=$_guile_required_version
+      AC_PATH_PROG(GUILE,[guile$_guile_suffix])
+      if test "$GUILE" = "" ; then
+          _guile_suffix=
+          AC_PATH_PROG(GUILE,[guile$_guile_suffix])
+          if test "$GUILE" = "" ; then
+              AC_MSG_ERROR([guile required but not found])
+          fi
+      fi
   fi
   AC_SUBST(GUILE)
 
@@ -246,15 +260,15 @@ AC_DEFUN([GUILE_PROGS],
   fi
   AC_MSG_RESULT([$_guile_prog_version])
 
-  AC_PATH_PROG(GUILD,guild)
+  AC_PATH_PROG(GUILD,[guild$_guile_suffix])
   AC_SUBST(GUILD)
 
-  AC_PATH_PROG(GUILE_CONFIG,guile-config)
+  AC_PATH_PROG(GUILE_CONFIG,[guile-config$_guile_suffix])
   AC_SUBST(GUILE_CONFIG)
   if test -n "$GUILD"; then
     GUILE_TOOLS=$GUILD
   else
-    AC_PATH_PROG(GUILE_TOOLS,guile-tools)
+    AC_PATH_PROG(GUILE_TOOLS,[guile-tools$_guile_suffix])
   fi
   AC_SUBST(GUILE_TOOLS)
  ])
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#24657: Autoconf macro GUILE_PROGS only looks for guile without version suffix even if given version - patch included
  2016-10-10  9:45 bug#24657: Autoconf macro GUILE_PROGS only looks for guile without version suffix even if given version - patch included Freja Nordsiek
@ 2017-02-23  9:43 ` Andy Wingo
  2017-02-23 22:31   ` Freja Nordsiek
  2017-03-14 14:25   ` Freja Nordsiek
  0 siblings, 2 replies; 5+ messages in thread
From: Andy Wingo @ 2017-02-23  9:43 UTC (permalink / raw)
  To: Freja Nordsiek; +Cc: 24657-done

[-- Attachment #1: Type: text/plain, Size: 588 bytes --]

Hi Freja,

Thanks for this bug report and the patch, and sorry for the delay :)

On Mon 10 Oct 2016 11:45, Freja Nordsiek <fnordsie@gmail.com> writes:

> While trying to build a package that uses guile with autotools, I
> found a problem in the provided GUILE_PROGS macro.
>
> The macro searches for the executables guile, guild, guile-config, and
> guile-tools. The problem is that even if the macro is given the
> version, it only looks for guile, guild, etc. with no version suffix.

Applied your patch with some small modifications; attached.  Let me know
if it works for you!

Andy


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fixed-specific-version-of-guile-search-in-autoconf-m.patch --]
[-- Type: text/x-patch, Size: 3015 bytes --]

From b6d3ab6c0f912c48463b597ccfa18879f550cf50 Mon Sep 17 00:00:00 2001
From: Freja Nordsiek <fnordsie@gmail.com>
Date: Mon, 10 Oct 2016 15:50:19 +0700
Subject: [PATCH] Fixed specific version of guile search in autoconf macro
 GUILE_PROGS.

* meta/guile.m4 (GUILE_PROGS): Search for guile with suffixes
  first ('-X.Y' and 'X.Y' where X.Y denotes the version) before
  searching for guile with no suffix.  Patch co-authored by Andy Wingo.
---
 meta/guile.m4 | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/meta/guile.m4 b/meta/guile.m4
index 9fd4f1a..2e4f3dc 100644
--- a/meta/guile.m4
+++ b/meta/guile.m4
@@ -181,7 +181,12 @@ AC_DEFUN([GUILE_SITE_DIR],
 #
 # This macro looks for programs @code{guile} and @code{guild}, setting
 # variables @var{GUILE} and @var{GUILD} to their paths, respectively.
-# If @code{guile} is not found, signal an error.
+# The macro will attempt to find @code{guile} with the suffix of
+# @code{-X.Y}, followed by looking for it with the suffix @code{X.Y}, and
+# then fall back to looking for @code{guile} with no suffix. If
+# @code{guile} is still not found, signal an error. The suffix, if any,
+# that was required to find @code{guile} will be used for @code{guild}
+# as well.
 #
 # By default, this macro will search for the latest stable version of
 # Guile (e.g. 2.0). x.y or x.y.z versions can be specified. If an older
@@ -198,16 +203,25 @@ AC_DEFUN([GUILE_SITE_DIR],
 # The variables are marked for substitution, as by @code{AC_SUBST}.
 #
 AC_DEFUN([GUILE_PROGS],
- [AC_PATH_PROG(GUILE,guile)
-  _guile_required_version="m4_default([$1], [$GUILE_EFFECTIVE_VERSION])"
+ [_guile_required_version="m4_default([$1], [$GUILE_EFFECTIVE_VERSION])"
   if test -z "$_guile_required_version"; then
     _guile_required_version=2.0
   fi
-  if test "$GUILE" = "" ; then
+
+  _guile_candidates=guile
+  _tmp=
+  for v in `echo "$_guile_required_version" | tr . ' '`; do
+    if test -n "$_tmp"; then _tmp=.$_tmp; fi
+    _tmp=$v$_tmp
+    _guile_candidates="guile-$_tmp guile$_tmp $_guile_candidates"
+  done
+
+  AC_PATH_PROGS(GUILE,[$_guile_candidates])
+  if test -z "$GUILE"; then
       AC_MSG_ERROR([guile required but not found])
   fi
-  AC_SUBST(GUILE)
 
+  _guile_suffix=`echo "$GUILE" | sed -e 's,^.*/guile\(.*\)$,\1,'`
   _guile_effective_version=`$GUILE -c "(display (effective-version))"`
   if test -z "$GUILE_EFFECTIVE_VERSION"; then
     GUILE_EFFECTIVE_VERSION=$_guile_effective_version
@@ -246,15 +260,15 @@ AC_DEFUN([GUILE_PROGS],
   fi
   AC_MSG_RESULT([$_guile_prog_version])
 
-  AC_PATH_PROG(GUILD,guild)
+  AC_PATH_PROG(GUILD,[guild$_guile_suffix])
   AC_SUBST(GUILD)
 
-  AC_PATH_PROG(GUILE_CONFIG,guile-config)
+  AC_PATH_PROG(GUILE_CONFIG,[guile-config$_guile_suffix])
   AC_SUBST(GUILE_CONFIG)
   if test -n "$GUILD"; then
     GUILE_TOOLS=$GUILD
   else
-    AC_PATH_PROG(GUILE_TOOLS,guile-tools)
+    AC_PATH_PROG(GUILE_TOOLS,[guile-tools$_guile_suffix])
   fi
   AC_SUBST(GUILE_TOOLS)
  ])
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#24657: Autoconf macro GUILE_PROGS only looks for guile without version suffix even if given version - patch included
  2017-02-23  9:43 ` Andy Wingo
@ 2017-02-23 22:31   ` Freja Nordsiek
  2017-03-14 14:25   ` Freja Nordsiek
  1 sibling, 0 replies; 5+ messages in thread
From: Freja Nordsiek @ 2017-02-23 22:31 UTC (permalink / raw)
  To: Andy Wingo; +Cc: 24657-done

Andy,


Your modifications to the patch make it a bit better since it will
handle the case where guile 2.2 gets put under the name guile-2 or
guile2. GIven how much more similar guile 2.1.x (and eventually 2.2.x)
are to guile 2.0.x than guile 2.0.x is to guile 1.8.x, this is not too
unlikely on distribution or another at some point.

Only one potential issue. On the off chance that the guile program
found by AC_PATH_PROGS is in the current directory and the absolute
path is not given nor a prefix of "./", it might be better to replace

    _guile_suffix=`echo "$GUILE" | sed -e 's,^.*/guile\(.*\)$,\1,'`

with

    _guile_suffix=`basename "$GUILE" | sed -e 's,^.*guile\(.*\)$,\1,'`

which replaces echo with basename to remove all the directory
information and then '/' is not looked for in the sed script anymore.


Freja

On Thu, Feb 23, 2017 at 10:43 AM, Andy Wingo <wingo@pobox.com> wrote:
> Hi Freja,
>
> Thanks for this bug report and the patch, and sorry for the delay :)
>
> On Mon 10 Oct 2016 11:45, Freja Nordsiek <fnordsie@gmail.com> writes:
>
>> While trying to build a package that uses guile with autotools, I
>> found a problem in the provided GUILE_PROGS macro.
>>
>> The macro searches for the executables guile, guild, guile-config, and
>> guile-tools. The problem is that even if the macro is given the
>> version, it only looks for guile, guild, etc. with no version suffix.
>
> Applied your patch with some small modifications; attached.  Let me know
> if it works for you!
>
> Andy
>





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#24657: Autoconf macro GUILE_PROGS only looks for guile without version suffix even if given version - patch included
  2017-02-23  9:43 ` Andy Wingo
  2017-02-23 22:31   ` Freja Nordsiek
@ 2017-03-14 14:25   ` Freja Nordsiek
  2017-03-14 14:44     ` Andy Wingo
  1 sibling, 1 reply; 5+ messages in thread
From: Freja Nordsiek @ 2017-03-14 14:25 UTC (permalink / raw)
  To: Andy Wingo; +Cc: 24657-done

[-- Attachment #1: Type: text/plain, Size: 2267 bytes --]

Found a bug in the modifications you made. Sorry for not catching this
before it got included into the Guile 2.1.8 release.

When constructing the candidates for the guile executable
(_guile_candidates), the version numbers essentially get reverse. This
is not noticeable for 2.2 since 2.2 reversed is still 2.2. But it is a
major issue for Guile 2.0.x and 1.8.x where 0.2 and 8.1 get generated
meaning the right executables could be missed. For the current version
of GUILE_PROGS, looking for 2.0 results in the following candidates

    guile-0.2 guile0.2 guile-2 guile2 guile

and for 1.8

    guile-8.1 guile8.1 guile-1 guile1 guile


The fix is luckily pretty trivial. A patch is attached.

For convenience of anyone trying to reproduce this bug, here are two
shell scripts that will take the version as the first input argument
and return the generated guile executable candidates.

The version with the bug is

    #!/bin/sh
    _guile_required_version=$1
    _guile_candidates=guile
    _tmp=
    for v in `echo "$_guile_required_version" | tr . ' '`; do
      if test -n "$_tmp"; then _tmp=.$_tmp; fi
      _tmp=$v$_tmp
      _guile_candidates="guile-$_tmp guile$_tmp $_guile_candidates"
    done
    echo $_guile_candidates

And the version with the fix is

    #!/bin/sh
    _guile_required_version=$1
    _guile_candidates=guile
    _tmp=
    for v in `echo "$_guile_required_version" | tr . ' '`; do
      if test -n "$_tmp"; then _tmp=$_tmp.; fi
      _tmp=$_tmp$v
      _guile_candidates="guile-$_tmp guile$_tmp $_guile_candidates"
    done
    echo $_guile_candidates

On Thu, Feb 23, 2017 at 10:43 AM, Andy Wingo <wingo@pobox.com> wrote:
> Hi Freja,
>
> Thanks for this bug report and the patch, and sorry for the delay :)
>
> On Mon 10 Oct 2016 11:45, Freja Nordsiek <fnordsie@gmail.com> writes:
>
>> While trying to build a package that uses guile with autotools, I
>> found a problem in the provided GUILE_PROGS macro.
>>
>> The macro searches for the executables guile, guild, guile-config, and
>> guile-tools. The problem is that even if the macro is given the
>> version, it only looks for guile, guild, etc. with no version suffix.
>
> Applied your patch with some small modifications; attached.  Let me know
> if it works for you!
>
> Andy
>

[-- Attachment #2: 0001-Fixed-reversed-version-order-bug-in-GUILE_PROGS-Auto.patch --]
[-- Type: text/x-patch, Size: 782 bytes --]

From 205f41d41b94f12670394ec526dddeaf1416d740 Mon Sep 17 00:00:00 2001
From: Freja Nordsiek <fnordsie@gmail.com>
Date: Tue, 14 Mar 2017 15:14:47 +0100
Subject: [PATCH] Fixed reversed version order bug in GUILE_PROGS Autoconf
 macro.

---
 meta/guile.m4 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/guile.m4 b/meta/guile.m4
index 4a2e285..501a21c 100644
--- a/meta/guile.m4
+++ b/meta/guile.m4
@@ -234,8 +234,8 @@ AC_DEFUN([GUILE_PROGS],
   _guile_candidates=guile
   _tmp=
   for v in `echo "$_guile_required_version" | tr . ' '`; do
-    if test -n "$_tmp"; then _tmp=.$_tmp; fi
-    _tmp=$v$_tmp
+    if test -n "$_tmp"; then _tmp=$_tmp.; fi
+    _tmp=$_tmp$v
     _guile_candidates="guile-$_tmp guile$_tmp $_guile_candidates"
   done
 
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#24657: Autoconf macro GUILE_PROGS only looks for guile without version suffix even if given version - patch included
  2017-03-14 14:25   ` Freja Nordsiek
@ 2017-03-14 14:44     ` Andy Wingo
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Wingo @ 2017-03-14 14:44 UTC (permalink / raw)
  To: Freja Nordsiek; +Cc: 24657-done

On Tue 14 Mar 2017 15:25, Freja Nordsiek <fnordsie@gmail.com> writes:

> Found a bug in the modifications you made. Sorry for not catching this
> before it got included into the Guile 2.1.8 release.

Thank you!  Applied.  Note that in the gnu coding standards you need an
entry in the commit log for every file you modify.  Blah, I know, but
that's how it is.

Andy





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-03-14 14:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-10  9:45 bug#24657: Autoconf macro GUILE_PROGS only looks for guile without version suffix even if given version - patch included Freja Nordsiek
2017-02-23  9:43 ` Andy Wingo
2017-02-23 22:31   ` Freja Nordsiek
2017-03-14 14:25   ` Freja Nordsiek
2017-03-14 14:44     ` Andy Wingo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).