Menu

porting to OpenBSD 7.4 ARM

2024-02-04
2024-02-18
  • Tito Mari Francis Escano

    I was able to build the bootstrap compiler, however when I was building the compiler itself, it complained not finding yacc.h as seen from the attached screenshot.
    It seems to be looking for yacc.h file which doesn't seem to exist in OpenBSD 7.4 even if I already installed the default development tools and libraries of the platform.
    Can this dependency be removed during building of the compiler itself? Or are there workarounds to this?
    Please advise.
    Thank s.

     
  • David Stes

    David Stes - 2024-02-10

    OpenBSD is an excellent UNIX distribution so hopefully I can help to get the Portable Object Compiler ported to OpenBSD 7.4 ARM.
    From looking at the screenshots, I think you correctly configured the boostrap compiler with

    configure --prefix=/opt/objc-bootstrap
    

    That is correct and well done so that the bootstrtap compiler was installed in /opt/objc-bootstrap.
    The next step is to build the real compiler and there you should use a different prefix.
    For the real compiler you can use something like:

    configure --prefix=/usr/local
    

    The file yacc.h is a copy of the file y.tab.h which is automatically generated by yacc.
    As explained in https://man.openbsd.org/yacc
    there is an option : The -d option causes the header file y.tab.h to be written.
    So the -d option is essential for Portable Object Compiler because it creates y.tab.h which is then copied by the Makefile to yacc.h.
    So I suspect that you configured with YACC=yacc instead of YACC='yacc -d'

    make clean
    configure --prefix=/usr/local YACC='yacc -d'
    

    Can you start again (after running make clean or after starting from a new set of extracted sources), and try it please with the -d option ?
    Note that the default configure script sets YACC='byacc -d' because some Linux distributions have a package called byacc (for BSD yacc). In the case of OpenBSD yacc is BSD yacc. Some Linux distributions have used bison as yacc although I prefer BSD yacc on all platforms, on some AT&T platforms the regular yacc developed by Stephen C. Johnson also works fine, in fact the BSD yacc is a clone by Keith Bostic Robert Corbett and many other developers.

     
  • David Stes

    David Stes - 2024-02-18

    I hope that my answer helped and that you were able to compile Portable Object Compiler on OpenBSD for ARM. Before installing you optionally can run tests with :

    gmake test
    

    This should print something like :

    Portable Object Compiler 3.3.39 (c) 1997-2023.
    Distributed under the terms of the GNU LGPL.
    /usr/bin/objc  objut.o -noLibs ../oclib/oclib.a ../objpak/objpak.a ../objcrt/objcrt.a -o objut
    ./objut
    Object
    ...
        Message
        Block
    
    Object Unit Test: number of classes is 105
    
    Object Unit Test: success
    

    Note that in the above I used the compiler version 3.3.39 to compile the compiler with itself. I install the new compiler and recompile the compiler with the new compiler, the running the test prints :

    Portable Object Compiler 3.3.42 (c) 1997-2024.
    Distributed under the terms of the GNU LGPL.
    /tmp/bin/objc  objut.o -noLibs ../oclib/oclib.a ../objpak/objpak.a ../objcrt/objcrt.a -o objut
    ./objut
    Object
    ...
        Block
    
    Object Unit Test: number of classes is 105
    
    Object Unit Test: success
    

    I'll add additional tests to Object Unit Test in future releases.

    The point here is that you rebuild the compiler with itself, so if you make a mistake you can end up with a non-working compiler and then you have to use the bootstrap compiler again which you installed in /opt/objc-bootstrap.

    So I recommend certainly to install the real compiler in a different location than the bootstrap compiler but I think that is what you already did.

    The bootstrap compiler is not required for anything at all except for starting the initial build on a new platform, for most upgrades it is sufficient to just compile the real compiler with itself.

    Regarding Berkeley YACC, the manpage of yacc at OpenBSD has some interesting pointers:

    https://man.openbsd.org/yacc

    yacc was originally developed at AT&T by Stephen C. Johnson.

    Berkeley yacc was based on
    F. DeRemer and T. J. Pennello, Efficient Computation of LALR(1) Look-Ahead Sets, TOPLAS, Issue 4, Volume 4, pp. 615–649, 1982.

    Based on wikipedia and OpenBSD manpage I think Berkeley yacc is written or was written by Robert Corbett and is maintained by Thomas Dickey now.

    The wikipedia page on byacc mentions Thomas Dickey as maintainer
    https://en.wikipedia.org/wiki/Berkeley_Yacc

    The current version of that branch or version of byacc is 20240109 ( 9 January 2024)

    I didn't test that latest byacc version so far but I'm always interested to hear which version of flex; byacc or which C compiler is used, because Portable Object Compiler is independent of C compiler (it works with any C compiler) and it also works with AT&T lex and yacc.

    In practice Portable Object Compiler succesfully builds with AT&T lex and yacc but I recommend flex and Berkeley yacc.

    For AT&T yacc I can confirm that Portable Object Compiler builds fine with AT&T yacc of Illumos :

    https://illumos.org/man/1/yacc

    With illumos yacc which is a branch of AT&T yacc it works fine.

    In some cases other tools can also be used such as GNU bison, with bison it depends a lot on the release of bison and bison is in my experience fine in some cases but sometimes bison has problems.

    Also MKS yacc (myacc) was succesful.

    https://en.wikipedia.org/wiki/Yacc

    for some information on yacc.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.