Building a “real” Project on vamos running SAS C

In the last post I showed you that vamos is already able to call the SAS C Compiler 6.58 and compile some example source files. In the last few days I added the missing parts to vamos to support smake, too. Namely, calling sub processes with SystemTagList() was added and lots of bugs fixed. With smake at hand I am able to compile some real SAS C projects with an smakefile describing the build.

In this post I will show you how you can build the magPLIP network driver I used in my plip2slip project directly on your Mac without using an Amiga machine emulator like P-UAE…

1. Setup Build Environment

  • I assume that you have installed the SAS C compiler ready to use for vamos as described in my last post
  • The netword driver we will compile needs the Amiga Network Driver Includes (i.e. SANA-II headers)
    • Download the AmiTCP-SDK-4.3.lha from aminet
    • You can unpack it on your Mac with the lha command available in MacPorts (call: sudo port install lha if the tool is still missing on your machine):
  • > cd ~/amiga/src
    > lha x ~/Downloads/AmiTCP-SDK-4.3.lha
  • Now we need to setup assigns in vamos so the build can reach the new network includes. My ~/.vamosrc config file looks like this:
[volumes]
wb310=~/amiga/wb310
sc=~/amiga/shared/sc
net=~/amiga/src/AmiTCP-SDK-4.3

[assigns]
include=sc:include
lib=sc:lib
t=root:tmp
c=wb310:c
netinclude=net:netinclude
netlib=net:netlib
includeasm=sc:include

[path]
path=sc:c,wb310:c

[vamos]
quiet=True
ram_size=2048

What’s new here?

  • First I added a new volume in vamos called net: where the SANA-II includes reside. It points to the native path we just unpacked.
  • Some new assigns were added: netinclude and netlib point inside our new net: volume
  • Another assign called includeasm: was necessary as the following build requires it. It simply points directly to the include directory in the SAS C installation.
  • Finally, a new section called vamos was introduced. This section holds defaults for common option that were currently only available via command line:
    • The quiet switch is similar to the -q command line option and suppresses information about un-implemented Amiga OS calls in vamos
    • The ram_size sets the RAM for the AmigaOS emulation of vamos to 2 MiB. Similar to the -m command line option. This ensures that we do not run out of memory during compilation.

2. Grab the Source

  • Next we download the source for magPLIP from aminet
  • I unpacked the source in a build directory:
> mkdir ~/build
> cd build
> lha x ~/magPLIP38.1.lha
> ls
magplip/      magplip.info
  • I also downloaded the plip2slip-0.1 source archive because it contains a patch for the driver we are going to build
  • Unpack this, too:
> unzip ~/Downloads/plip2slip-0.1.zip
> ls
magplip/       magplip.info   plip2slip-0.1/
  • Next, we patch the source:
> patch -p0 < plip2slip-0.1/contrib/magplip/magplip.patch 
patching file magplip/source/magplip_rev.h
patching file magplip/source/magplip_rev.i
patching file magplip/source/magport.asm
patching file magplip/source/server.c
patching file magplip/source/smakefile
  • That’s it, now the source is ready to be compiled!

3. Perform the Build

  • The build itself is now rather unspectacular… It simply works 🙂
> cd magplip/source
> vamos smake all_opt
SAS/C_SMAKE 6.58 (27.12.96)
Copyright (c) 1988-1995 SAS Institute, Inc.
 sc:c/sc INCDIR="INCLUDEASM:" INCDIR="include:" INCDIR="netinclude:" VERBOSE DEFINE MAGPLIP=1 OBJECTNAME MAGrt.o rt.asm
No default scoptions file found
SAS/C Amiga Compiler 6.58
Copyright (c) 1988-1995 SAS Institute Inc.

asm "-dMAGPLIP=1" -iINCLUDEASM: -iinclude: -inetinclude: -oMAGrt.o rt.asm
...

SLINK Complete - Maximum code size = 8824 ($00002278) bytes

Final output file size = 8940 ($000022ec) bytes
  • If everything went fine then the resulting binary resides in the magplip/devs/networks folder:
> ls ../devs/networks/magplip.device.000
-rwxr-xr-x  1 chris  staff  8940 18 Dez 18:16 ../devs/networks/magplip.device.000*
  • Ah! A fresh build of the driver… Now let’s create a 68020 version, too:
> vamos smake CPUSUFFIX=020 all_opt
...
> ls ../devs/networks/magplip.device.020
-rwxr-xr-x  1 chris  staff  8872 18 Dez 18:21 ../devs/networks/magplip.device.020*
  • Finally, you can compare your new builds with the reference compiles I did on P-UAE and that are available in the plip2slip release:
> cmp ../devs/networks/magplip.device.000 ../../plip2slip-0.1/contrib/magplip/magplip.device.000
> cmp ../devs/networks/magplip.device.020 ../../plip2slip-0.1/contrib/magplip/magplip.device.020
  • It really works! Same output generated on vamos!!
  • Now its time to read the plip2slip docs on how to actually use the driver on your real machine…

4. Some additional Notes

  • While vamos now supports the typical builds on SAS C even with smakefiles, there are still things missing. Most notably, the internal Shell commands like Echo are not emulated yet. So the default/help rule in our project’s smakefile does not work. But the internal Shell commands and a more complete support for the typical CLI commands will be the next on my TODO list…
  • Compared to last vamos versions I optimized the loading of native libraries (most notably sc1.library and sc2.library of sc) and that gave a real speed boost when calling the compiler.
  • To better judge where the bottlenecks in the vamos emulation are, I added profiling support for the library calls. You can use the new -P switch and give the libraries you want to get detailed information for:
> vamos smake clean # first clean our build again
...
> vamos -v -P exec,dos smake all_opt # now build with profiling on
...
18:34:09.103       prof:   INFO:  'dos.library' Function Call Profile
18:34:09.103       prof:   INFO:                   Close: #     251  total=    0.0115  per call=    0.0000
18:34:09.103       prof:   INFO:              CurrentDir: #      45  total=    0.0009  per call=    0.0000
18:34:09.103       prof:   INFO:               DateStamp: #       9  total=    0.0005  per call=    0.0001
18:34:09.103       prof:   INFO:              DeleteFile: #      12  total=    0.0033  per call=    0.0003
18:34:09.103       prof:   INFO:                 DupLock: #       3  total=    0.0003  per call=    0.0001
18:34:09.103       prof:   INFO:                 Examine: #      85  total=    0.0158  per call=    0.0002
18:34:09.104       prof:   INFO:                FilePart: #       3  total=    0.0002  per call=    0.0001
18:34:09.104       prof:   INFO:                FreeArgs: #       6  total=    0.0017  per call=    0.0003
18:34:09.104       prof:   INFO:          FreeDeviceProc: #       3  total=    0.0005  per call=    0.0002
18:34:09.104       prof:   INFO:           GetDeviceProc: #       3  total=    0.0008  per call=    0.0003
18:34:09.104       prof:   INFO:                   Input: #      20  total=    0.0001  per call=    0.0000
18:34:09.104       prof:   INFO:                   IoErr: #      94  total=    0.0006  per call=    0.0000
18:34:09.104       prof:   INFO:                    Lock: #      77  total=    0.0163  per call=    0.0002
18:34:09.104       prof:   INFO:                MatchEnd: #       6  total=    0.0019  per call=    0.0003
18:34:09.104       prof:   INFO:              MatchFirst: #       6  total=    0.0055  per call=    0.0009
18:34:09.104       prof:   INFO:               MatchNext: #       6  total=    0.0002  per call=    0.0000
18:34:09.104       prof:   INFO:                    Open: #     352  total=    0.0850  per call=    0.0002
18:34:09.104       prof:   INFO:                  Output: #      37  total=    0.0003  per call=    0.0000
18:34:09.104       prof:   INFO:               ParentDir: #      62  total=    0.0061  per call=    0.0001
18:34:09.104       prof:   INFO:            ParsePattern: #       3  total=    0.0006  per call=    0.0002
18:34:09.104       prof:   INFO:                  PutStr: #       9  total=    0.0005  per call=    0.0001
18:34:09.104       prof:   INFO:                    Read: #     617  total=    0.0273  per call=    0.0000
18:34:09.105       prof:   INFO:                ReadArgs: #       6  total=    0.0038  per call=    0.0006
18:34:09.105       prof:   INFO:                  Rename: #       3  total=    0.0013  per call=    0.0004
18:34:09.105       prof:   INFO:                    Seek: #     155  total=    0.0048  per call=    0.0000
18:34:09.105       prof:   INFO:                SetIoErr: #       3  total=    0.0000  per call=    0.0000
18:34:09.105       prof:   INFO:           SetProtection: #       4  total=    0.0009  per call=    0.0002
18:34:09.105       prof:   INFO:           SystemTagList: #      16  total=    0.0486  per call=    0.0030
18:34:09.105       prof:   INFO:                  UnLock: #     108  total=    0.0026  per call=    0.0000
18:34:09.105       prof:   INFO:                   Write: #     277  total=    0.0152  per call=    0.0001
18:34:09.105       prof:   INFO:  sum total=0.2570
18:34:09.105       main:   INFO:  done 3218549052 cycles in host time 14.9556s -> 174.60 MHz m68k CPU
18:34:09.106       main:   INFO:  code time 14.9556s (81.13 %), trap time 3.4781s (18.87 %) -> total time 18.4337s
18:34:09.106       main:   INFO:  exit code=0
18:34:09.107       prof:   INFO:  'exec.library' Function Call Profile
18:34:09.107       prof:   INFO:                AllocMem: #    1266  total=    0.1440  per call=    0.0001
18:34:09.107       prof:   INFO:                AllocVec: #      39  total=    0.0024  per call=    0.0001
18:34:09.107       prof:   INFO:            CloseLibrary: #      85  total=    0.0129  per call=    0.0002
18:34:09.107       prof:   INFO:                FindTask: #     137  total=    0.0024  per call=    0.0000
18:34:09.107       prof:   INFO:                  Forbid: #     137  total=    0.0004  per call=    0.0000
18:34:09.107       prof:   INFO:                 FreeMem: #    1318  total=    0.4038  per call=    0.0003
18:34:09.107       prof:   INFO:                 FreeVec: #      39  total=    0.0059  per call=    0.0002
18:34:09.107       prof:   INFO:                  GetMsg: #     650  total=    0.0082  per call=    0.0000
18:34:09.107       prof:   INFO:             OpenLibrary: #      85  total=    0.1304  per call=    0.0015
18:34:09.107       prof:   INFO:                  Permit: #     137  total=    0.0004  per call=    0.0000
18:34:09.107       prof:   INFO:                  PutMsg: #     650  total=    0.0794  per call=    0.0001
18:34:09.108       prof:   INFO:                RawDoFmt: #      11  total=    0.0006  per call=    0.0001
18:34:09.108       prof:   INFO:               SetSignal: #  103942  total=    0.9651  per call=    0.0000
18:34:09.108       prof:   INFO:               StackSwap: #      34  total=    0.0030  per call=    0.0001
18:34:09.108       prof:   INFO:  sum total=1.7587
  • That’s it for today! Enjoy vamos and if you already use it for doing your own “cross”-compiles then I’d really like to hear from your projects…

2 thoughts on “Building a “real” Project on vamos running SAS C

Leave a Reply