msys 1.0.13 gawk problem

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

msys 1.0.13 gawk problem

Ralf Fassel
I'm using:
  msysCORE-1.0.13-1-msys-1.0.13-bin.tar.bz2
  bash-3.1.17-2-msys-1.0.11-bin.tar.bz2
  gawk-3.1.7-1-msys-1.0.11-bin.tar.bz2

Extracted in some tmp directory, started msys.bat.

Problem is in gawk with printf, the positional parameters are printed
wrong:

Ok, as expected:
    $ echo -1 2 | gawk '{print $1, $2}'
    -1 2
    $  echo -1 2 | gawk '{printf "%d %d\n", $1, $2}'
    -1 2

Bug: wrong values printed (should be -1 2 in both cases):
    $  echo -1 2 | gawk '{printf "%g %g\n", $1, $2}'
    1 -2

    $  echo -1 2 | gawk '{printf "%f %f\n", $1, $2}'
    1.000000 -2.000000

    $ type gawk
    gawk is hashed (/bin/gawk)

    $ type echo
    echo is a shell builtin

    $ uname -a
    MINGW32_NT-5.1 JAGUAR 1.0.13(0.47/3/2) 2010-01-24 17:47 i686 Msys

    $ gawk --version
    Use -h to see help about each section
    GNU Awk 3.1.7
    Copyright (C) 1989, 1991-2009 Free Software Foundation.

- Same awk version on linux doesn't have this problem.
- Msys 1.0.11 doesn't have this problem.

Can anyone confirm this?

Thanks
R'

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Mingw-msys mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mingw-msys
Reply | Threaded
Open this post in threaded view
|

Re: msys 1.0.13 gawk problem

Charles Wilson-8
Ralf Fassel wrote:
> Bug: wrong values printed (should be -1 2 in both cases):
>     $  echo -1 2 | gawk '{printf "%g %g\n", $1, $2}'
>     1 -2
>
>     $  echo -1 2 | gawk '{printf "%f %f\n", $1, $2}'
>     1.000000 -2.000000

>     $ gawk --version
>     Use -h to see help about each section
>     GNU Awk 3.1.7
>     Copyright (C) 1989, 1991-2009 Free Software Foundation.
>
> - Same awk version on linux doesn't have this problem.
> - Msys 1.0.11 doesn't have this problem.
>
> Can anyone confirm this?

I can confirm the behavior on msys, but not that it works any
differently anywhere else:

msys:
$ uname -s -r
MINGW32_NT-6.0 1.0.13(0.47/3/2)
$ gawk --version
GNU Awk 3.1.7
$ echo "-1 2" | gawk '{printf "%f %f\n", $1, $2}'
-1.000000 2.000000

linux:
$ uname -s -r
Linux 2.6.31.6-desktop-1mnb
$ gawk --version
GNU Awk 3.1.7
$ echo "-1 2" | gawk '{printf "%f %f\n", $1, $2}'
-1.000000 2.000000

$ uname -s -r
CYGWIN_NT-6.0 1.7.1(0.218/5/3)
$ gawk --version
GNU Awk 3.1.7
$ echo "-1 2" | gawk '{printf "%f %f\n", $1, $2}'
-1.000000 2.000000

My hunch is that msys-1.0.11 had a bug, or there was a problem in an
older version of gawk.  I really wouldn't expect gawk's %f printf to act
any differently that C's:

#include <stdio.h>
int main(int argc, char *argv[])
{
        double d1 = -1;
        double d2 = 2;
        printf ("%f %f\n", d1, d2);
}


$ gcc -o bob bob.c
$ ./bob
-1.000000 2.000000

--
Chuck

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Mingw-msys mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mingw-msys
Reply | Threaded
Open this post in threaded view
|

Re: msys 1.0.13 gawk problem

Ralf Fassel
* Charles Wilson
| msys:
| $ uname -s -r
| MINGW32_NT-6.0 1.0.13(0.47/3/2)
| $ gawk --version
| GNU Awk 3.1.7
| $ echo "-1 2" | gawk '{printf "%f %f\n", $1, $2}'
| -1.000000 2.000000

This is what I'd expect.

| I really wouldn't expect gawk's %f printf to act any differently
| that C's:
|
| #include <stdio.h>
| int main(int argc, char *argv[])
| {
| double d1 = -1;
| double d2 = 2;
| printf ("%f %f\n", d1, d2);
| }
|
|
| $ gcc -o bob bob.c
| $ ./bob
| -1.000000 2.000000

In fact, it does not:

    $ gawk '{printf "%g %g\n", -1, 2}'

    1 -2

    -1 2

    1 -2

    -1 2

Note the alternating sign...

    $ cat x.c
    #include <stdio.h>
    int main(int argc, char *argv[])
    {
            double d1 = -1;
            double d2 = 2;
            printf ("%f %f\n", d1, d2);
            printf ("%f %f\n", d1, d2);
            printf ("%f %f\n", d1, d2);
            printf ("%f %f\n", d1, d2);
    }

    $ gcc -o x x.c

    $ ./x
    1.000000 -2.000000
    -1.000000 2.000000
    1.000000 -2.000000
    -1.000000 2.000000

I.e. the C binary also gets it wrong.  Seems like this has nothing to
do with gawk.

If I run the very same binary in the 1.0.12 environment, it is ok:
    $ ./x
    -1.000000 2.000000
    -1.000000 2.000000

msysinfo for 1.0.13:
    $ msysinfo
    msysinfo-1.3: Send this to the MSYS support list:

    MSYS 1.0.13(0.47/3/2) 2010-01-15 19:54 i686 unknown; targ=MINGW32
    GNU bash, version 3.1.17(1)-release (i686-pc-msys); ENV=.profile
    GNU Make 3.81This program built for i686-pc-msys; MAKE_MODE=unix
    gcc (GCC) 3.4.4 (msys special); targ=MINGW32
    GNU ld (GNU Binutils) 2.19.51.20090704
     2010-01-15 19:56:40.000000000 +0000 /bin/msys-1.0.dll
     2008-03-25 23:51:00.000000000 +0000 /bin/make.exe
     2010-01-16 20:38:39.000000000 +0000 /bin/gcc.exe
    2 2010-01-16 21:17:47.000000000 +0000 /bin/ld.exe
    HOME=/c/home/ralf
    Sysname=MINGW32_NT-5.1  OSTYPE=msys  TERM=cygwin
    PATH=/bin
    $ ls -tx /c/home/ralf/tmp
    x.exe*  x.c

Will try to recompile the MSYS runtime...

R'

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Mingw-msys mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mingw-msys
Reply | Threaded
Open this post in threaded view
|

Re: msys 1.0.13 gawk problem

Charles Wilson-8
Ralf Fassel wrote:

> In fact, it does not:
>
>     $ gawk '{printf "%g %g\n", -1, 2}'
>
>     1 -2
>
>     -1 2
>
>     1 -2
>
>     -1 2
>
> Note the alternating sign...

Hmmm...this sounds disturbingly familiar.  See this thread:
http://thread.gmane.org/gmane.comp.gnu.mingw.devel/3592

> Will try to recompile the MSYS runtime...

Try compiling (the MSYS dll) with -fno-unit-at-a-time.  I think this
might be a compiler bug in the gcc used to build the msys dll.

--
Chuck

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Mingw-msys mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mingw-msys
Reply | Threaded
Open this post in threaded view
|

Re: msys 1.0.13 gawk problem

Ralf Fassel
In reply to this post by Charles Wilson-8
* Charles Wilson
| Try compiling (the MSYS dll) with -fno-unit-at-a-time. I think this
| might be a compiler bug in the gcc used to build the msys dll.

Since setting CFLAGS in the environment did not make it into
libc/stdio/Makefile (where the printf's are), I added
-fno-unit-at-a-time manually there, and ran a recompile/reinstall:
problem gone.

Recompiled using the original Makefile:
problem reappeared.

So it seems like it really is a problem in the compiler.
How do I use -fno-unit-at-a-time everywhere?

R'

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Mingw-msys mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mingw-msys
Reply | Threaded
Open this post in threaded view
|

Re: msys 1.0.13 gawk problem

Charles Wilson-8
Ralf Fassel wrote:
> I added
> -fno-unit-at-a-time manually there, and ran a recompile/reinstall:
> problem gone.
>
> Recompiled using the original Makefile:
> problem reappeared.
>
> So it seems like it really is a problem in the compiler.
> How do I use -fno-unit-at-a-time everywhere?

I can confirm this. Compiling the MSYS dll with unit-at-a-time enables
(the default for this version of gcc at levels -O2 and -O3), and you
will see this aberrant gawk behavior.  Compile with -fno-unit-at-a-time,
and gawk behaves as expected.

Note that this is with a gawk executable that was compiled last fall,
using msys-gcc-2.95.3 and (old) msys-binutils.

In answer to your question, Ralf, you should edit the msysrlsbld.ini
file and change the two lines:

-export CFLAGS="-O3 -g"
+export CFLAGS="-O3 -g -fno-unit-at-a-time"
 export LDFLAGS='-L/usr/lib/w32api'
-export CXXFLAGS="-O3 -g"
+export CXXFLAGS="-O3 -g -fno-unit-at-a-time"
 export CPPFLAGS='-I/usr/include/w32api'

Then, use ./msysrlsbld as usual.  (I'm assuming that you are trying to
build from the -src tarball, not from CVS).

--
Chuck

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Mingw-msys mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mingw-msys
Reply | Threaded
Open this post in threaded view
|

Re: msys 1.0.13 gawk problem

Ralf Fassel
* Charles Wilson
| Note that this is with a gawk executable that was compiled last
| fall, using msys-gcc-2.95.3 and (old) msys-binutils.

I also see this behaviour with the simple C test program you posted
earlier which simply issues 4 printf's with fixed values in a row.
(gawk is just a victim here ;-)

| In answer to your question, Ralf, you should edit the msysrlsbld.ini
| file and change the two lines:

Ah, msysrlsbld.ini.  I forgot.

R'

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Mingw-msys mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mingw-msys