Re: HLA, Flex, and Bison

From: T.M. Sommers (tms2_at_mail.ptd.net)
Date: 10/15/03


Date: Wed, 15 Oct 2003 05:34:56 GMT

Randall Hyde wrote:
> "T.M. Sommers" <tms2@mail.ptd.net> wrote in message news:jjMib.1001$_i.93454@nnrp1.ptd.net...
>
>>I don't know what you meant about the inability to support separate
>>compilation. You can certainly call external functions from within a
>>yacc production.
>
> Yes, you can call external C code (which the HLA Bison file does a lot of),
> but you can compile productions separately and link those together (i.e.,
> separate compilation of Bison files).

But the productions can consist of mostly external code:

foo: whatever { do_foo($1); }

>>I've finally installed the newest bison (had to upgrade the os first),
>>and managed to compile the program natively on FreeBSD with only two
>>small changes to hlaparse.bsn:
>>
>>1) comment out the definition of __STDC__ on line 612; and
>>2) add #include <sys/types.h> before #include <sys/timeb.h> on line 31.
>>
>>I have not tested it, because the libraries will have to be fixed
>>first, and that looks like a big job.
>
> Yep. That's a very big job.

I'll see if I can't generate the syscall functions automatically.
FreeBSD does that for the C library, so it should be possible here.
In fact, FreeBSD does the same for its Linux compatibility mode, so it
should be possible to generate the Linux library automatically, too.
Does Linux do the same thing?

Looking at the libraries, it looks like, except for the syscalls, the
Linux versions are more generic than just Linux; they should work for
any Unix. How about making it so that when you define os.linux, it
also defines os.unix. That way common code won't have to be duplicated.

Also, regarding the console library, the Linux version assumes the tty
works in a particular way. While that will be true most of the time,
it won't always be true. Using termcap/terminfo would require linking
to a C library, but it would be more portable.

> Also, there are a *few* OS-specific sections of code in the compiler
> itself. I suspect, however, that much of the Linux-specific code may
> actually work for BSD. I'd do a grep for "Linux" throughout the source
> tree, just to be on the safe side.

I did compile with -DLinux, but didn't look at the code. Now I've
looked.

It seems like most of the Linux dependencies in output.c are really
gas dependencies, so maybe they can be handled that way. Near line
8305 is a real dependency (for calling exit), which will need new code
for FreeBSD.

In hlaparse.bsn, near line 76593, there is the same deal involving exit.

In the other files the dependencies are benign. Some, I think, can
even be eliminated with a little fiddling. Also, FreeBSD has
strcasecmp, which can replace stricmp.

>>The makefile is a bit of a mess right now, but I could clean it up and
>>send it to you if you want.
>
> Sounds good.

Okay, I'll clean it up and send it to you. I'll also send some diffs
for the above issues.

Also, while browsing in the library code I came across this near line
1226 of linux.hhf:

     #if( !@defined( nogroup ))
         ngroup := -1;
     #endif

which looks suspsicious. Should the ngroup be a nogroup?



Relevant Pages

  • Re: Confessions of a Linux Wannabe
    ... wouldn't be able to tell you if it is using Linux or FreeBSD. ... As for software installation: FreeBSD has a package management system ... download/build dependencies if applicable, configure and compile the ...
    (comp.os.linux.misc)
  • Re: Problem compiling cgi on 4.10 Release
    ... > won't run or compile on FreeBSD 4.10 Release? ... In the worst case I need one snippet of code for FreeBSD and a different ... snippet for Linux. ...
    (comp.unix.bsd.freebsd.misc)
  • Re: QUESTION: binaries on linux
    ... I need to find a way to release executable software on LINUX. ... > run on RH9 and vice versa. ... ofcourse if you use other libraries which have been upgraded and so ... Certanly, compile it on an older machine, e.g. RH 8.0. ...
    (alt.os.linux.redhat)
  • Re: Initial list of ports that fail due to -pthread
    ... > If FreeBSD wants to take the simple approach and only support ... > libraries, but I grow weary. ... for it shouldn't be used in compile command lines) ... work has to be done by a FreeBSD user is when they want to link a non-ported ...
    (freebsd-current)
  • Re: Cross-compiling/porting to linux
    ... Michael> FreeBSD binary or library and outputs a linux one? ... If Linux supported the FreeBSD system call interface, ... libraries, just as we do with Linux binaries on FreeBSD today (or ...
    (comp.unix.bsd.freebsd.misc)