Subject: bug#14911: automake-1.14 t/ccnoco-lt failure on OS X

From: Hanspeter Niederstrasser <[email-masked]>
Date: Sun, 21 Jul 2013 22:35:08 -0400

On 7/21/2013 11:49 AM, Stefano Lattarini wrote:
> tags 14911 + patch
> severity 14911 minor
> thanks
>
> On 07/19/2013 10:24 PM, Nick Bowler wrote:
>> On 2013-07-19 11:48 -0400, Hanspeter Niederstrasser wrote:
>>> On OS X 10.7, t/ccnoco-lt fails with the following error (from
>>> test-suite.log).  For completeness sake, t/depcomp2 also failed, but I
>>> applied the patch from #14706 and that allowed depcomp2 to pass.
>>>
>>> ------- 8< ------- 8< ------- 8< -------
>>>
>>> FAIL: t/ccnoco-lt
>>> =================
>> [...]
>>> libtool: link:
>>> /sw/build.build/automake1.14-1.14-1/automake-1.14/t/ccnoco-lt.dir/compile /sw/build.build/automake1.14-1.14-1/automake-1.14/t/ax/cc-no-c-o
>>> -dynamiclib -Wl,-undefined -Wl,dynamic_lookup -o .libs/libwish.0.dylib
>>> .libs/libwish.o   -L/sw/lib  -O2   -install_name
>>> /usr/local/lib/libwish.0.dylib -compatibility_version 1 -current_version
>>> 1.0 -Wl,-single_module
>>> /sw/build.build/automake1.14-1.14-1/automake-1.14/t/ax/cc-no-c-o: both
>>> '-o' and '-c' seen on the command line
>>> make: *** [libwish.la] Error 2
>>
>> Looks like a false negative to me.
>>
>> Automake uses a deliberately-crippled compiler wrapper which is designed
>> to reject command-lines with -c and -o for testing purposes, found in
>> automake/t/ax/cc-no-c-o.  The problem appears to be that the wrapper's
>> test of the command line arguments is too simplistic, and incorrectly
>> considers the above command line as a using both -c and -o, when it
>> clearly does not.
>>
>> So the test will need to be made more robust.
>>
> Agreed.  Could anybody test the patch below?
>
> Thanks,
>    Stefano
>
> ---- 8< --- 8< ---- 8< --- 8< ---- 8< --- 8< ---- 8< --- 8< ----
>
>  From 4d7dcafc0f419378cd80e46f9390950c6fbaffa0 Mon Sep 17 00:00:00 2001
> Message-Id: <4d7dcafc0[email-masked]>
> From: Stefano Lattarini <[email-masked]>
> Date: Sun, 21 Jul 2013 13:46:48 +0100
> Subject: [PATCH] test: avoid false positives in 'cc-no-c-o' script
>
> Fixes automake bug#14991.
>
> * t/ax/cc-no-c-o.in: Be more careful in determining whether both the
> '-c' and '-o' options have been passed on the command line to the
> compiler.  In particular, do not spuriously complain in the face of
> options like '-compatibility_version' or '-current_version' (seen on
> Mac OS X 10.7).
> * THANKS: Update.
>
> Signed-off-by: Stefano Lattarini <[email-masked]>
> ---
>   THANKS            |  1 +
>   t/ax/cc-no-c-o.in | 20 ++++++++++++++++----
>   2 files changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/THANKS b/THANKS
> index b708943..1482da2 100644
> --- a/THANKS
> +++ b/THANKS
> @@ -145,6 +145,7 @@ Gwenole Beauchesne              [email-masked]
>   H.J. Lu                         [email-masked]
>   H.Merijn Brand                  [email-masked]
>   Hans Ulrich Niedermann          [email-masked]
> +Hanspeter Niederstrasser        [email-masked]
>   Harald Dunkel                   [email-masked]
>   Harlan Stenn                    [email-masked]
>   He Li                           [email-masked]
> diff --git a/t/ax/cc-no-c-o.in b/t/ax/cc-no-c-o.in
> index c18f9b9..bbc9ec9 100644
> --- a/t/ax/cc-no-c-o.in
> +++ b/t/ax/cc-no-c-o.in
> @@ -19,11 +19,23 @@
>
>   am_CC=${AM_TESTSUITE_GNU_CC-'@GNU_CC@'}
>
> -case " $* " in
> - *\ -c*\ -o* | *\ -o*\ -c*)
> +seen_c=false
> +seen_o=false
> +
> +for arg
> +do
> +  case $arg in
> +    -c)
> +      seen_c=true;;
> +    # It is acceptable not to leave a space between the '-o' option
> +    # and its argument, so we have to cater for that.
> +    -o|-o*)
> +      seen_o=true;;
> +  esac
> +  if $seen_c && $seen_o; then
>       echo "$0: both '-o' and '-c' seen on the command line" >&2
>       exit 2
> -    ;;
> -esac
> +  fi
> +done
>
>   exec $am_CC "$@"

This patch allowed t/ccnoco-lt to PASS.  One nit: It is for bug#14911, 
not bug#14991 as mentioned in the comment.

Thank you for the quick solution.

Hanspeter