bug#54421: AM_PROG_AR and LT_INIT don't work together when using lib.exe

2022-03-16 Thread Tim Ruffing
Hello :)

Assume environment variable AR="lib.exe" and configure.ac has

```
AM_PROG_AR
LT_INIT
```

Then AM_PROG_AR checks for an archiver using AC_CHECK_TOOLS. Then it
detects the lib.exe interface and prefixes the AR variable with a call
to ar-lib. (There's a FIXME in the code that says that overwriting is
wrong). But so far so good, this works.

Now LT_INIT will again look for an archiver using AC_CHECK_TOOLS (in
subroutine _LT_PROG_AR). The check will discover that ac_cv_prog_AR has
"lib.exe" (unprefixed!) and overwrites AR with it.

So AR is correct (with ar-lib prefix) after AM_PROG_AR but LT_INIT
overwrites with the unprefixed value again, causing the build the fail.
I wonder why noone has reported this so far. I tend to think that
lib.exe support is only really useful in combination with libtool but
this then triggers the bug.

Possible workarounds include:
 * Calling AM_PROG_AR after LT_INIT. But this will raise a warning in
   autoreconf telling me that I should call AM_PROG_AR before LT_INIT.
 * Clearing the cache value. This is what I've done for now in our
   project [1]. Note that here I'm careful and clear two cache
   variables but in in the end it's enough to clear ac_cv_prog_AR.

The aforementioned FIXME mentions introducing am_AR as a cleaner way.
This sounds like it fix the problem but maybe I'm overlooking
something. A crude hack is to overwrite not only AR but also
ac_cv_prog_AR.

Best,
Tim

[1] 
https://github.com/bitcoin-core/secp256k1/pull/1084/commits/e6b8a1ca47c07b798cf45ea85e257546c4dbafc4





bug#54421: AM_PROG_AR and LT_INIT don't work together when using lib.exe

2023-01-13 Thread Tim Ruffing
On Fri, 2023-01-13 at 05:52 +, Mike Frysinger wrote:
> i think the expectation is that, if you're using libtool, then you
> use libtool.  

Well, I *use* libtool. libtool needs some AR. I choose to use
libtool.exe with the ar-lib wrapper. 






bug#54421: AM_PROG_AR and LT_INIT don't work together when using lib.exe

2023-01-13 Thread Mike Frysinger
On 13 Jan 2023 13:52, Tim Ruffing wrote:
> On Fri, 2023-01-13 at 05:52 +, Mike Frysinger wrote:
> > i think the expectation is that, if you're using libtool, then you
> > use libtool.  
> 
> Well, I *use* libtool. libtool needs some AR. I choose to use
> libtool.exe with the ar-lib wrapper. 

you wondered why no one has reported/noticed hits before.  i gave you
an explanation.  what you're doing is unusual, and so far, i haven't
seen an explanation as to why you're doing something unusual.  so the
(implicit) question still stands: why are you using Automake's archive
(ar-lib) logic when libtool already provides support for doing the same
thing -- creating static archives.

should we fix it ?  probably.  is it worth the effort ?  maybe not.
would we accept patches from someone who wants to spend the time ?
depends on the patch.
-mike


signature.asc
Description: PGP signature