diff mbox

lftp: new package.

Message ID 528E8110.10406@mind.be
State Superseded
Headers show

Commit Message

Arnout Vandecappelle Nov. 21, 2013, 9:54 p.m. UTC
On 21/11/13 18:12, Thomas Petazzoni wrote:
> Dear Arnaud Rébillout,
>
> On Thu, 21 Nov 2013 17:17:39 +0100, Arnaud Rébillout wrote:
>
[snip]
>> But after that comes the second problem: the test is supposed to run
>> this piece of code. How are we supposed to run cross-compiled code on
>> the host ?
>> I can imagine it's a typical problem, but I don't know how it's supposed
>> to be handled.
>
> Yes, that's a typical problem, and of course, we cannot use configure
> scripts that try to run programs compiled for the target on the build
> machine.
>
> I believe we have two solutions here:
>
>   (1) Find the configure variable that can be passed in the configure
>       environment to tell configure that posix_fallocate() is not
>       available. Set it to "available" when a glibc/eglibc toolchain is
>       used and "not available" when an uClibc toolchain is used.
>
>   (2) Or, better, improve the configure test to be able to only do the
>       compile test and not the execution test, and assume that if a
>       posix_fallocate() program builds, then it means that it works. We
>       don't use those old glibcs or AIX that have broken
>       posix_fallocate().

  You can give AC_TRY_RUN a fourth argument with actions to take when 
cross-compiling. These actions are taken when compilation was successful. 
Basically, the following patch should work:

----------------------------------
Fix support for cross-compilation.

The check for posix_fallocate doesn't handle the cross-compilation case. 
Assume that it works, because cross-compilation for AIX or old glibc is 
unlikely.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
----------------------------------


  But of course I haven't tested it :-)

  If this patch is OK, can you also upstream it?

  Don't forget to add your own SOB BTW.

  Regards,
  Arnout

Comments

Thomas Petazzoni Nov. 21, 2013, 10 p.m. UTC | #1
Dear Arnout Vandecappelle,

On Thu, 21 Nov 2013 22:54:24 +0100, Arnout Vandecappelle wrote:

>   You can give AC_TRY_RUN a fourth argument with actions to take when 
> cross-compiling. These actions are taken when compilation was successful. 
> Basically, the following patch should work:
> 
> ----------------------------------
> Fix support for cross-compilation.
> 
> The check for posix_fallocate doesn't handle the cross-compilation case. 
> Assume that it works, because cross-compilation for AIX or old glibc is 
> unlikely.
> 
> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
> ---
> diff -Nrup lftp-4.4.10.orig/m4/lftp.m4 lftp-4.4.10/m4/lftp.m4
> --- lftp-4.4.10.orig/m4/lftp.m4 2013-03-19 13:25:50.000000000 +0100
> +++ lftp-4.4.10/m4/lftp.m4      2013-11-21 22:46:27.776820935 +0100
> @@ -271,6 +271,8 @@ AC_DEFUN([LFTP_POSIX_FALLOCATE_CHECK],[
>          i_cv_posix_fallocate_works=yes
>        ], [
>          i_cv_posix_fallocate_works=no
> +     ], [
> +       i_cv_posix_fallocate_works=yes
>        ])
>      ])
>      if test x$i_cv_posix_fallocate_works = xyes; then
> ----------------------------------

Seeing this, I believe that passing i_cv_posix_fallocate_works=yes in
the ./configure environment is a better solution.

Thomas
Arnout Vandecappelle Nov. 21, 2013, 10:19 p.m. UTC | #2
On 21/11/13 23:00, Thomas Petazzoni wrote:
> Dear Arnout Vandecappelle,
>
> On Thu, 21 Nov 2013 22:54:24 +0100, Arnout Vandecappelle wrote:
>
>>    You can give AC_TRY_RUN a fourth argument with actions to take when
>> cross-compiling. These actions are taken when compilation was successful.
>> Basically, the following patch should work:
>>
>> ----------------------------------
>> Fix support for cross-compilation.
>>
>> The check for posix_fallocate doesn't handle the cross-compilation case.
>> Assume that it works, because cross-compilation for AIX or old glibc is
>> unlikely.
>>
>> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
>> ---
>> diff -Nrup lftp-4.4.10.orig/m4/lftp.m4 lftp-4.4.10/m4/lftp.m4
>> --- lftp-4.4.10.orig/m4/lftp.m4 2013-03-19 13:25:50.000000000 +0100
>> +++ lftp-4.4.10/m4/lftp.m4      2013-11-21 22:46:27.776820935 +0100
>> @@ -271,6 +271,8 @@ AC_DEFUN([LFTP_POSIX_FALLOCATE_CHECK],[
>>           i_cv_posix_fallocate_works=yes
>>         ], [
>>           i_cv_posix_fallocate_works=no
>> +     ], [
>> +       i_cv_posix_fallocate_works=yes
>>         ])
>>       ])
>>       if test x$i_cv_posix_fallocate_works = xyes; then
>> ----------------------------------
>
> Seeing this, I believe that passing i_cv_posix_fallocate_works=yes in
> the ./configure environment is a better solution.

  But that wouldn't detect the uClibc case when posix_fallocate isn't 
available...

  Regards,
  Arnout
Thomas Petazzoni Nov. 22, 2013, 8:15 a.m. UTC | #3
Dear Arnout Vandecappelle,

On Thu, 21 Nov 2013 23:19:10 +0100, Arnout Vandecappelle wrote:

> > Seeing this, I believe that passing i_cv_posix_fallocate_works=yes in
> > the ./configure environment is a better solution.
> 
>   But that wouldn't detect the uClibc case when posix_fallocate isn't 
> available...

I thought there were two tests, with two different variables:

 * One testing if a program with posix_fallocate() can be *compiled*.
   This test we need to let it as it is.
 
 * One testing if a program with posix_fallocate() can *run*. This test
   we need to tell the configure script to just assume that
   posix_fallocate() works (but of course, making the assumption that
   a failure on the previous test will make the configure conclude that
   posix_fallocate is not available).

Best regards,

Thomas
Arnout Vandecappelle Nov. 22, 2013, 9:20 a.m. UTC | #4
On 22/11/13 09:15, Thomas Petazzoni wrote:
> Dear Arnout Vandecappelle,
>
> On Thu, 21 Nov 2013 23:19:10 +0100, Arnout Vandecappelle wrote:
>
>>> Seeing this, I believe that passing i_cv_posix_fallocate_works=yes in
>>> the ./configure environment is a better solution.
>>
>>    But that wouldn't detect the uClibc case when posix_fallocate isn't
>> available...
>
> I thought there were two tests, with two different variables:
>
>   * One testing if a program with posix_fallocate() can be *compiled*.
>     This test we need to let it as it is.
>
>   * One testing if a program with posix_fallocate() can *run*. This test
>     we need to tell the configure script to just assume that
>     posix_fallocate() works (but of course, making the assumption that
>     a failure on the previous test will make the configure conclude that
>     posix_fallocate is not available).

  Well, yes, there are two tests in configure, but only a single macro in 
lftp.m4. AC_TRY_RUN compiles the first argument and then tries to run it 
(if not cross-compiling). The second argument is executed if the run 
succeeds, the third argument if the compilation or the run fails, the 
fourth argument if compilation succeeds but it cannot be ran because 
you're cross-compiling.

  There are a number of other instances of AC_TRY_RUN in the lftp 
configure scripts, but the others all have the fourth argument.

  Regards,
  Arnout
Arnaud Rébillout Nov. 25, 2013, 1:06 p.m. UTC | #5
On 11/22/2013 10:20 AM, Arnout Vandecappelle wrote:
>
>  Well, yes, there are two tests in configure, but only a single macro 
> in lftp.m4. AC_TRY_RUN compiles the first argument and then tries to 
> run it (if not cross-compiling). The second argument is executed if 
> the run succeeds, the third argument if the compilation or the run 
> fails, the fourth argument if compilation succeeds but it cannot be 
> ran because you're cross-compiling.
>
>  There are a number of other instances of AC_TRY_RUN in the lftp 
> configure scripts, but the others all have the fourth argument.

I tried to add a 4th argument to the AC_TRY_RUN as you suggested in a 
previous mail:

> +     ], [
> +       i_cv_posix_fallocate_works=yes 

But in case of cross-compiation, it always returns yes, even if 
posix_fallocate is not defined by the libc: autotools don't even try to 
compile in case of cross-compile.
So it looks like a compile tested is needed in addition to the run test.


I just sent a second revision of the patch with the compile test added. 
I tried it on two different buildroot repo, one with posix_fallocate, 
and the other without posix_fallocate. It's working good.


Best regards,
Arnaud
diff mbox

Patch

diff -Nrup lftp-4.4.10.orig/m4/lftp.m4 lftp-4.4.10/m4/lftp.m4
--- lftp-4.4.10.orig/m4/lftp.m4 2013-03-19 13:25:50.000000000 +0100
+++ lftp-4.4.10/m4/lftp.m4      2013-11-21 22:46:27.776820935 +0100
@@ -271,6 +271,8 @@  AC_DEFUN([LFTP_POSIX_FALLOCATE_CHECK],[
         i_cv_posix_fallocate_works=yes
       ], [
         i_cv_posix_fallocate_works=no
+     ], [
+       i_cv_posix_fallocate_works=yes
       ])
     ])
     if test x$i_cv_posix_fallocate_works = xyes; then