home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / f / fortran / GCCmain / !gcc / docs / gcc-faq < prev    next >
Encoding:
Text File  |  1996-11-10  |  18.2 KB  |  524 lines

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