home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / c / gnu_c / docs / gcc_faq < prev    next >
Encoding:
Text File  |  1996-03-18  |  18.2 KB  |  521 lines

  1. RISC OS-GCC FAQ
  2. ===============
  3.  
  4. Last updated: 15.03.1996, Jochen Scharrlach (jscharrl@ba-stuttgart.de),
  5.                           Nick Burrett (n.a.burrett@mcs.salford.ac.uk) and
  6.                           Peter Burwood (pjb@arcangel.demon.co.uk)
  7.  
  8. Posting: irregularly, every time when there are major changes. I am not
  9.          sure where to put this FAQ at the moment, but I'll make it
  10.          available via:
  11.          http://www.uni-stuttgart.de/Archive/acorn/
  12.  
  13. Throughout this document, when we refer to GCC we collectively mean
  14. GNU C, GNU C++, GNU Objective-C, GNU Fortran-77 and GNU GNAT Ada.
  15.  
  16. The following FAQ does not try to explain internals of GCC nor does it
  17. provide a language tutorial. It only tries to explain how to handle the Acorn
  18. port of GCC. It is not a classic selection of questions and answers,
  19. it's more like a brief manual. Unless you are an experienced Acorn-GCC
  20. programmer, this document might be very helpful.
  21.  
  22. Other GNU languages, such as Ada, Fortran and Pascal have their own FAQ,
  23. but common aspects of GNU compilers are discussed here. Parts of this
  24. FAQ may be overridden by language specific FAQs.
  25.  
  26. Disclaimer: Acorn, FSF or the GCC porters are not responsible for this FAQ.
  27.   Be aware that this FAQ wasn't written by one almighty guru, there were
  28.   several people helping me.
  29.  
  30. This FAQ describes the port: GCC 2.7.2 (and equivalent compiler versions)
  31. with ARM/RISC OS backend version 1.0.5. If you have an older version try
  32. to get this one, if you have a newer version please tell me where I can get
  33. it from...
  34.  
  35. Please help me on stuff marked with "(?)". If you find any mistakes (even
  36. grammar or spelling mistakes) or have any updates or suggestions, drop me
  37. an email.
  38.  
  39. Contents
  40. --------
  41.  
  42. 1. Availability
  43.  1.1 FTP
  44.  1.2 CD-ROM
  45.  1.3 other
  46.  1.4 Source
  47. 2. Installation
  48. 3. Libraries
  49.  3.1 C++
  50.  3.2 UnixLib
  51.  3.3 gststubs
  52.  3.4 DeskLib
  53.  3.5 OSLib
  54.  3.6 Toolbox
  55. 4. Using GCC
  56.  4.1 Memory requirements
  57.   4.1.1 Archimedes
  58.   4.1.2 RiscPC
  59.  4.2 Directories
  60.  4.3 Filename translation
  61.  4.4 Commandline options
  62.  4.5 Compiling C++ sources
  63.  4.6 Compiling Objective-C sources
  64.  4.7 Using <varargs.h>
  65.  4.8 Compiling other languages
  66. 5. Problems
  67.  5.1 General
  68.  5.2 Not enough memory
  69.  5.3 Failure to link
  70.  5.4 Fatal error: 2, System variable 'SHELL' not found
  71.  5.5 Compiler bugs
  72.  5.6 Dynamic Areas not deleted
  73. 6. Related Information
  74.  6.1 GCC documentation
  75.  6.2 Other FAQs
  76.  6.3 Interactive help
  77.  6.4 Books
  78.   6.4.1 C
  79.   6.4.2 C++
  80.   6.4.3 Object-Oriented Analysis and Design
  81.  
  82. ***************************
  83.  
  84. ---------------
  85. 1. Availability
  86. ---------------
  87.  
  88.  1.1 FTP
  89.  
  90.   * No full pathname details available at the time of GCC's release.
  91.     But the following addresses are going to be likely places to find
  92.     the compilers.
  93.  
  94.   * ftp::/micros.hensa.ac.uk/micros/arch/riscos/
  95.   * ftp::/ftp.demon.co.uk/archimedes/
  96.  
  97.  1.2 CD-ROM
  98.  
  99.   * No details available at time of release
  100.  
  101.  1.3 Other
  102.  
  103.   * No details available at time of release
  104.  
  105.  1.4 Source
  106.  
  107.   * The source changes for the RISC OS port are in the process of being
  108.     merged into the standard gcc distribution. Source for the RISC OS port
  109.     will currently only be available direct from Nick Burrett. Installation
  110.     help can also be obtained from him.
  111.  
  112. (?) - anything else?
  113.  
  114. ---------------
  115. 2. Installation
  116. ---------------
  117.  
  118.   You will find several archives which you'll have to unpack into the same
  119.   directory. Additionally you'll need a linker, e.g. DRLink. Install it into
  120.   a directory that is listed in Run$Path, e.g. !GCC.bin.
  121.  
  122. ------------
  123. 3. Libraries
  124. ------------
  125.  
  126.   The easiest way to use a C-library is to put the path into GCC$Path.
  127.   The path must point to the location where the subdirectories "o"
  128.   (contains the library itself) and "h" (contains the include files) reside.
  129.   C++-libraries have to be listed in GPP$Path. The other method would be to
  130.   tell gcc where to find the headers with -I<path> and the library with
  131.   -L<path>.
  132.  
  133.  3.1 C++
  134.  
  135.   If you want to compile C++-programs you'll also need the C++ library,
  136.   you should be able to get it where you found gcc. To use it, GPP$Path has
  137.   to point to the location you installed the lib. The C++ libraries supplied
  138.   with GCC 2.7.2 are C++ iostream, GNU C++ library and GNU ANSI C++.
  139.  
  140.  3.2 UnixLib
  141.  
  142.   UnixLib 3.6f works with gcc. In fact, gcc is configured to use UnixLib as
  143.   the preferred library. UnixLib provides Unix-style headers which seem to
  144.   work with gststubs (see below), but you may run into trouble with it.
  145.  
  146.   *Note*. All GNU compilers based around GCC 2.7.2 require UnixLib 3.6f,
  147.   not 3.6e.
  148.  
  149.  3.3 gststubs
  150.  
  151.   This one is a PD-replacement for Acorn's stubs. It's much smaller than
  152.   UnixLib, because it uses the SharedCLib, though it comes with no
  153.   header files. If you don't have the Acorn-C headers you'll have to try
  154.   it with UnixLib's headers, but it is not guaranteed that this will work
  155.   correctly.
  156.  
  157.  3.4 DeskLib
  158.  
  159.   Official versions above 2.16 should work fine with gcc. DeskLib provides
  160.   many WIMP- and other RISC OS-specific commands, but you'll need to link
  161.   with (gst)stubs (try -mstubs). As for whether GCC can compile DeskLib,
  162.   this has not been tested.
  163.  
  164.  3.5 OSLib
  165.  
  166.   Acorn's unofficial PD library. Should work with gcc, but it also needs
  167.   (gst)stubs. There are known problems when using C++ (OSLib uses C++
  168.   keywords) and you may need to use the "-ansi"-option.
  169.  
  170.  3.6 Toolbox
  171.  
  172.   Acorn's toolbox libraries for programming the toolbox modules from C.
  173.   Should work with gcc, but it also needs (gst)stubs. This is untested.
  174.  
  175. ------------
  176. 4. Using GCC
  177. ------------
  178.  
  179.  4.1 Memory requirements
  180.  
  181.   GCC needs between 3 and 8 Mb to compile C-programs and more than 4MB for
  182.   C++-progs, so it is very hard to use it on a 4MB machine without "tricks":
  183.  
  184.   4.1.1 Archimedes
  185.  
  186.   You can use !Virtual (current version 0.37), which gives you up to 24MB
  187.   of "virtual memory", i.e. your harddisc will be used to simulate this.
  188.   You still need at least 1.5MB of real memory, otherwise compiling will
  189.   take ages!
  190.  
  191.   4.1.2 RiscPC
  192.  
  193.   !Virtual doesn't work on a RiscPC, so you'll need to get enough RAM, i.e.
  194.   about 6-12MB.  Modifications have been made to UnixLib to allow usage
  195.   of dynamic areas for the compiler's heap and stack space. This is
  196.   compatible with Clares' Virtualise product which provides virtual
  197.   memory for dynamic areas. Other VM products will hopefully be
  198.   supported if and when they become available.
  199.  
  200.  4.2 Directories
  201.  
  202.   Because RiscOS doesn't use file extenders, the files are stored in
  203.   different subdirectories:
  204.  
  205.   * c    C source code
  206.   * cc   C++ source code (the way it was supposed to be)
  207.   * c++  C++ source code (the way Acorn wanted it to be...)
  208.   * ads  Ada specification source code
  209.   * adb  Ada body source code
  210.   * ali  Ada library files
  211.   * f    Fortran 77 source code
  212.   * m    Objective-C source code
  213.   * p    Pascal source code
  214.   * s    Assembler-source
  215.   * o    object files
  216.   * h    header files
  217.  
  218.  4.3 Filename translation
  219.  
  220.   GCC works correctly with both Unix format filenames and RISC OS format
  221.   filenames.
  222.  
  223.   If you want to compile the file dir.c.myprog, you can either say:
  224.     gcc dir.c.myprog
  225.   or:
  226.     gcc dir/myprog.c
  227.  
  228.  4.4 Commandline options
  229.  
  230.   I don't want to list all possible options, there are sh**loads of them.
  231.   The most important are:
  232.  
  233.   * -o <file>
  234.    redirect the output into <file>.
  235.   * -c
  236.    stop after compiling, i.e. no linking.
  237.   * -E
  238.    stop after preprocessing. If you don't specify an output file, the
  239.    output will be sent to stdout.
  240.   * -S
  241.    stop before assembling, i.e. generates Assembler-output.
  242.   * -I<path>
  243.    specify an additional path to search for include files.
  244.   * -L<path>
  245.    specify an additional path to search for libraries.
  246.   * -l<lib>
  247.    link with the library <lib>. You don't need to specify the path if
  248.    you either do this with the "-L"-option or specify it in GCC$Path.
  249.   * -O<n>
  250.    optimise, <n> is the degree how much should be done. "-O2" is the best
  251.    possible optimisation at the moment. "-O1" is the same as "-O", "-O0"
  252.    means no optimisation (default).
  253.    -O2 can significantly increase compilation time and is probably best used
  254.    during the final compilation of the program.
  255.   * -Wall
  256.    gives more warnings.
  257.  
  258.  
  259.   ARM dependant stuff, i.e. don't try this on other platforms:
  260.  
  261.   The opposite effect of these options can be utilised by pre-pending
  262.   -mno- to the option i.e. -mno-poke-function-name will prevent function
  263.   names from being compiled into the code.
  264.  
  265.   * -mapcs, -mapcs-frame
  266.    target for ARM Procedure Call Standard stack frames.
  267.   * -mpoke-function-name
  268.    place the name of the current function before the start of the function
  269.    to allow the post mortem debugger to print a readable backtrace.
  270.    Using it's opposite will reduce code size by about 3.5% for C code and
  271.    about 10% for Ada code. Note, code size reductions are very dependant
  272.    upon function sizes and function names. Reductions for other
  273.    languages are not known, but they will be similar.
  274.   * -mfpe
  275.    prevents instruction scheduling of floating point instructions since it
  276.    increases compile time and the benefits acheived make no difference through
  277.    the FPE.
  278.   * -mapcs-32
  279.    target the APCS-32 bit standard. Condition flags are assumed to be corrupted
  280.    by function calls in this mode.
  281.   * -mapcs-stack-check
  282.    provide explicit stack checking on entry to each function which allocates
  283.    temporary variables on the stack.
  284.   * -mapcs-strict
  285.    make the compiler conform strictly to the APCS even in the cases where
  286.    stack frames do not need to be set up.
  287.   * -msoft-float
  288.    cause the compile to assume all floating point instructions are missing
  289.    (and there is no emulator either), therefore generating function calls
  290.    instead.
  291.   * -mhard-float
  292.    the opposite of -msoft-float
  293.   * -mshort-load-bytes, -mno-short-load-words
  294.    if the MMU traps unaligned word accesses, shorts must be loaded
  295.    byte-at-a-time so this flag should be set.
  296.  
  297.   RISC OS specific options
  298.  
  299.   * -munique-areas
  300.    generate each function in its own individual code area giving the linker
  301.    extra chance to remove unused functions from the resulting binary.
  302.   * -mthrowback
  303.    send errors to a text editor capable of receiving 'throwbacks'.
  304.   * -mstubs
  305.    compiles to target SharedCLibrary and tells the linker to link with
  306.    stubs instead of UnixLib.
  307.   * -munixlib
  308.    tell the linker to target UnixLib instead of the SharedCLibrary
  309.   * -mdepend
  310.    Generate the file !Depend which contains a list of all the source
  311.    files that the produced object depend on. This is intended for use
  312.    with amu, which edit the makefile to include these after the
  313.    '# Dynamic Dependencies' line.
  314.  
  315.   For GCC on RISC OS, the options set on as default are:
  316.     -mapcs-frame
  317.     -mpoke-function-name
  318.     -mapcs-stack-check
  319.  
  320.  4.5 Compiling C++-sources
  321.  
  322.   GCC also compiles C++-code, you only have to put the source into the
  323.   correct subdirectory. To link C++-programs you can either explicitly
  324.   link with the C++-library, e.g.
  325.     gcc -o hello cc.hello -lc++
  326.   or:
  327.     gcc -c hello.cc
  328.     gcc -o hello o.hello -lc++
  329.   
  330.   or use the front end, g++, e.g.
  331.     g++ -o hello cc.hello
  332.   or:
  333.     g++ -c hello.cc
  334.  
  335.  4.6 Compiling Objective-C sources
  336.  
  337.    GCC also compiles Objective-C code, again source code just needs to be
  338.    placed in the correct subdirectory, m. To compile an Objective-C source
  339.    just typing:
  340.      gcc -o hello m.hello
  341.    or
  342.      gcc -c hello.m
  343.  
  344.    will be quite sufficient.
  345.  
  346.  4.7 Using <varargs.h>, <assert.h>, <stdarg.h>
  347.  
  348.   GCC supplies it's own versions of these header files since they are not
  349.   compatible with the headers supplied with Norcroft C and UnixLib.  However,
  350.   this feature is invisible to the user.
  351.  
  352.  4.8 Compiling other languages
  353.  
  354.    Please read the documentation that comes with the other languages.
  355.  
  356. ----------------------
  357. 5. Problems
  358. ----------------------
  359.  
  360.  If a problem is encountered, be it unable to compile, link, compiler
  361.  crash or something else then this section should be read before
  362.  contacting the porters for advice.
  363.  
  364.  5.1 General
  365.  
  366.   If you are new to using GNU compilers then try following the
  367.   !gcc.docs.gccuser instruction manual which contains helpful advice in
  368.   using them. If you believe the problem is specific to the RISC OS port,
  369.   then you will probably get more help from the comp.sys.acorn.programmer
  370.   newsgroup.
  371.  
  372.  5.2 Not enough memory
  373.  
  374.   All of the GNU compilers are memory hungry, some more than others.
  375.   This is often a problem with on a system with 4MB or less. Section 4.1
  376.   covers some ways to overcome this. To determine what the compiler is
  377.   trying to do when it runs out of memory, use the -v switch on gcc.
  378.   This will report what programs are being run to compile the source.
  379.   See also the section 5.6 about Dynamic Areas.
  380.  
  381.  5.3 Failure to link
  382.  
  383.   If you can compile the source to object files but not generate an
  384.   executable, then this probably means a linker program was not found.
  385.   Another cause is due to missing symbols, though this error will be
  386.   reported as such. Ensure the libraries specified with the link command
  387.   provide the symbols that are reported missing. Use the gcc command to
  388.   link rather than `link' or `drlink' since it adds some GNU specific
  389.   libraries.
  390.  
  391.   If you get `___main' undefined then you are trying to link a main unit
  392.   compiled with GCC 2.4.5 with the GCC 2.7.2 libgcc library. In this
  393.   case recompile the main unit with 2.7.2 or provide an assembler veneer
  394.   for ___main to branch to __gccmain and cross your fingers.
  395.   
  396.   Please note that GCC 2.4.5 is incompatible with GCC 2.7.2. We do not
  397.   recommend that object files, between the compilers, are intermixed.
  398.  
  399.  5.4 Fatal error: 2, System variable 'SHELL' not found
  400.  
  401.   Sometimes an error of the form `SHELL not found' is printed by the
  402.   compiler. This is a confusing error report and the true error is
  403.   normally reported just before this line. Typically, this is reported
  404.   when a file the program was looking for was not found. Use -v with gcc
  405.   to determine which program was not found and then check your Run$Path
  406.   and make sure the program exists. Run$Path should include gcc:bin.
  407.  
  408.  5.5 Compiler bugs
  409.  
  410.   All programs are susceptible to bugs and the GNU compilers are no
  411.   different. Your bug reports play an essential role in making the GNU
  412.   compilers reliable.
  413.   
  414.   When you encounter a problem, the first thing to do is to see if it is
  415.   already known. Known bugs are usually reported in one of the readme
  416.   files supplied with the compiler distribution. If the bug isn't known,
  417.   then you should report the problem.
  418.   
  419.   Reporting a bug may help you by bring a solution to your problem, or it
  420.   may not. In any case, the principal function of a bug report is to help
  421.   the entire community by making the next version of a GNU compiler work
  422.   better. Bug reoirts are your contribution to the maintenance of any GNU
  423.   compiler.
  424.   
  425.   In order for a bug report to serve its purpose, you must include the
  426.   information that makes for fixing the bug.
  427.   
  428.   If a bug is encountered in the compiler then contact the maintainer of
  429.   that particular compiler with the bug report produced by the compiler.
  430.   Do not send any source code in the first instance.
  431.   
  432.   All the GNU compilers use a common backend, which includes the ARM
  433.   backend and are under continuous development. New versions of the
  434.   compilers will be made available when they have been ported to RISC OS.
  435.  
  436.   More detailed information for reporting bugs can be found in the file
  437.   !gcc.docs.Bugs as supplied in the distribution.
  438.  
  439.  5.6 Dynamic Areas not deleted
  440.  
  441.   This is Risc PC specific. The GNU compiler can use dynamic areas as
  442.   detailed in section 4.1.2. If the dynamic area persists after the
  443.   compiler has finished, then it will never be deleted and it is not
  444.   reused by subsquent compilations. There is a utility program that
  445.   allows you to delete a Dynamic Area and this is explained in the
  446.   ReadMe that comes with the common components of the compiler and with
  447.   UnixLib.
  448.  
  449. ----------------------
  450. 6. Related Information
  451. ----------------------
  452.  
  453.  6.1 GCC documentation
  454.  
  455.   The original GCC documentation is written in Texinfo, which can either be
  456.   printed via TeX and be converted into a hypertext format ("info"). You
  457.   can also get a version for !StrongHlp v2:
  458.  
  459.   ftp://ftp.uni-stuttgart.de/pub/systems/acorn/riscos/docs/gnu/gcc-docs.zip
  460.  
  461.   CAUTION: this beast is 2MB (unpacked 7MB) big! Be aware that the given
  462.   information belongs to GCC 2.6.3, so not every listed feature will work.
  463.  
  464.  6.2 Other FAQs
  465.  
  466.   * comp.sys.acorn.announce: if you have trouble with your Acorn
  467.   * gnu.g++.help (g++-FAQ): GNU-C/C++ questions
  468.   * comp.lang.c: system independent questions about C
  469.   * comp.lang.c++: system independent questions about C++
  470.   * comp.lang.objective-c: system independent questions about Objective-C
  471.   * comp.lang.ada: system independent questions about Ada
  472.  
  473.  6.3 Interactive help
  474.  
  475.   * e-mail: Nicholas_A_Burrett@notes.salford.ac.uk  (Nick Burrett)
  476.     providing support for any problems with the ARM/RISC OS GCC compiler
  477.     for the C and Fortran family of languages.
  478.     
  479.     email: gnat@arcangel.demon.co.uk (Peter Burwood) providing support
  480.     for any problems with the ARM/RISC OS or ARM/RiscBSD GNAT compiler.
  481.     
  482.   * The "C Acorn User Group" (CAUG) supports C and C++ users on RISC
  483.     OS machines. For more information, send an email to caug@accu.org.
  484.     Their parent organisation ACCU has web pages at:
  485.     http://bach.cis.temple.edu/accu
  486.  
  487.  6.4 Books
  488.  
  489.   6.4.1 C
  490.  
  491.   * Kernighan, B. W. and Ritchie, D. M. (1988), The C Programming Language
  492.     (second edition). Prentice-Hall, Englewood Cliffs, NJ, USA.
  493.     ISBN 0-13-110362-8. (The original C 'bible'. Written by the designers
  494.     of C.)
  495.  
  496.   6.4.2 C++
  497.  
  498.   * Bjarne Stroustrup (1991), The C++ Programming Language (second
  499.     edition). At&T Bell Telephone Laboratories, Inc. ISBN 0-201-53992-6
  500.     (Written by the 'father' of C++)
  501.  
  502.   * Murray, Robert B. (1993), C++ Strategies and Tactics,
  503.     Addison-Wesley, ISBN 0-201-56382-7
  504.  
  505.   * Cargill, Tom (1992), C++ Programming Style, Addison-Wesley, ISBN
  506.     0-201-56365-7. This is a good 'second' C++ book showing you why
  507.     and how you should be using C++ features.
  508.  
  509.   6.4.3 Object-Oriented Analysis and Design
  510.  
  511.   * Booch, Grady (1994), Object-Oriented Analysis and Design with
  512.     Applications (2nd Edition), Benjamin/Cummings, ISBN
  513.     0-8053-5340-2. Complete coverage of the well-known Booch method of
  514.     OOAD.
  515.  
  516.   * White, Iseult (1994), Using the Booch Method, Benjamin/Cummings,
  517.     ISBN 0-8053-0614-5. A practical example of the Booch method. More
  518.     accessible but less complete than Booch's book.
  519.  
  520. (?) - Any other books, FAQs, etc. worth mentioning?
  521.