Here's more background info:

- On a Redhat 7.2 box, install the ghc-5.04.1 RPM
- do the following:

rh7.2$ cat M.hs
module M where { import System; main = system "uname" >>= print }
rh7.2$ ghc -o m M.hs
rh7.2$ ./m
ExitFailure 127

You can also reproduce this using just C code by compiling
up the attached invoke.c file on a RedHat 7.3 box, and
then linking it together with this little test stub on a RH7.2
box:

rh7.3$ gcc --version
2.96
rh7.3$ gcc -O -c invoke.c

-----------------------------------

rh7.2$ gcc --version
2.96
rh7.2$ gcc -o main main.c invoke.o
rh7.2$ ./main
127
rh7.2$ 

Peering at the generated binaries and assembly output, it
appears as if BFD (=> assembler/linker) has changed
the code it emits to refer to strings in the read-only
data section. 

Fascinating though that is, avoiding mixing code built on
these two 'platforms' is probably the only valuable piece
of info to take away from all this.

May I suggest the GHC downloads page drops the claim
that the 5.04.1 RPMs will work under RH7.2?

--sigbjorn

----- Original Message ----- 
From: "Sigbjorn Finne" <[EMAIL PROTECTED]>
To: "Saswat Anand" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, September 26, 2002 08:52
Subject: Re: Newbie building GHC


> Hi there,
> 
> we've been running into similar problems here on a Redhat 7.2
> box using the ghc-5.04.1 RPM (which was built on RedHat 7.3).
> The salient line from your strace output is the following one:
> 
> [pid  1514] execve("n/sh", ["/bin/sh", "-c", "gcc Adjustor.c
> -o /tmp/ghc1513.s"...], [/* 36 vars */])
>   = -1 ENOENT (No such file or directory)
> 
> execl() (called by System.system) is somehow causing execve()
> to be invoked with a stripped off command arg.
> 
> The cause of this suspected outbreak of Linux versionitis is as yet
> unknown (gcc? glibc?..), but you may want to try installing the
> .tar.bz2 instead (which was built on a RH 7.2 box.) That worked
> around the problem here, at least.
> 
> hth
> --sigbjorn
> 

#include <unistd.h>
#include <sys/wait.h>
#include <errno.h>
#include <stdio.h>

int 
invokeCmd(char* cmd)
{
    int pid;
    int wstat;

    switch(pid = fork()) {
    case -1:
        if (errno != EINTR) {
            return -1;
        }
    case 0:
      {
        /* the child */
        execl("/bin/sh", "sh", "-c", cmd, NULL);
        _exit(127);
      }
    }

    while (waitpid(pid, &wstat, 0) < 0) {
        if (errno != EINTR) {
            return -1;
        }
    }

    if (WIFEXITED(wstat))
        return WEXITSTATUS(wstat);
    else if (WIFSIGNALED(wstat)) {
        errno = EINTR;
    }
    else {
        /* This should never happen */
    }
    return -1;

}

Reply via email to