Bug 1559 - Autoconf overrides AR environment variable
Summary: Autoconf overrides AR environment variable
Status: CLOSED WONTFIX
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Build system (show other bugs)
Version: 5.1p1
Hardware: All All
: P2 normal
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-21 14:01 AEDT by Brice Lin
Modified: 2009-10-06 15:02 AEDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brice Lin 2009-02-21 14:01:14 AEDT
Reproduced on Linux (x86) and Mac OS X (PPC and x86):

$ LD="ld" AR="foo" ./configure

Running the above command results in Autoconf incorrectly setting the AR variable in the generated Makefile. Setting CC instead of LD causes the same issue, while only specifying AR works without issue.
Comment 1 Damien Miller 2009-02-21 14:41:41 AEDT
It works for me:

$ env LD=/tmp/xxld AR=/tmp/har ./configure
...
$ egrep "^(LD|AR)=" Makefile
LD=/tmp/xxld
AR=/tmp/har
Comment 2 Brice Lin 2009-02-21 18:28:26 AEDT
I pulled the tarball from ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-5.1p1.tar.gz to generate the error. Did you use that as well?
Comment 3 Brice Lin 2009-02-21 19:51:22 AEDT
$ env LD=/tmp/xxld AR=/tmp/har ./configure
$ egrep "^(LD|AR)=" Makefile
LD=/tmp/xxld
AR=/tmp/har

$ env LD="ld" AR="foo" ./configure
$ egrep "^(LD|AR)=" Makefile      
LD=ld
AR=/usr/bin/ar

For some reason, the command on top works differently than the one on bottom.
Comment 4 Damien Miller 2009-02-22 08:50:17 AEDT
do you really have a semi-functional ar-replacement called "foo" in your path? autoconf checks that the selected linker at least exists and is executable. Furthermore if the linker exists, but is not functional, then it will cause configure test failures.

Try copying your /usr/bin/ar to a different path (e.g. /tmp/har) and trying it.
Comment 5 Brice Lin 2009-02-22 09:39:10 AEDT
I need to compile with LLVM, which requires pointing AR to llvm-ar (which exists). That's how I encountered the bug in the first place. What I posted just serves as an example test case of the issue.
Comment 6 Damien Miller 2009-02-22 10:10:51 AEDT
It is an invalid testcase for the reasons that I just described. 

If you are trying to use llvm-ar then why not show an example with llvm-ar? You can look at the details of what searches are being performed in config.log.
Comment 7 Brice Lin 2009-02-22 11:45:53 AEDT
$ env CC="llvm-gcc" LD="llvm-ld" AR="llvm-ar" RANLIB="llvm-ranlib" ./configure
$ egrep "^(CC|LD|AR|RANLIB)=" Makefile
CC=llvm-gcc
LD=llvm-ld
AR=/usr/bin/ar
RANLIB=llvm-ranlib
$ llvm-ar 
llvm-ar: Not enough positional command line arguments specified!
Must specify at least 2 positional arguments: See: llvm-ar --help

After running the above commands, I combed through config.log for llvm-ar, but nothing shows up. I've included what seems like the relevant lines from config.log. What else should I look for to debug this?

$ egrep "( |\W)(ar|ranlib)\W*$" config.log
configure:4038: checking for ranlib
configure:4065: result: llvm-ranlib
configure:4256: checking for ar
configure:4274: found /usr/bin/ar
configure:4286: result: /usr/bin/ar
ac_cv_path_AR=/usr/bin/ar
ac_cv_prog_ac_ct_RANLIB=llvm-ranlib
AR='/usr/bin/ar'
RANLIB='llvm-ranlib'
Comment 8 Damien Miller 2009-02-22 19:39:22 AEDT
Try an absolute path for AR (I have no idea why autoconf demands this)
Comment 9 Brice Lin 2009-02-22 21:56:14 AEDT
Thanks, setting AR to the absolute path of llvm-ar works. It still seems like a bug with Autoconf though. There's no reason for it to require absolute paths, especially because it perfectly detects them for the other environment variables (like RANLIB). Can you do anything about it?
Comment 10 Damien Miller 2009-02-23 08:07:37 AEDT
Probably not - it is buried deep in the guts of autoconf (... and you thought this thing smelt bad on the outside). I'd suggest filing a but on them.
Comment 11 Darren Tucker 2009-08-28 18:20:45 AEST
Since there's a workaround and the problem is in autoconf generated file we're not going to try to bodge around it.

Thanks for the report, sorry we couldn't help.  Closing.
Comment 12 Damien Miller 2009-10-06 15:02:40 AEDT
Mass move of RESOLVED bugs to CLOSED now that 5.3 is out.