adtools / amigaos-cross-toolchain

AmigaOS cross compiler for Linux / MacOSX / Windows
184 stars 48 forks source link

stdio functions from libnix not usable on Kickstart 1.3 #52

Closed saldali closed 8 years ago

saldali commented 8 years ago

I wish to write a program for my real Amiga 500 with kickstart 1.3 using the toolchain. My program needs 'printf' and 'sprintf'.

Tried hello.c from the examples directory; the A500 complained about a missing library version 37 and nothing got printed on screen.

hello-ks13.c worked fine, got the hello world string.

If I take hello-ks13.c and include stdio.h and try to sprintf something somewhere in my program, the A500 crashes badly with: Software error task held, Finnish ALL disk activity etc… Tried this with -noixemul -noixemul -lnix13 -noixemul -fbaserel -m68000 -msmall-code -lnix13

cahirwpz commented 8 years ago

If I compile with -lnix13 following example:

#include <proto/exec.h>
#include <proto/dos.h>
#include <stdio.h>

int __nocommandline = 1;
int __oslibversion = 34; /* another not so well documented feature of libnix */

int main() {
  char str[100];

  sprintf(str, "foobar: %lx", (LONG)SysBase);

  Write(Output(), str, strlen(str));

  return 0;
}

... and run it I get an intuition message that utility.library is not present. Which is expected as it was introduced in Kickstart 2.0.

After short investigation of compiled binary I found out that several functions from libnix13 that should be compiled in, are actually not there. Although this behaviour is not desired I learned it's correct. Fixing that won't be trivial, but is doable.

cahirwpz commented 8 years ago

Please try out toolchain from new branch ks13_fix. Following program works ok on A500:

#include <stdio.h>

int __nocommandline = 1; /* turn off command line parser */
int __oslibversion = 34;

int main()
{
  printf("hello world!\n");
  return 0;
}

Note that command line parser is broken under Kickstart 1.3. Do not use it!