This is Info file gcc-faq.info, produced by Makeinfo-1.55 from the
input file Amiga-GCC-FAQ.texi.


File: gcc-faq.info,  Node: Top,  Next: General Introduction,  Prev: (dir),  Up: (dir)

   Warning:  This FAQ remains incomplete, i.e. some sections do not
have an answer or much of an answer.  However, on the whole, there is
still a lot of information here that could be of help to you.

   All sections are immediately preceded by
[sec_number<.subsec_num<.subsubsec_num>>] where the <> indicate an
optional argument.  Thus, to get to section 9 without wading through
everything, simply search for [9].  For 2. (b) (iii), search for
[2.2.3].

   Amiga GNU CC FAQ 				Version 0.5

* Menu:



List of Chapters

* General Introduction::

* Obtaining and Installing the Beast::

* Initial Problems with GCC::

* Amiga-specific extensions::

* Advanced Questions::

* C++ and Objective C::

* Notes For Un*x Hackers::

* Support Utilities::

* Additional Support::

* Known Bugs::

* Maintainers and Contributors::

* Future::

* History::



Appendices

* How does the GPL affect programs compiled by GCC?::

* GNU Porting activities and who dealing with them::

* Another Free C compiler (for those without much memory)::


File: gcc-faq.info,  Node: General Introduction,  Next: Obtaining and Installing the Beast,  Up: Top

General Introduction
********************

* Menu:


* The  the GNU  and the GPL::

* What GCC has to offer.::

* Hardware and Software Requirements::


File: gcc-faq.info,  Node: The  the GNU  and the GPL,  Next: What GCC has to offer.,  Up: General Introduction

The FSF, the GNU Project, and the GPL
=====================================

   The Free Software Foundation (FSF) is an institution dedicated to
the free flow of software (and information in general (?)).  To this end
it has start the GNU (GNU's Not Unix) project, a collection of widely
portable software of all sorts (compilers and Un*x utilities for the
most part, but some other stuff as well).  But I'm sure Richard
Stallman, director and founder of the FSF, can say it better than I:
[Note that this is heavily clipped;  You should get the original at
<prep.mit.edu>]

   Copyright (C) 1985, 1993 Free Software Foundation, Inc.

   The GNU Manifesto *****************

   Why I Must Write GNU ====================

   I consider that the golden rule requires that if I like a program I
must share it with other people who like it.  Software sellers want to
divide the users and conquer them, making each user agree not to share
with others.  I refuse to break solidarity with other users in this
way.  I cannot in good conscience sign a nondisclosure agreement or a
software license agreement.  For years I worked within the Artificial
Intelligence Lab to resist such tendencies and other inhospitalities,
but eventually they had gone too far: I could not remain in an
institution where such things are done for me against my will.

   So that I can continue to use computers without dishonor, I have
decided to put together a sufficient body of free software so that I
will be able to get along without any software that is not free.  I
have resigned from the AI lab to deny MIT any legal excuse to prevent
me from giving GNU away.

   Why GNU Will Be Compatible with Unix
====================================

   Unix is not my ideal system, but it is not too bad.  The essential
features of Unix seem to be good ones, and I think I can fill in what
Unix lacks without spoiling them.  And a system compatible with Unix
would be convenient for many other people to adopt.

   How GNU Will Be Available =========================

   GNU is not in the public domain.  Everyone will be permitted to
modify and redistribute GNU, but no distributor will be allowed to
restrict its further redistribution.  That is to say, proprietary
modifications will not be allowed.  I want to make sure that all
versions of GNU remain free.

   Why Many Other Programmers Want to Help
=======================================

   I have found many other programmers who are excited about GNU and
want to help.

   Many programmers are unhappy about the commercialization of system
software.  It may enable them to make more money, but it requires them
to feel in conflict with other programmers in general rather than feel
as comrades.  The fundamental act of friendship among programmers is the
sharing of programs; marketing arrangements now typically used
essentially forbid programmers to treat others as friends.  The
purchaser of software must choose between friendship and obeying the
law.  Naturally, many decide that friendship is more important.  But
those who believe in law often do not feel at ease with either choice.
They become cynical and think that programming is just a way of making
money.

   By working on and using GNU rather than proprietary programs, we can
be hospitable to everyone and obey the law.  In addition, GNU serves as
an example to inspire and a banner to rally others to join us in
sharing.  This can give us a feeling of harmony which is impossible if
we use software that is not free.  For about half the programmers I
talk to, this is an important happiness that money cannot replace.

   How You Can Contribute ======================

   I am asking computer manufacturers for donations of machines and
money.  I'm asking individuals for donations of programs and work.

   One consequence you can expect if you donate machines is that GNU
will run on them at an early date.  The machines should be complete,
ready to use systems, approved for use in a residential area, and not
in need of sophisticated cooling or power.

   I have found very many programmers eager to contribute part-time
work for GNU.  For most projects, such part-time distributed work would
be very hard to coordinate; the independently-written parts would not
work together.  But for the particular task of replacing Unix, this
problem is absent.  A complete Unix system contains hundreds of utility
programs, each of which is documented separately.  Most interface
specifications are fixed by Unix compatibility.  If each contributor
can write a compatible replacement for a single Unix utility, and make
it work properly in place of the original on a Unix system, then these
utilities will work right when put together.  Even allowing for Murphy
to create a few unexpected problems, assembling these components will
be a feasible task.  (The kernel will require closer communication and
will be worked on by a small, tight group.)

   If I get donations of money, I may be able to hire a few people full
or part time.  The salary won't be high by programmers' standards, but
I'm looking for people for whom building community spirit is as
important as making money.  I view this as a way of enabling dedicated
people to devote their full energies to working on GNU by sparing them
the need to make a living in another way.

   Why All Computer Users Will Benefit
===================================

   Once GNU is written, everyone will be able to obtain good system
software free, just like air.(2)

   This means much more than just saving everyone the price of a Unix
license.  It means that much wasteful duplication of system programming
effort will be avoided.  This effort can go instead into advancing the
state of the art.

   Complete system sources will be available to everyone.  As a result,
a user who needs changes in the system will always be free to make them
himself, or hire any available programmer or company to make them for
him.  Users will no longer be at the mercy of one programmer or company
which owns the sources and is in sole position to make changes.

   Schools will be able to provide a much more educational environment
by encouraging all students to study and improve the system code.
Harvard's computer lab used to have the policy that no program could be
installed on the system if its sources were not on public display, and
upheld it by actually refusing to install certain programs.  I was very
much inspired by this.

   Finally, the overhead of considering who owns the system software
and what one is or is not entitled to do with it will be lifted.

   Arrangements to make people pay for using a program, including
licensing of copies, always incur a tremendous cost to society through
the cumbersome mechanisms necessary to figure out how much (that is,
which programs) a person must pay for.  And only a police state can
force everyone to obey them.  Consider a space station where air must
be manufactured at great cost: charging each breather per liter of air
may be fair, but wearing the metered gas mask all day and all night is
intolerable even if everyone can afford to pay the air bill.  And the
TV cameras everywhere to see if you ever take the mask off are
outrageous.  It's better to support the air plant with a head tax and
chuck the masks.

   Copying all or parts of a program is as natural to a programmer as
breathing, and as productive.  It ought to be as free.

   The GNU Public License (GPL) was written in order to keep software
published under it free.  Here's the Preamble of the GPL:

   		    GNU GENERAL PUBLIC LICENSE 		       Version 2, June 1991

   Copyright (C) 1989, 1991 Free Software Foundation, Inc.
             675 Mass Ave, Cambridge, MA 02139, USA  Everyone is
permitted to copy and distribute verbatim copies  of this license
document, but changing it is not allowed.

   			    Preamble

   The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software-to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.)  You can apply it to
your programs, too.

   When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it in
new free programs; and that you know you can do these things.

   To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

   For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

   We protect your rights with two steps: (1) copyright the software,
and (2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

   Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

   Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

   The precise terms and conditions for copying, distribution and
modification follow.

   More information regarding the FSF, GNU, and the GPL can be obtained
at gnu.prep.mit.edu.  Note that the source code of any GPLed software
must be made available by the distributor (is this wording accurate?).
The GPL may also affect how you distribute your programs, or maybe not.
For more information, check out Appendix A of this FAQ.  (Do this
before believing all the bad hype about it.  Then decide for yourself).


File: gcc-faq.info,  Node: What GCC has to offer.,  Next: Hardware and Software Requirements,  Prev: The  the GNU  and the GPL,  Up: General Introduction

What GCC has to offer.
======================

   A FREE C compiler, for starters.      It's available for a wide
range of machines (and thus it can't be 	beat for
cross-compiling, at least on the Amiga).      For the interested, a
chance to change it as you like, make your own       bug fixes, be an
active part in the development process.


File: gcc-faq.info,  Node: Hardware and Software Requirements,  Prev: What GCC has to offer.,  Up: General Introduction

Hardware and Software Requirements
==================================

   This depends upon what you're doing.  Here's an excerpt from Phillipe
Brand's readme for his distribution on the net:

   - Systems: Any Amiga (ranging from A1000 up to A4000/40, including
CD-32 & SX-1) will run amigados-gnu utilities.

   - Memory: A minimum of 4MB free memory is needed in order to compile
small/medium projects.  More memory will be needed for large projects,
such as recompiling gcc itself.  Gigamem is known to work with GCC so
*maybe* less memory will work.  But in this case, you'll need an MMU
equiped amiga (A3000,A4000/40, etc...).  VMM40 (Public Domain Virtual
memory manager) is also known to work with GCC.

   [Editor's note:  using the g++ compiler can require even more, like
at 	least  6 MB of free RAM] - OS: Starting from this release [2.6.3],
1.3 systems are not longer supported.  Gcc runs fine on all other
systems, starting from 2.04 up to 3.1 (40.68).

   [Lars Hecking: 1.3 compatibility was skipped with v40 of
ixemul.library.   I'm not completely sure, but gcc2.4.x runs under 1.3,
while 2.5.x and higher  need ixemul v40.x and thus 2.04 or higher.]

   - Disk Space; An installation of gcc requires the use of a hard
disk. Approximately 10MB is required at present to install the compiler
and utilities required to use it.  In addition 3MB is required for the
Commodore Developer Kit, which is required to be able to compile
AmigaDOS specific programs. This kit is available direct from
Commodore-Amiga.

   [Note, this is not true for the FreshFish distribution, which can be
run straight off the CD-ROM if desired.]

   Yes, it can take a lot of resources, but that's a function of its
portability.  Be glad you can count on having the same compiler on your
Amiga at home or the Unix system at work (or vice versa :-)).


File: gcc-faq.info,  Node: Obtaining and Installing the Beast,  Next: Initial Problems with GCC,  Prev: General Introduction,  Up: Top

Obtaining and Installing the Beast
**********************************

* Menu:


* Sources of the Amiga port of GCC::

* The Breakdown of the Distribution::

* Installation::

* Common Installation Problems::


File: gcc-faq.info,  Node: Sources of the Amiga port of GCC,  Next: The Breakdown of the Distribution,  Up: Obtaining and Installing the Beast

Sources of the Amiga port of GCC
================================

   There are a couple of options for getting GCC.     If you have
access to the Internet, and ftp service, you can obtain the current
version of GCC from Aminet, in dev/gcc.  The main site of Aminet is
<ftp.wustl.edu> in /pub/aminet, and has mirrors world-wide:
        USA (MO)                ftp.wustl.edu                      USA
(WI)               ftp.netnet.net                      USA (TX)
       ftp.etsu.edu                      Scandinavia
ftp.luth.se                      Switzerland              ftp.eunet.ch
                   Switzerland          ftp.math.ethz.ch
      Germany        kelly.uni-paderborn.de
Germany          ftp.uni-paderborn.de                      Germany
   ftp.uni-stuttgart.de                      Germany
ftp.uni-erlangen.de                      Germany
ftp.cs.tu-berlin.de                      Germany
ftp.tu-chemnitz.de                      Germany
ftp.fh-augsburg.de                      Germany
ftp.uni-bremen.de                      Germany
ftp.uni-kl.de                      Germany              ftp.uni-trier.de
                    Germany      ftp.informatik.rwth-aach
       France                    ftp.cnam.fr
Portugal                 ftp.ci.ua.pt                      UK
       ftp.doc.ic.ac.uk                      UK
micros.hensa.ac.uk

   <ftp.funet.fi> also serves to act as a hub for porting GNU software
to the Amiga, and serves to mirror Phillipe Brand's Amiga GCC tree
directly, so that you may always find GCC there (particularly to
guarantee the availability of source code).


File: gcc-faq.info,  Node: The Breakdown of the Distribution,  Next: Installation,  Prev: Sources of the Amiga port of GCC,  Up: Obtaining and Installing the Beast

The Breakdown of the Distribution
=================================

   The distribution is broken up into several parts, both to make it
easier to download and to respect the GPL.  Thus each archive is broken
into two parts, one for binaries and one for sources.

   Gcc-2.6.3 is split up into 15 archives:

   gcc263-readme.lha	holds readmes files (include installation notes).
gcc263-base.lha         basic gcc distribution, hold necessary files.
gcc263-inclib.lha	headers and libraries.  gcc263-c.lha		C compiler.
gcc263-c-020.lha	68020+68881 version of C compiler.  gcc263-c++.lha		C++
compiler, headers and libraries.  gcc263-c++-020.lha	68020+68881
versions of C++ compiler.  gcc263-objc.lha		Objective-C compiler,
header and libraries.  gcc263-objc-020.lha	68020+68881 versions
of Objective-C compiler.  gcc263-doc.lha		Gcc AmigaGuide(tm)
documents & manpages.  gcc263-utils.lha	Useful utilities needed for
development.  gcc263-utilsdoc.lha	Utilities documentation (guide &
manpages).  gcc263-texi.lha		All Texinfo documents.
gcc263-diffs.lha	Diff files for all binaries.
gcc263-src.lha		Source for gcc-2.6.3 plus diff file.

   The second way is to utilize your CD-ROM drive and get one of Fred
Fish's great CD-ROM collections. Any of the FreshFish or GoldFish Vol.
2 will have it, though the later the CD-ROM the later the version.  He
also includes as many ports of GNU utilities as he can.  His
restriction is simply that the binaries he includes must be compilable
from the sources he includes (this has been a problem in the past, and
Fred is a stringent observer of the GPL).  So, yes, you also get all
the sources with the binaries.  (If you've got a CD-ROM drive, you
should get one of these anyway; it's a great deal).     These CD-ROMs
may be purchased from Amiga Library Services by: Snail Mail:  Amiga
Library Services 	     610 N. Alma School Road, Suite 18
Chandler, AZ   85224-3687 	     USA FAX or Voice: (602) 491-0048
Phone: 	      (800) 804-0833 or Email: orders@amigalib.com (but sending
credit card information over e-mail is not secure, so one of the other
methods would be preferable.  Fred is working on using some kind of
encryption though.  More details when they're available.)

   There may be other CD-ROMs containing GCC, I just know of Fred's
since he is directly involved in the porting of it.     The breakdown
of this distribution is different.  Check the specific CD-ROM for
details.  They also include the Commodore Native Developer Updates (no
Autodocs) for 2.04, 3.0, and 3.1, which is a big bonus.


File: gcc-faq.info,  Node: Installation,  Next: Common Installation Problems,  Prev: The Breakdown of the Distribution,  Up: Obtaining and Installing the Beast

Installation
============

   Installation procedures may vary depending on your source, but the
final directory structure should be the same.  Check the README files
included in your distribution package for more details.

   The ftp distribution (Phillipe Brand's) contains an Installer
program.      It utilizes the following layout:

   Name			What					Where

   COPYING			GNU LICENSE, read!!			All archives
COPYING.LIB		GNU LIBRARY LICENSE, read!!		All archives
README-2.6.3		this file				All archives
NEWS-2.6.3		What's new in gcc-2.6.3			gcc263-base
Installer		Commodore installer utility		gcc263-base
GCC-Install		Installer script to configure gcc	All archives
envarc/			global environment variables you should 			have set when
using this programming	gcc263-base 			environment include/		non-amiga
specific C/C++ headers	gcc263-inclib os-include/proto	amiga specific
protos headers.		gcc263-inclib os-include/inline	amiga specific
inline C headers. Add	gcc263-inclib 			Commodore headers!!
os-lib/			amiga specific libraries		gcc263-base guide/			Docs
in AmigaGuide(tm) format		gcc263-doc man/			this is the root
for tons of man pages	gcc263-doc bin/			this is /bin, and contains all
gcc263-c 			binaries of this distribution that	gcc263-c++
are meant to be directly invoked by	gcc263-utils 			the user (contrary to
the executables      			in lib/gcc-lib/, that are meant to be
invoked by a driver program like gcc) lib/			normal (not base
relatives) libraries	gcc263-inclib lib/libm020/		normal 68020
libraries			gcc263-inclib lib/libb/		base relatives
libraries		gcc263-inclib lib/libb/libm020/	base relatives using
68020 libraries	gcc263-inclib lib/libnix/		Non-ixemul
libraries			gcc263-inclib lib/libm020/libnix/	Non-ixemul 68020
libraries		gcc263-inclib lib/libb/libnix/	Non-ixemul base
relatives libraries	gcc263-inclib
lib/libb/libm020/libnix	Non-ixemul base relatives 68020
libs	gcc263-inclib lib/gcc-lib/		home of compilers called by
gcc		gcc263-c 								gcc263-c++ 								gcc263-objc ixpipe/			a
pipe handler needed by the library	gcc263-base
libs/			ixemul.library				gcc263-base rexx/			ARexx wrappers for gcc and
g++		gcc263-base src-patches/		source patches				gcc263-diffs
geninline/		Perl scripts to generate inline
headers	gcc263-inclib 			and -lamy glue

   A standard GNU directory tree structure has been adopted by the
porting team to make life easier for everyone.  Starting with the
assign of GNU: to somewhere, we then have:

   GNU:amigados      GNU:man      GNU:Info      GNU:etc      GNU:bin
 GNU:include      GNU:lib      GNU:os-include      GNU:os-lib

   Since one of the aims of porting GNU software is to be able to
provide a Un*x like environment under AmigaOS, the porters decided to
make a GNU "root directory" (GNU:) in which a standard Un*x directory
tree can live, like /etc, /bin, and so on.  This decision makes for
good Un*x compatibility.     Also, in the past, you would have to add
many assigns (>=10) to have your GNU utilities working, and now it's
just 5 (GNU:, MAN:, INFO:, ETC:, and BIN: ).  We no longer have a
conflicting assign LIB: (which most other compilers use).


File: gcc-faq.info,  Node: Common Installation Problems,  Prev: Installation,  Up: Obtaining and Installing the Beast

Common Installation Problems
============================

   Using the Installer program for the ftp distribution should get rid
of any problems.       Check out the GNU documentation on the specs
file if you are having problems customizing your installation (say you
have another compiler, and don't want to have 2 separate copies of
os-include).       Also, for those of you who refuse to read the
README, you need the Commodore includes.  Section 2 (d) tells you where
to get them.       See 2 (c) about the GCC object format.  You may need
to convert some standard libraries.  Also check 2(a) on setting your
stack properly.


File: gcc-faq.info,  Node: Initial Problems with GCC,  Next: Amiga-specific extensions,  Prev: Obtaining and Installing the Beast,  Up: Top

Initial Problems with GCC
*************************

* Menu:


* Set your stack properly::

* Amiga specific Library options::

* The object file format of GCC::

* Getting the Commodore includes::

* The frontend of the compiler::

* Optimization may work where no optimization doesn::

* Using the OS functions with gcc::

* Removing Debug Symbols::


File: gcc-faq.info,  Node: Set your stack properly,  Next: Amiga specific Library options,  Up: Initial Problems with GCC

Set your stack properly
=======================

   [Note: this warning is becoming dated as versions >= 2.7.0 will
include automatic stack checking.]

   GCC needs a lot of stack to run.  For a nice, small (<1000 lines)
source, a stack of 50,000 should do just fine.  For more complicated
code, you may need more, but 250,000 should do in any case, for gcc
alone.      Note that using make may increase the demands on the stack
size, so the above suggestions may not hold.

   A word from Phillipe Brand's README:

   You need to have a 50.000 stack size in order to compile with GCC.
This should be enough for most projects. Note than while recompiling
gcc with itself it has taken more than 300KB stack. Stack can grow due
to source complexity.  Don't be afraid of it.

   To set the stack size, see the AmigaDOS Command 'stack'.

   To use ar and/or ranlib, 50KB is the minimum acceptable. You should
have a much larger stack, if you use larger libraries.

   Starting with 2.6.3 a new environnement variable, GCCSTACK, enables
gcc to read this variable and set stack upon startup. Thus now no need
to set stack to huge values, only gcc/ld/cpp/cc1#? will automatically
set new stack, according to GCCSTACK variable.

   Simply commit a: 	setenv GCCSTACK value to set gcc stack to value.

   Benefits: huge memory savings.

   Note that GCC 2.7.0 will include automatic stack growth code, so you
won't need to worry about this anymore.


File: gcc-faq.info,  Node: Amiga specific Library options,  Next: The object file format of GCC,  Prev: Set your stack properly,  Up: Initial Problems with GCC

Amiga specific Library options
==============================

* Menu:


* Ixemul.Library::

* libnix::

* Gerlib::

* the PDC library::


File: gcc-faq.info,  Node: Ixemul.Library,  Next: libnix,  Up: Amiga specific Library options

Ixemul.Library
--------------

   This library was developed by Markus Wild when originally started
porting GCC (up to version 2.3.3).  It is a shared library that emulates
a lot of Un*x functions, making life a lot easier for folks porting GNU
utilities and such.  Unfortunately, it is fairly resource hungry by
Amiga standards, and has caused not a little irritation among Amiga
users.  Bydefault, GCC has programs it compiles open ixemul.library, so
if you want to avoid it, you'll have to use -noixemul on the command
line (see below in Amiga specific extensions and/or coding with libnix)
and link to one of the libraries below.  	The general rule of
thumb should be to use ixemul.library if you're writing something
non-Amiga specific (e.g. porting something) or one of the below link
libraries when writing something specifically for the Amiga.

   Getting ixconfig to work: [Joerg-Cyril Hoehle]

   > Which ixconfig should we use for ixemul v40.4?

   If you're using R.Luebbert ixem404lib.lha, use ixconfig from there.
It's actually called bin in that archive :-( [generic]            2925
 5396  54.2% -lh5- b464 Sep  3  1994 ixem/bin

   The ixemul.library from the gcc263 archive is R.Luebbert's 40.4.

   If you're using another one:

   Fred Fish's: I don't know whether he removed the ArpBase field in the
include/library/ixemul.h file. R.Luebbert removed it between his 40.2
and 40.4, which was a big mistake IMHO (as this mail and others show).
So I don't know which ixconfig is good for him.

   Leonard's: He told me that he had never removed this field, so get
any old ixconfig you'll find. The one from the gcc263 archive will do.


File: gcc-faq.info,  Node: libnix,  Next: Gerlib,  Prev: Ixemul.Library,  Up: Amiga specific Library options

libnix
------

   This is a standard link library to replace the functionality of
ixemul.library. Make sure you link to it if you use the -noixemul
command line option for gcc.  Here's the readme file from the
distribution:

   Short: A library for amiga specific development on gcc Type: dev/gcc
Uploader: fleischr@izfm.uni-stuttgart.de Author:
fleischr@izfm.uni-stuttgart.de, gnikl@informatik.uni-rostock.de

   This is libnix, a static (i.e. link) library for gcc 2.3.3 or above.
It's not a replacement for ixemul.library (though it's possible to
recompile most of the gcc environment with libnix) but a good thing for
amiga specific development on gcc:

   * It's mostly compatible to SAS's way of handling things, i.e.
you get even an automatic shared library opening feature and   some
other things you may miss in ixemul.library.    This also means it's
ANSI compliant.

   * It doesn't need any shared libraries than normal Amiga OS ones.

   * It is not copyrighted by the FSF. Therefore you neither need   to
include sources nor objects together with your executable.    (read the
GLGPL _before_ flaming on this statement)

   * And it's short! I was able to compile a 492 byte 'hello, world'
using normal main.

   * It uses OS20 features whenever necessary.

   To cut it short:

   Use ixemul.library for porting Un*x programs, libnix for compiling
amiga-only programs and gcc becomes one of the best Amiga compilers.

   There is no need to download this archive if you use gcc2.6.0 or
above since the libraries itself are included with the normal gcc
distribution.

   But if you use an older gcc version or if you want to get the sources
you can take this package. But be warned: The ld that comes with earlier
versions of gcc has some serious trouble with set elements. You cannot
use libnix without the fixed linker that comes with gcc2.6.0.


File: gcc-faq.info,  Node: Gerlib,  Next: the PDC library,  Prev: libnix,  Up: Amiga specific Library options

Gerlib
------

   Obsolete.


File: gcc-faq.info,  Node: the PDC library,  Prev: Gerlib,  Up: Amiga specific Library options

the PDC library
---------------

   Obsolete.


File: gcc-faq.info,  Node: The object file format of GCC,  Next: Getting the Commodore includes,  Prev: Amiga specific Library options,  Up: Initial Problems with GCC

The object file format of GCC
=============================

   Yes, GCC uses its own object file format.  This means you aren't
currently able to link to AmigaDOS hunk format object files (standard).
But hunk2gcc (by Markus Wild) will do the conversion for you as
described below.

   Why does GCC use its own object file format?  It's really just a
design decision that allows other gnu utilities to deal with these
objects (for example, gdb [when the port is finished], nm, objdump, and
gas) without having to convert them to deal with AmigaDOS hunks.

   [From Brand's README-2.6.3]

   Starting from this release an AmigaDOS compliant library is provided,
thanks to libnix authors (Matthias Fleischer and Gunther Nikl).

   Anyway if you want to rebuild one, there are two methods:

   1) Using hunk2gcc; the AmigaDOS object converter made by Markus
Wild. To achieve this, simply grab a copy of latest amiga.lib (from
Commodore Development Kit) and make a new directory where you want your
converted object files to go, cd into it, and enter

   hunk2gcc amiga.lib [..further libs if you like..]

   This generates an a.out object file for every program unit present
in the hunk file (in this case, from amiga.lib).

   As the final step convert all those files into an a.out style
library by issuing:

   ar qc libamiga.a obj.*   ranlib libamiga.a

   The ranlib run builds a symbol table in the archive, and makes
accesses to the library much faster.

   2) Creating a libamiga.a library with libnix is fairly easy, but
takes some time. Just uncompress sources.lha from libnix distribution
and run a 'make libamiga.a'.

   NOTE:

   As long as you make no AmigaDOs specific calls, you can create a
dummy library using:

   cat "int dummy;" >dummy.c   gcc -c dummy.c   ar crv libamiga.a
dummy.o   mv libamiga.a gcc:lib

   A small libamiga.a (dummy) is also provided with libnix.


File: gcc-faq.info,  Node: Getting the Commodore includes,  Next: The frontend of the compiler,  Prev: The object file format of GCC,  Up: Initial Problems with GCC

Getting the Commodore includes
==============================

   [Jochen Wiedmann]

   You can obtain the includes and some developer tools from any Fish CD
and some other CD's as well.

   However, you will be missing the autodocs, which are definitely the
best information source for the OS functions. You can get them either
by buying the

   The Amiga ROM Kernel Manual:  Includes and Autodocs, ISBN
                                              0-201-56773-3

   (about 50-60$, as far as I know), or by buying the so-called NDU
(Native developers update kit, 5 disks, about 40$) from

   Fa. Hirsch & Wolf          Mittelstr. 33          56564 Neuwied
Germany

   Phone: (0049) +2631 83990 Email: hhhirsch@carla.adsp.sub.org

   Sorry, but this is still the *only* source for the NDU, at least as
long as CATS (Commodore Amiga Technical Support) isn't alive.

   I'd prefer buying the NDU, because it contains the newer information
than the book and I prefer it online.

   [Rask Lambertsen]

   [The C= includes are available via FTP from <ftp.dfv.rwth-aachen.de>
in directory cdrom/bbs/cbm. URL:
file://ftp.dfv.rwth-aachen.de/cdrom/bbs/cbm/

   The latest package is nduk-v40.lha. It includes includes (asm and C),
fd-files and a few developer tools (Atom, Alink, ...).

   Just to advertice a little for my homepage (sorry), I keep an
up-to-date link to the OS includes. They seem to move around from time
to time.

   Regards,
___________________________________________________________________________
/
   \ | Rask Ingemann Lambertsen <gc948374@gbar.dtu.dk> or
<e9864029@ebar.dtu.dk> | |              WWW homepage:
http://srv2.gbar.dtu.dk:8001/Rask/             | |   Keyboard error:
<Ctrl> and <Alt> are stuck - press <Del> to continue    |
\___________________________________________________________________________/

   P.S. My homepage URL recently changed, hopefully to something
permanent.


File: gcc-faq.info,  Node: The frontend of the compiler,  Next: Optimization may work where no optimization doesn,  Prev: Getting the Commodore includes,  Up: Initial Problems with GCC

The frontend of the compiler
============================

   amigados-gcc and gcc are the same thing.

   AREXX scripts [Phillipe Brand's README]:

   The provided ARexx scripts have been contributed by Loren J. Rittle.
If you like ARexx, they're an alternate way of calling gcc. They
automatically make sure you're using a large enough stack setting, and
enable you to compile C++ programs with less obscure options. This
approach is furthermore useful if you're not able to use the g++ /bin/sh
script.


File: gcc-faq.info,  Node: Optimization may work where no optimization doesn,  Next: Using the OS functions with gcc,  Prev: The frontend of the compiler,  Up: Initial Problems with GCC

Optimization may work where no optimization doesn't
===================================================

   The folks who write GCC almost always use -O when compiling GCC and
other stuff.  Hence, the -O routines are better tested than those
without optimization.  So you may want to try it.


File: gcc-faq.info,  Node: Using the OS functions with gcc,  Next: Removing Debug Symbols,  Prev: Optimization may work where no optimization doesn,  Up: Initial Problems with GCC

Using the OS functions with gcc
===============================

   [Jochen Wiedmann, with a small suggestion by Christian Stieber]

   Let's write a simple "HelloWorld.c":

   /*  Compile me with 	    gcc -noixemul -o HelloWorld HelloWorld.c
-lauto     */     #include <stdlib.c>     #include
<intuition/intuition.h>     #include <proto/intuition.h>

   int main(int argc, char *argv[])

   struct EasyRequest er;

   er.es_StructSize = sizeof(er);         er.es_Flags = 0;
er.es_Title = "Message";         er.es_TextFormat = "Hello,
world!\nintuition.library is at 0x8l.";         er.es_GadgetFormat =
"Ok";         EasyRequest(NULL, &er, NULL, IntuitionBase);
exit(0);

   Some notes:

   - We are using the function EasyRequestArgs() from intuition.library.
   Thus we have to include the appropriate headers:
intuition/intuition.h     for the structures and constants,
proto/intuition.h for the     function prototypes. Do not use headers
from other compilers (for     example pragmas/intuition.h), gcc headers
(inline/intuition.h,     included by proto/intuition.h) or even OS
headers     (clib/intuition_protos.h). The only exception are
clib/alib_protos.h     and clib/alib_stdio_protos.h: These represent
link libraries and not     shared libraries.

   - We did *not* open intuition.library. gcc does this for you by
including proto/intuition.h and linking against libauto.a.
However, this works only for OS libraries. Consult the GNU:libauto
directory, if you want to know how to get the same possibilities for
other shared libraries.

   Using proto/intuition.h you are safe and even source compatible
to SAS/C and Dice.

   - If you *need* to open a library manually, do it as follows:

   	#include <stdlib.h> 	#include <stdio.h>         #include
<intuition/intuition.h> 	#include <proto/intuition.h>

   struct IntuitionBase *IntuitionBase = NULL; 	/*  Explicit
initialization with NULL is a *must*!  */

   	void Cleanup(void)

   	 	    if (IntuitionBase) CloseLibrary(IntuitionBase); 	

   	int main(int argc, char *argv[])

   	 	    if (atexit(Cleanup))  		perror("atexit");
exit(20); 	

   	    if (!(IntuitionBase = (struct IntuitionBase *)
OpenLibrary("intuition.library", 37)))  		fprintf(stderr, "Cannot
open intuition.library, V37"); 		exit(20); 	

   	    /* Same program as above */ 	

   Note the use of atexit(), which makes exit() calling Cleanup().

   Note this possible alteration:

   >         struct EasyRequest er; > >         er.es_StructSize =
sizeof(er);

   This seems to be correct, but I suggest hardcoding 5*sizeof(ULONG)
here.  That field serves as version information; using sizeof() and
compiling with newer headers would tell the OS that you're using the
new structure.  But the additional fields will contain garbage...


File: gcc-faq.info,  Node: Removing Debug Symbols,  Prev: Using the OS functions with gcc,  Up: Initial Problems with GCC

Removing Debug Symbols
======================

   	By default, GCC will leave the debugging symbols in the executable.
To turn this off, simply use -s on the command line when you compile.
It could significantly reduce the size of your executable.


File: gcc-faq.info,  Node: Amiga-specific extensions,  Next: Advanced Questions,  Prev: Initial Problems with GCC,  Up: Top

Amiga-specific extensions
*************************

* Menu:


* The CHIP keyword::

* Command Line options::


File: gcc-faq.info,  Node: The CHIP keyword,  Next: Command Line options,  Up: Amiga-specific extensions

The CHIP keyword
================

   	Most C compilers for the Amiga have a CHIP keyword or equivalent to
signify that an object should stored CHIP memory when declared.  I.e.,
CHIP struct Image *my_graphics =  ...  will cause the memory for the
data to which my_graphics points to be allocated in CHIP memory (pretty
handy, huh?) 	This is obviously Amiga-specific, so of course
it's not implemented in the FSF code. BUT, the linker (ld) currently
recognizes -chip and -fast options.  However, these haven't been put in
gcc itself quite yet, though I have been assured they will be here soon
(there have been more important things to work on, like getting
-resident to work again, see below).           So if you're using 2.6.3
or below, here are some basic work-arounds:

   [under construction]


File: gcc-faq.info,  Node: Command Line options,  Prev: The CHIP keyword,  Up: Amiga-specific extensions

Command Line options
====================

* Menu:


* -noixemul::

* -fbaserel (currently broken until 2.7.0)::

* -resident::


File: gcc-faq.info,  Node: -noixemul,  Next: -fbaserel (currently broken until 2.7.0),  Up: Command Line options

-noixemul
---------

   This option prevents gcc from making your executable open
ixemul.library (of course, your program can still do so).  Make sure you
link to libnix or something similar to access those functions.
See also 2. (b) (ii)


File: gcc-faq.info,  Node: -fbaserel (currently broken until 2.7.0),  Next: -resident,  Prev: -noixemul,  Up: Command Line options

-fbaserel (currently broken until 2.7.0)
----------------------------------------

   [Christian Stieber]             -fbaserel turns on base relative
adressing; which means that global/static variables are referenced with
a 16 bit offset relative to an address register (a4 is generally used
for that). The startup-code loads a4 with a pointer into the data
segment. Result: every access to a global/shared variable is only 16
bit instead of the usual 32 bit address -> shorter & faster. It also
means that you're limited to at most 64K of global/static variables.


File: gcc-faq.info,  Node: -resident,  Prev: -fbaserel (currently broken until 2.7.0),  Up: Command Line options

-resident
---------

   [Christian Stieber]            A "resident" program (the correct
term is "pure") is a program that can be loaded into memory just once,
but executed by serveral processes at the same time. Therefore,
"resident" is actually "code sharing".  -resident turns on -fbaserel
and links with a special startup code.  That first thing that special
startup code is to allocate some memory, copy the global/static
variables into it and load a4 with a pointer to that memory. Then, a
normal startup-code and your normal program is run. When the program
exists, the memory block is freed.  Result: Every process has its very
own, private data segment for global/static variables. Since there all
global/static variables are accessed via a4+16-bit-offset (because of
-fbaserel), the original data segment is untouched. Result: the program
can be executed independently by several processes, with every process
getting its own data segment.


File: gcc-faq.info,  Node: Advanced Questions,  Next: C++ and Objective C,  Prev: Amiga-specific extensions,  Up: Top

Advanced Questions
******************

* Menu:


* How do I build a cross-compiler?::

* Working with AmiTCP::

* Writing code for ixemul.library::

* Writing code for libnix::

* Problems with asm()::

* How do I save RAM?::

* Writing shared libraries and resident (pure) code::

* I want to change from SAS/C to GCC::

* Inline Headers::

* Writing Hooks::


File: gcc-faq.info,  Node: How do I build a cross-compiler?,  Next: Working with AmiTCP,  Up: Advanced Questions

How do I build a cross-compiler?
================================

   [from Phillipe Brand]

   How to generate a cross-compiler, AmigaDOS side:

   - Get gcc-2.6.3.tar.gz from ftp.gnu.ai.mit.edu or mirror site - Get
ftp.telesys-innov.fr:/pub/amigados-gnu/gcc-2.6.3-amiga.diffs file

   >From CLI:

   CLI> sh # zcat gcc-2.6.3.tar.gz | tar xvf - # cd gcc-2.6.3 # zcat
../gcc-2.6.3-amiga.diffs | patch -p1 # ./configure -host=amigados
-target=CPU-COMPANY-SYSTEM # make

   When compilers are built, all you have to do is installing it using
make install, and to grab other architecture's libraries (libc.a,
etc...), and headers.

   More infos: See GCC AmigaGuide documentation, look for
"Cross-Compiling".

   How to generate a cross-compiler, Other architecture side:

   - Get gcc-2.6.3.tar.gz from ftp.gnu.ai.mit.edu or mirror site - Get
ftp.telesys-innov.fr:/pub/amigados-gnu/gcc-2.6.3-amiga.diffs file

   >From CLI:

   CLI> sh # zcat gcc-2.6.3.tar.gz | tar xvf - # cd gcc-2.6.3 # zcat
../gcc-2.6.3-amiga.diffs | patch -p1 # ./configure -target=amigados
(host should be determined by configure itself) # make

   When compilers are built, all you have to do is installing it using
make install, and to grab AmigaDOS GCC libraries (libc.a, etc...), and
headers.

   More infos: See GCC AmigaGuide documentation, look for
"Cross-Compiling".

   A working example of a cross-compiler running on sunos4.1.3 can be
found in ftp.telesys-innov.fr:/pub/amigados-gnu/gcc-cross/....


File: gcc-faq.info,  Node: Working with AmiTCP,  Next: Writing code for ixemul.library,  Prev: How do I build a cross-compiler?,  Up: Advanced Questions

Working with AmiTCP
===================

   [Peter Ivimey-Cook]

   > Could somebody please explain where exactly gcc and the libraries
> that come with it fall down when it comes to using AmiTCP?  > >
What's missing etc.  > > Then, Why can't (I assume you can't since
veryone says you can't) > use the C= Developers kit with gcc without
fiddling.

   The problems are:

   a) gcc uses it's own object module and library format, so lots of
the GNU tools don't have to change too.

   b) gcc uses ixemul by default, which is not compatible directly with
the SAS libraries supplied with AmiTCP.

   a) is just a design decision, and indeed there are tools to convert.
(b) is harder to see; basically the SAS AmiTCP libraries assume the
environment of SAS/C, complete with references to the SAS FILE
structure internals and the functions which aren't in SAS or which need
to be patched to work with AmiTCP. In addition, the netincludes
supplied with the AmiTCP port include many items and structure
definitions which are also defined in gcc, albeit differently,
resulting in a very confised compiler if you mix them.

   Unfortunately, a simplistic port (recompile with the right -I
directives) fails for two reasons; the includes are wrong, and even if
they were matched, the SAS-directed library patches the wrong things.
Resulting in an executable which will fail to operate as expected (it
might work OK, or it might not - depends what you call & when).

   What is needed is a new library - take out the duplicate
definitions, patch the right functions and remake the library for gcc.


File: gcc-faq.info,  Node: Writing code for ixemul.library,  Next: Writing code for libnix,  Prev: Working with AmiTCP,  Up: Advanced Questions

Writing code for ixemul.library
===============================

   After looking at Markus Wild's README, I couldn't see anything to
include in particular, and the thing is way too long to put here.  Any
specific suggestions of stuff to clip out?

   Actually, considering the update activity, the current maintainers/
developers should be providing a new README.  Particularly the functions
available in the different versions (regular fxns, the ones in the
network version, and the conflicts.  Somebody recently answered a
question about this last part, saying he was trying to integrate the 2).

* Menu:


* Finding bugs with trace()::


File: gcc-faq.info,  Node: Finding bugs with trace(),  Up: Writing code for ixemul.library

Finding bugs with trace()
-------------------------

   [Joerg-Cyril Hoehle] more than one year ago, I corrected a huge bug
in the program trace (a buffer overflow). Together with ixemul.trace,
this program allows you to see every ixemul call (aka SnoopDOS for
ixemul.library programs) and may be useful for debugging.

   Before, because of that overflow, trace hung the whole system very
often (and very soon) when tracing every ixemul call. Now, I've been
able to trace long sessions of gcc compilation to a (K)CON: window
without trouble.


File: gcc-faq.info,  Node: Writing code for libnix,  Next: Problems with asm(),  Prev: Writing code for ixemul.library,  Up: Advanced Questions

Writing code for libnix
=======================

   	You should really grab the documentation for libnix from the libnix
source archive and read it.  (This will be included in the
Amigaguide/texi versions of this FAQ).

   	But in the meanwhile, here's a warning from one of the authors of
libnix:

   [Gunther Nikl]  Hi!

   Let's write a simple "HelloWorld.c":

   /*  Compile me with             gcc -noixemul -o HelloWorld
HelloWorld.c -lauto     */
       ^^^^^^

   When using the "-noixemul" switch it is NOT nessecary (and better
avoided) to use "-lauto". libnix uses an own technique to open  the
system libraries.   Using "-noixemul" and "-lauto" together means that
all system  libraries will be opened twice...   The "libauto.a" is only
useful for IXEMUL linked programs.   Please state this in the faq!

   Gunther

