FAQ
Andy's linux.sh fix seems to be "too strong"

On SuSE 6.4 & 7.3 /lib/libc.so.6 is not a link so the test -L fails and
libc= is not set, which then matches the default case and disables
stdio buffer snooping.

I happen to know :stdio with snooping works fine on the two systems
in question - it was developed there!

What this means is that in RC1 as it stands many linux systems will
be giving :perlio a good hammering - which may be no bad thing!

The alternate way of finding out the version as suggested by Chip
- running /lib/libc.so.6 - would seem safer:

nick@bactrian 1024$ /lib/libc.so.6 | grep 'C Library'
GNU C Library stable release version 2.2.4, by Roland McGrath et al.
nick@bactrian 1025$

My "awk" isn't up to turning that into a patch

--
Nick Ing-Simmons
http://www.ni-s.u-net.com/

Search Discussions

  • Andy Dougherty at Jun 1, 2002 at 5:58 pm

    On Sat, 1 Jun 2002, Nick Ing-Simmons wrote:


    Andy's linux.sh fix seems to be "too strong"

    On SuSE 6.4 & 7.3 /lib/libc.so.6 is not a link so the test -L fails and
    libc= is not set, which then matches the default case and disables
    stdio buffer snooping.

    I happen to know :stdio with snooping works fine on the two systems
    in question - it was developed there!
    In my brief testing, the version without snooping actually ran very
    slightly marginally faster anyway :-), so defensively defaulting to
    it didn't bother me much.
    The alternate way of finding out the version as suggested by Chip
    - running /lib/libc.so.6 - would seem safer:

    nick@bactrian 1024$ /lib/libc.so.6 | grep 'C Library'
    GNU C Library stable release version 2.2.4, by Roland McGrath et al.
    My experience is that I don't trust the format of any free-form string
    very much at all, so I'm wary of trying too hard.

    --
    Andy Dougherty doughera@lafayette.edu
    Dept. of Physics
    Lafayette College, Easton PA 18042
  • Jarkko Hietaniemi at Jun 1, 2002 at 6:00 pm

    The alternate way of finding out the version as suggested by Chip
    - running /lib/libc.so.6 - would seem safer:

    nick@bactrian 1024$ /lib/libc.so.6 | grep 'C Library'
    GNU C Library stable release version 2.2.4, by Roland McGrath et al.
    My experience is that I don't trust the format of any free-form string
    very much at all, so I'm wary of trying too hard.
    But if the -L route fails, it's nice to have a fallback.

    --
    $jhi++; # http://www.iki.fi/jhi/
    # There is this special biologist word we use for 'stable'.
    # It is 'dead'. -- Jack Cohen
  • Andy Dougherty at Jun 3, 2002 at 5:55 pm

    On Sat, 1 Jun 2002, Jarkko Hietaniemi wrote:

    The alternate way of finding out the version as suggested by Chip
    - running /lib/libc.so.6 - would seem safer:

    nick@bactrian 1024$ /lib/libc.so.6 | grep 'C Library'
    GNU C Library stable release version 2.2.4, by Roland McGrath et al.
    My experience is that I don't trust the format of any free-form string
    very much at all, so I'm wary of trying too hard.
    But if the -L route fails, it's nice to have a fallback.
    Here's a slightly more robust approach -- it requires changes to
    d_gnulibc.U and d_stdstdio.U. This has the advantage of working anywhere
    that uses GNU libc, not just Linux. It has the disadvantage of requiring
    changes to metaconfig units. (I'm re-syncing my repository copies and
    will suggest the appropriate changes, probably tomorrow.)

    This is still a band-aid, however. Ideally, we'd like to alter the
    Configure tests so they automatically detect the issue and handle it
    appropriately.

    I'd appreciate any useful feedback from folks with various versions of
    GNU libc.

    diff -r -u perl-current/Configure perl-andy/Configure
    --- perl-current/Configure Sat Jun 1 12:37:35 2002
    +++ perl-andy/Configure Mon Jun 3 13:40:38 2002
    @@ -495,6 +495,7 @@
    d_gmtime_r=''
    gmtime_r_proto=''
    d_gnulibc=''
    +gnulibc_version=''
    d_hasmntopt=''
    d_htonl=''
    d_inetaton=''
    @@ -5303,26 +5304,43 @@

    echo " "
    echo "Checking for GNU C Library..." >&4
    -cat >try.c <<EOM
    +cat >try.c <<'EOCP'
    +/* Find out version of GNU C library. __GLIBC__ and __GLIBC_MINOR__
    + alone are insufficient to distinguish different versions, such as
    + 2.0.6 and 2.0.7. The function gnu_get_libc_version() appeared in
    + libc version 2.1.0. A. Dougherty, June 3, 2002.
    +*/
    #include <stdio.h>
    -int main()
    +int main(void)
    {
    #ifdef __GLIBC__
    - exit(0);
    +# ifdef __GLIBC_MINOR__
    +# if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
    +# include <gnu/libc-version.h>
    + printf("%s\n", gnu_get_libc_version());
    +# else
    + printf("%d.%d\n", __GLIBC__, __GLIBC_MINOR__);
    +# endif
    +# else
    + printf("%d\n", __GLIBC__);
    +# endif
    + return 0;
    #else
    - exit(1);
    + return 1;
    #endif
    }
    -EOM
    +EOCP
    set try
    -if eval $compile_ok && $run ./try; then
    +if eval $compile_ok && $run ./try > glibc.ver; then
    val="$define"
    - echo "You are using the GNU C Library"
    + gnulibc_version=`$cat glibc.ver`
    + echo "You are using the GNU C Library version $gnulibc_version"
    else
    val="$undef"
    + gnulibc_version=''
    echo "You are not using the GNU C Library"
    fi
    -$rm -f try try.*
    +$rm -f try try.* glibc.ver
    set d_gnulibc
    eval $setvar

    @@ -15358,6 +15376,26 @@
    echo "Your stdio doesn't appear very std."
    fi
    $rm -f try.c try
    +
    +# glibc 2.2.90 and above apparently change stdio streams so Perl's
    +# direct buffer manipulation no longer works. The Configure tests
    +# should be changed to correctly detect this, but until then,
    +# the following check should at least let perl compile and run.
    +# (This quick fix should be updated before 5.8.1.)
    +# To be defensive, reject all unknown versions, and all versions > 2.2.9.
    +# A. Dougherty, June 3, 2002.
    +case "$d_gnulibc" in
    +$define)
    + case "$gnulibc_version" in
    + 2.[01]*) ;;
    + 2.2) ;;
    + 2.2.[0-9]) ;;
    + *) echo "But I will not snoop inside glibc $gnulibc_version stdio buffers."
    + val="$undef"
    + ;;
    + esac
    + ;;
    +esac
    set d_stdstdio
    eval $setvar

    @@ -19801,6 +19839,7 @@
    d_gettimeod='$d_gettimeod'
    d_gmtime_r='$d_gmtime_r'
    d_gnulibc='$d_gnulibc'
    +gnulibc_version='$gnulibc_version'
    d_grpasswd='$d_grpasswd'
    d_hasmntopt='$d_hasmntopt'
    d_htonl='$d_htonl'
    diff -r -u perl-current/Porting/Glossary perl-andy/Porting/Glossary
    --- perl-current/Porting/Glossary Thu May 30 22:27:51 2002
    +++ perl-andy/Porting/Glossary Mon Jun 3 13:45:29 2002
    @@ -2537,6 +2537,11 @@
    REENTRANT_PROTO_T_ABC macros of reentr.h if d_gmtime_r
    is defined.

    +gnulibc_version (d_gnulibc.U):
    + This variable contains the version number of the GNU C library.
    + It is usually something like '2.2.5'. It is a plain '' if this
    + is not the GNU C library, or if the version is unknown.
    +
    grep (Loc.U):
    This variable is used internally by Configure to determine the
    full pathname (if any) of the grep program. After Configure runs,
    diff -r -u perl-current/hints/linux.sh perl-andy/hints/linux.sh
    --- perl-current/hints/linux.sh Thu May 30 16:56:40 2002
    +++ perl-andy/hints/linux.sh Mon Jun 3 13:40:38 2002
    @@ -48,6 +48,7 @@
    # If you have glibc, then report the version for ./myconfig bug reporting.
    # (Configure doesn't need to know the specific version since it just uses
    # gcc to load the library for all tests.)
    +# This symlink test doesn't work everywhere.
    # We don't use __GLIBC__ and __GLIBC_MINOR__ because they
    # are insufficiently precise to distinguish things like
    # libc-2.0.6 and libc-2.0.7.
    @@ -55,33 +56,6 @@
    libc=`ls -l /lib/libc.so.6 | awk '{print $NF}'`
    libc=/lib/$libc
    fi
    -
    -# glibc 2.2.90 and above apparently change stdio streams so Perl's
    -# direct buffer manipulation no longer works. The Configure tests
    -# should be changed to correctly detect this, but until then,
    -# the following check should at least let perl compile and run.
    -# (This quick fix should be updated before 5.8.1.)
    -# Since we just computed libc above, we'll use it here. A typical
    -# value looks like libc='/lib/libc-2.0.6.so'
    -# To be defensive, reject all unknown versions > 2.2.9.
    -# A. Dougherty, May. 30, 2002
    -case "$libc" in
    -*-2.[01]*) ;;
    -*-2.2.so) ;;
    -*-2.2.[0-9].*) ;;
    -*) # Honor a command-line override
    - if test -z "$d_stdstdio"; then
    - d_stdstdio="$undef"
    - cat <<'EOM' >&4
    -
    -Disabling perl's stdio buffer snooping. This will generate a harmless
    - *** WHOA THERE!!! ***
    -message in Configure. Accept the recommended value.
    -Read hints/linux.sh for further information.
    -EOM
    - fi
    - ;;
    -esac

    # Configure may fail to find lstat() since it's a static/inline
    # function in <sys/stat.h>.

    --
    Andy Dougherty doughera@lafayette.edu
    Dept. of Physics
    Lafayette College, Easton PA 18042
  • Nick Ing-Simmons at Jun 5, 2002 at 7:54 am
    Andy Dougherty writes:
    >>
    But if the -L route fails, it's nice to have a fallback.
    Here's a slightly more robust approach -- it requires changes to
    d_gnulibc.U and d_stdstdio.U. This has the advantage of working anywhere
    that uses GNU libc, not just Linux. It has the disadvantage of requiring
    changes to metaconfig units. (I'm re-syncing my repository copies and
    will suggest the appropriate changes, probably tomorrow.)

    This is still a band-aid, however. Ideally, we'd like to alter the
    Configure tests so they automatically detect the issue and handle it
    appropriately.
    I don't think the issue is too hard to detect automatically, but is
    a bit messy.

    In the test program that checks FILE_ptr for sanity we need to
    set a SEGV handler, open a regular file and try:

    ch = fgetc(f);
    ptr = FILE_ptr(f);
    *--ptr = c;

    If we get a SEGV we don't set STDIO_BUF_WRITABLE
    I'd appreciate any useful feedback from folks with various versions of
    GNU libc.
    Will do.

    --
    Nick Ing-Simmons
    http://www.ni-s.u-net.com/
  • Jarkko Hietaniemi at Jun 5, 2002 at 2:05 pm

    I'd appreciate any useful feedback from folks with various versions of
    GNU libc.
    Will do.
    Please note that it took me until #17007 or so to get Andy's patch
    applied in its fullness...
    --
    Nick Ing-Simmons
    http://www.ni-s.u-net.com/
    --
    $jhi++; # http://www.iki.fi/jhi/
    # There is this special biologist word we use for 'stable'.
    # It is 'dead'. -- Jack Cohen
  • Nick Ing-Simmons at Jun 5, 2002 at 3:42 pm

    Jarkko Hietaniemi writes:
    I'd appreciate any useful feedback from folks with various versions of
    GNU libc.
    Will do.
    Please note that it took me until #17007 or so to get Andy's patch
    applied in its fullness...
    This SuSE7.3 laptop is reported as having
    gnulibc_version='2.2.4'
    which agrees with running /lib/libc.so.6

    :stdio is chosen again

    --
    Nick Ing-Simmons
    http://www.ni-s.u-net.com/
  • Nick Ing-Simmons at Jun 3, 2002 at 2:24 am

    Andy Dougherty writes:
    On Sat, 1 Jun 2002, Nick Ing-Simmons wrote:


    Andy's linux.sh fix seems to be "too strong"

    On SuSE 6.4 & 7.3 /lib/libc.so.6 is not a link so the test -L fails and
    libc= is not set, which then matches the default case and disables
    stdio buffer snooping.

    I happen to know :stdio with snooping works fine on the two systems
    in question - it was developed there!
    In my brief testing, the version without snooping actually ran very
    slightly marginally faster anyway :-), so defensively defaulting to
    it didn't bother me much.
    It does not bother me that much either - only place it is likely
    to matter is XS code which is wants FILE * - :stdio layer is needed
    then.

    Good to know :perlio is faster O:-)
    nick@bactrian 1024$ /lib/libc.so.6 | grep 'C Library'
    GNU C Library stable release version 2.2.4, by Roland McGrath et al.
    My experience is that I don't trust the format of any free-form string
    very much at all, so I'm wary of trying too hard.
    Understood.

    --
    Nick Ing-Simmons
    http://www.ni-s.u-net.com/
  • Nicholas Clark at Jun 3, 2002 at 9:50 am

    On Sat, Jun 01, 2002 at 02:00:25PM -0400, Andy Dougherty wrote:
    In my brief testing, the version without snooping actually ran very
    slightly marginally faster anyway :-), so defensively defaulting to
    it didn't bother me much.
    IIRC when the buffer snooping probes were updated to look for *BSD and glibc
    was before full perlio was written. At that time perlbench reported massive
    (600%) speedup on one test for glibc with the snooping, making it on average
    a percentage or so faster (ie within noise, so don't read much into that)

    FreeBSD slowed a slight slowdown on that same test, but was roughly unchanged
    on average. It would not surprised me if FreeBSD's stdio is sufficiently
    carefully written that we can't win by cheating it.

    (I think none of perlbench's tests change $/ from "\n". We may skew stats
    in the favour of buffer snooping by having tests with $/ set to something
    else. We might as well write tests which want $/ as a regexp, to make awk
    look better. Do we get $/ as a regexp on perl6?)

    Nicholas Clark
    --
    Even better than the real thing: http://nms-cgi.sourceforge.net/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-porters @
categoriesperl
postedJun 1, '02 at 10:24a
activeJun 5, '02 at 3:42p
posts9
users5
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase