I compile gcc4.3.2 for 68k with old clib, it compile and work, but i want no ixemul and want newest files so i try latest clib2 for 68k from here

But in clib2 is some diffrent that fail to compile with clib2 libiberty, libstdc++ from gcc source.

I download OS4 clib2 too, but same files and i ask how can compilers build with that ?

compile the gcc4.x files with old includes and use later for coding new includes dont work, because there get __sF and __ctype__ linker errors
for example in a hello world printf bring the __sF not found error.

here is what i find and fix so far to compile more.

then most problematic part is this:

the Wrapper of C-language FILE struct -*- C++ -*- in libstdc++/config/io_basic_file_stdio.cc seem need the function calls.

  __basic_file<char>::xsgetn(char* __s, streamsize __n)
    streamsize __ret;
      __ret = read(this->fd(), __s, __n);      <- error read was not declared in that scope ------------------------------
    while (__ret == -1L && errno == EINTR);
    return __ret;

on all systems i think (here is snipped from cygwin includes old aos includes are too same), the structure is same.

struct __sFILE {
  unsigned char *_p;    /* current position in (some) buffer */
  int    _r;        /* read space left for getc() */
  int    _w;        /* write space left for putc() */
  short    _flags;        /* flags, below; this FILE is free if 0 */
  short    _file;        /* fileno, if Unix descriptor, else -1 */
  struct __sbuf _bf;    /* the buffer (at least 1 byte, if !NULL) */
  int    _lbfsize;    /* 0 or -_bf._size, for inline putc */

  struct _reent *_data;

  /* operations */
  _PTR    _cookie;    /* cookie passed to io functions */

  _READ_WRITE_RETURN_TYPE _EXFUN((*_read),(struct _reent *, _PTR,
                       char *, int));
  _READ_WRITE_RETURN_TYPE _EXFUN((*_write),(struct _reent *, _PTR,
                        const char *, int));
  _fpos_t _EXFUN((*_seek),(struct _reent *, _PTR, _fpos_t, int));
  int _EXFUN((*_close),(struct _reent *, _PTR));


are pointers to functions.the call is simular to OS4 interface with filepointer->_read
this seem need the C++ callstyle  of  libstdc++

but on clib2 the file structure is complete incompatible.
wy it is so incompatible ?

typedef struct
    unsigned long    flags;                /* See below for some of the public
                                           flag bits defined; this is by no
                                           means a complete list, though! */
    unsigned char *    buffer;                /* Points to the first byte of the
                                           buffer; this could be NULL! */
    long            size;                /* How many bytes will fit into the
                                           buffer; this could be 0! */
    long            position;            /* Current buffer position, which is
                                           usually a number between 0 and
                                           size-1 */
    long            num_read_bytes;        /* How many bytes can be read from
                                           the buffer; this can be 0! */
    long            num_write_bytes;    /* How many bytes have been copied
                                           to the buffer which have not been
                                           written back yet; this can be 0! */

    /* Private fields follow... */

here are some small problems i fix (they come before above error)

the file sys/resource.h miss the struct  rusage.See old aos include file how this look

file include/fcntl.h miss constant FD_CLOEXEC.
old file include file from include/sys/fcntl.h.seem buildprocess of gcc update only file sys/fcntl.h

this have this define.

file time.h have diffrent declare of gettimeofdate than old file.see old include file.timezone is void.and libstdc++ expectet it.

code in GCC source libiberty/gettimeofdate look as this

int gettimeofday (struct timeval *tp, void *tz)

now libiberty compile ok

next are libststdc++ changes need.

in include/unistd.h

add this line

ssize_t     write(int fd, const void *buf, size_t nbytes);


The build of a actual 68k gcc with is very easy(can build 4.4.0 with 3 minutes hand work too, and if all is done, the code can add to gcc main source because no gcc c source files need change or new #ifdef need add), if somebody want test, i can send complete source files.

here is remind log i write what must do to get it working out of a gcc source from there homepage

in the amigaos includes dir in your inline dir, you need the new macros.h file.work too on older gcc,because ggc use now motorola ASM output,
thats standard on amiga.also gcc main source dont generate correct code when not use motorola output.

compile of the attached 4.3.2 sources.I test on cygwin with 3.4 compilers:

important do cd to objdir and objdir should be diffrent to source dir or build/gencodes.exe miss error come.
and the vars should set with
export OBJDIR=......
export SRCDIR=......

to your source and object dir you want.

$SRCDIR/configure --target=m68k-amigaos --with-cpu=m68040 --prefix=/usr/local/amiga

make install DESTDIR=xxxx

best use DESTDIR to a temporary dir, so you see what files are create
create files in usr/local/amiga

thats all.

If you want build a compiler from gcc main source, this steps are need

add in gcc-x.x.x/gcc/config.gcc

    tm_file="${tm_file} m68k/amigaos.h"
    tm_p_file="${tm_p_file} m68k/amigaos-protos.h"
    tm_defines="TARGET_AMIGAOS TARGET_DEFAULT=0" # 68040

in gcc-x.x.x/gcc/config/m68k dir add files (from the 4.3.2 source)


in dir gcc-x.x.x//gcc files add

thats enough to build the gcc.more steps are need, to build the libs, libgcc libstdc++ when you want new

to build libgcc: add in libgcc/config.host 68k cpu and later amigaos.see file from 4.3.2 or use same.

the dir amigaos must add in libstdc++-v3/config (see 4.3.2 source)
now you can compile all.

for build libstdc++ with the crosscompilers you need do this steps

after (search for "GLIBCXX_IS_NATIVE=true")

if test $hostos = $targetos -o $targetos = darwin ; then

add this lines

     LDFLAGS="${LDFLAGS-ld} -noixemul"

search for "Base decisions on target environment"

# Base decisions on target environment.
case "${host}" in

add this lines


in gccx.x.x/libiberty/configure

after this lines

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.


add this line

LDFLAGS="${LDFLAGS-ld} -noixemul"

when you get assembler error remove the cas and jne instruction in atomics.h

if you want build without debug(-g ) type make "CFLAGS=-O2"  "LIBCFLAGS=-O2" "LIBCXXFLAGS=-O2" (but dont work i find out)

if you dont like that the whole debug symbols are in the libs, then use strip -g dir(older gcc are build without complete symbols)
also you can choose in amidev in linker options that your program have no debug symbols.

Wy now gcc compile always with debuf symbols i dont know,

every help/report is welcome, you can mail to get all files.