[comp.sys.amiga.programmer] Which C-compiler can create true libraries?

micja@IDA.LiU.SE (Michael Jansson) (01/10/91)

I would really appreciate to hear from people who has actually used a
c-compiler/linker to create a normal run-time library of the kind that can
be found in the LIBS: directory.

I am only interested in hearing about compiler/linker that you have used
develop big libraries without any use of library tools.


If you have:
*  information about specification for compiler/linker that says that
   they can create libraries.
*  managed to re-compile a PD-library with a compiler.
Then don't bother telling me about it! I need REAL LIFE EXPERIENCES from
developing libraries that tells me that I REALLY can rely on a compiler to
generate correct code!

I'm currently using Manx 5.0a which I managed to force into creating a
correct library.  Version 5.0d is a dead-end, even though it generates
very nice code for ordinary programs.

I have read that SAS (former Lattice) is supposed to be able to generate
libraries also. Will it do that? Really? What about DICE, GCC, etc?


Please help a frustrated man...


--
##########################################################
#   Michael Jansson             |   \_/
#   Internet: mij@IDA.LIU.SE    |    V                   _|_
#   UUCP: uunet!liuida!mij      |    |    Absolut Software|
#   BITNET: mij@SELIUIDA        |   ~~~  

swalton@solaria.csun.edu (Stephen Walton) (01/11/91)

In article <1991Jan10.130040.13771@ida.liu.se>, micja@IDA (Michael
Jansson) writes:

>I'm currently using Manx 5.0a which I managed to force into creating a
>correct library.  Version 5.0d is a dead-end, even though it generates
>very nice code for ordinary programs.

I'm not sure what Michael means by "force."  It seems a well-kept
secret that the Manx 5.0a distribution has a complete example of a
resident library in the res_lib directory of disk 4.  All one needs to
do to produce one's own library is write the library functions,
#pragmas for them (easy) and list them in a table in the file called
libsup.c in that directory.

Manx 5.0d has, unfortunately, a couple of new bugs having to do with
library code generation.  To work around them:

1.  Add a dummy argument (I used int x) to the three routines in
libsup.c (myOpen, myClose, myExpunge).

2.  Do not optimize the actual library entry points, though
lower-level routines can be optimized fine.
-------------------------------
Stephen Walton, Dept. of Physics & Astronomy, Cal State Univ. Northridge
   I am srw@csun.edu no matter WHAT the stupid From: line says!

micja@IDA.LiU.SE (Michael Jansson) (01/11/91)

In article <1991Jan11.003038.17471@csun.edu> swalton@solaria.csun.edu (Stephen Walton) writes:

[stuff deleted]

>Manx 5.0d has, unfortunately, a couple of new bugs having to do with
>library code generation.  To work around them:
>
>1.  Add a dummy argument (I used int x) to the three routines in
>libsup.c (myOpen, myClose, myExpunge).
>
>2.  Do not optimize the actual library entry points, though
>lower-level routines can be optimized fine.
>-------------------------------
>Stephen Walton, Dept. of Physics & Astronomy, Cal State Univ. Northridge
>   I am srw@csun.edu no matter WHAT the stupid From: line says!


It is just typical that I get this information now when I just discovered
how to use 5.0d last night. Big sigh ;-(. Big thanks to you for the help
anyway!

Further comments on the bugs:

1. This point is valid for not only the three common functions.  Any
function that is compiled which is also #pragma:ed with zero registers as
parameters will result in bad code! (There is a mismatch on the number of
parameters that are pushed/poped on the stack). The solution is to add a
dummy register to all the #pragma:s that don't have any. You don't need
to actually add the dummy parameters to the function.

2. All functions can be optimized if they contains a "geta4()" as the
first line in the function.  (The optimizer seems to be a bit confused
about the use of a4!?) I guess this bug is related to point 1.


I took the res_lib example and made the following changes to make it work:
* Add a geta4() call as the first line in each function.
* Changed the optimizer flag -so to -safmrs (every optimizer switch except
  -sn)
* Added -bs so that I could debug the library with sdb
* Added a dummy 'd0' to all the #pragmas in libsup.c that have zero registers.

It now works very well!


--
##########################################################
#   Michael Jansson             |   \_/
#   Internet: mij@IDA.LIU.SE    |    V                   _|_
#   UUCP: uunet!liuida!mij      |    |    Absolut Software|
#   BITNET: mij@SELIUIDA        |   ~~~