[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Jun 28 00:31:33 2003 
Subject:'errno' problem for poplog in redhat 9 
From:Aaron Sloman 
Volume-ID:1030628.02 


Given the problems that have been reported I thought I should
investigate poplog on redhat 9 myself.

I think I've reached the point where I need help from an
experienced C programmer.

On Thursday night I took the plunge and upgraded my laptop
from RH8 to RH 9. It was all very smooth except that (a) I
can't get mplayer to work now and (b) although I can run a
version of poplog that was linked on RH8 I cannot relink
on RH 9, and whenever I run it I get this irritating warning
message as others have reported:

    Incorrectly built binary which accesses errno, h_errno or _res
    directly.
    Needs to be fixed

It is clear that this has nothing to do with Ved, or X because the
same warning message is produced by running the 'minimal' corepop,
used for system building.

Also it is not a problem in the external C bits of poplog because
running
    $usepop/pop/extern/lib/mklibpop

produces no warnings or errors.


Attempting to rebuild corepop using
    pglink -safe

fails with the usual warning followed by error messages about errno:

Incorrectly built binary which accesses errno, h_errno or _res directly. Needs to be fixed.
/usr/local/poplog/v15.53/pop/obj/src.olb(devio.o)(.text+0xbc0): In function `x.L3C':
: undefined reference to `errno'
 /usr/local/poplog/v15.53/pop/obj/src.olb(devio.o)(.text+0xcd7): In function `x.L3C':
: undefined reference to `errno'
 /usr/local/poplog/v15.53/pop/obj/src.olb(devio.o)(.text+0xd7e): In function `xc.Sys.Io.Sync_or_close':
: undefined reference to `errno'
 /usr/local/poplog/v15.53/pop/obj/src.olb(devio.o)(.text+0xd97): In function `xc.Sys.Io.Sync_or_close':
: undefined reference to `errno'
 /usr/local/poplog/v15.53/pop/obj/src.olb(devio.o)(.text+0xda0): In function `xc.Sys.Io.Sync_or_close':
: undefined reference to `errno'
/usr/local/poplog/v15.53/pop/obj/src.olb(devio.o)(.text+0xda9): more undefined references to `errno' follow
collect2: ld returned 1 exit status

So it looks as if the problem likes in $popsrc/devio.p

I also did some research on google and found that poplog is not the only system
that has problems because of 'errno' no longer being defined.
E.g. it's discussed here:
    http://article.gmane.org/gmane.mail.qmail.general/13960

    Recent versions of the GNU C library (glibc), as well as
    other C libraries, will not work with qmail.  Here's an
    explanation and a patch.

    The explanation is simple:  'errno' is not required nor
    guaranteed to be an int, only a modfifiable lvalue.  Many
    modern *nixes define it to be an expression involving a
    function call in order to be threadsafe. The <errno.h>
    header will do it all for you.

    Most *nixes also have some kind of backwards compatibility
    for the annoying historical practice of writing "extern
    int errno;" rather than including the header.  The most
    recent version of glibc removed that compatability. (C was
    standardized in 1989, you'd think 14 years would be enough
    time to catch up.)

and later on:
    The patch is equally simple:  let the system set up errno
    the way it wants to, rather than assuming an int.  ...

So I have to find a place to declare errno (probably as an int)
and make sure that that is included when poplog is linked.

I wondered if it would suffice to put that in
    $popexternlib/c_core.h

I then looked at saw that it was already defined there:
   #ifdef UNIX
   /*
    *  Save errno during signal handling (not done by default)
    */
   #include <errno.h>
   extern int errno;   /* for systems which don't define it in <errno.h> */
    ....

So maybe we need to have another archive that can be linked in before

    /usr/local/poplog/v15.53a/pop/obj/src.olb

in the file
    $popsys/poplink_cmnd

If someone produces some C code that declares the global
variable errno (and initialises it e.g. to 1 or 0) which I
can use to create (with ar) a static library liberrno.a
then I guess I can edit poplink_cmnd to link it before
src.olb That may stop devio.p causing problems at link
time.


I am hoping that will allow the re-linking to complete, and
then the warning message about errno will go away...

My attempts to write C by guessing failed to achieve anything.

But maybe I just don't understand the linux/unix linking process.

Aaron
====
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A.Sloman AT cs.bham.ac.uk   (ReadATas@please !)
PAPERS: http://www.cs.bham.ac.uk/research/cogaff/ (And free book on Philosophy of AI)
FREE TOOLS: http://www.cs.bham.ac.uk/research/poplog/freepoplog.html