URL
                    https://opencores.org/ocsvn/or1k/or1k/trunk
                
            Subversion Repositories or1k
[/] [or1k/] [trunk/] [gdb-5.3/] [mpw-README] - Rev 1765
Compare with Previous | Blame | View Log
This is basic information about the Macintosh(tm) MPW(tm) port of theGNU tools. The information below applies to both native and crosscompilers.(Please note that there are two versions of this file; "mpw-README"is the source form, and "Read Me for MPW" is the distribution form."Read Me for MPW" has 8-bit chars such as \Option-d embedded in it.)INSTALLING GNU TOOLS* System RequirementsTo use these tools, you will need a Mac with a 68020 or better or elseany PowerMac, System 7.1 or later, and MPW 3.3 or 3.4. You will *not*need any other MPW compiler unless you want to rebuild from sources,nor even any include files, unless you are building actual Macapplications. For PowerMac native you will need PPCLink, however;also the executables are PowerPC-only.* Automated InstallationThe simplest way to install GNU tools is to run the Install script.The script will copy things to where you want to keep them, will builda UserStartup file with settings corresponding to where things werecopied, and offer to put that UserStartup file in your MPW folder.The Install script does not alter anything in the System Folder, andit does not take any action without confirmation.The Install script will be at the top level of the binarydistribution, or at the top level of the object directory ifrebuilding from source. (The sources include a file called"mpw-install" at the top level, but it is the source to the Installscript and cannot be run directly.)* Manual InstallationIf you don't want to run the Install script, you can do installationmanually; this section describes the steps involved.The GNU tools can go in any directory that is in your {Commands} list.We generally put all the tools somewhere like {Boot}Cygnus:latest:bin,and then add to a UserStartup file:set Commands "{Boot}Cygnus:latest:bin:,{Commands}"However, the cpp and cc1 programs of GCC are not normally stored here.Instead, they will be in a "lib" directory that is alongside "bin",and organized by target and version underneath, with names like:lib:gcc-lib:<target>:cygnus-<version>:If you build and install everything yourself according to the buildinstructions below, then you will not have any problems. However, youmay discover that GCC seems unable to find the right cpp and cc1;usually this will be because directory names have changed. (Evenrenaming your hard disk will make this happen.) In such cases, youhave several choices. One is just to add this directory to{Commands}, but then you will not be able to get any other cpp or cc1,such as those used by a different target or version. Another way isto rename your disk and directories to match the prefix used when thetools were compiled. Finally, you can set the variableGCC_EXEC_PREFIX to point to the library directory:set GCC_EXEC_PREFIX MyDisk:Stuff:lib:gcc-lib:export GCC_EXEC_PREFIXYou may also want to edit MPW's HEXA 128 resource. When GCC is builtusing a native GCC, it is compiled to use a special stack allocatorfunction alloca(). While this is very efficient, it means that GCCwill need considerable stack space to run, especially when compilinglarge programs with optimization turned on. You give MPW more stackby editing the HEXA 128 resource of the MPW Shell. A value of "00080000" gives 512K of stack size, which is usually sufficient.USING GNU TOOLS* Using Native PowerMac GCCUsing a native PowerMac GCC to produce MPW tools or MacOS applicationsis more complicated than just "gC foo.c", although no more complicatedthan with other Mac compilers.To build a native PowerMac MPW tool, use this sequence, where hello.cis the usual "hello world" program, and genericcfrg.r is the Rez filewith the code fragment resource:gC -I{CIncludes} -fno-builtin -Dpascal= -c -g hello.cPPCLink hello.o -o hello \Option-d"{PPCLibraries}"StdCRuntime.o \Option-d"{SharedLibraries}"InterfaceLib \Option-d"{SharedLibraries}"StdCLib \Option-d"{PPCLibraries}"PPCToolLibs.o \Option-d"{PPCLibraries}"PPCCRuntime.o \Option-d"{GCCPPCLibraries}"libgcc.xcoffrez -d APPNAME='"'hello'"' GenericCFRG.r -o hellosetfile -t 'MPST' -c 'MPS ' helloThe same sequence works to build a MacOS application, but you set the filetype to 'APPL' and don't link in PPCToolLibs.o. For further details onusing MPW to build Mac applications, see the general MPW documentation.Recent versions of PPCLink have an option to generate the codefragment resource and automatically set creator and file type;here is what GenericCFRG.r should look like if you have an olderPPCLink or are using GNU ld:#include "CodeFragmentTypes.r"resource 'cfrg' (0) {{kPowerPC,kFullLib,kNoVersionNum,kNoVersionNum,0,0,kIsApp,kOnDiskFlat,kZeroOffset,kWholeFork,APPNAME // must be defined on Rez command line with -d option}};In general this port of GCC supports the same option syntax andbehavior as its Unix counterpart. It also has similar compilationrules, so it will run the assembler on .s files and so forth.The GCC manual includes full information on the available options.One option that may be especially useful is "-v", which shows you whattools and options are being used; unlike most Mac C compilers, GCCdirects assembly and linking in addition to compilation.MPW GCC does feature two extensions to the option syntax; '-d macro=name'works just as '-Dmacro=name' does in Unix, and '-i directory' works thesame as '-Idirectory'.MPW GCC supports the usual Pascal-style strings and alignment pragmas.To find standard include files you can set the variable GCCIncludes:set GCCIncludes MyDisk:MyIncludes:export GCCIncludesGCCIncludes is similar to MPW's CIncludes or CW's MWCIncludes. Inorder to use MPW's usual include files, just say:set GCCIncludes "{CIncludes}"export GCCIncludes* Using GCC as a Cross-CompilerIf you have a cross-compiler, and you have all of the correcttarget-side crt0 and libraries available, then to compile and link afile "foo.c", you can say justgC foo.cThe output file will be an MPW binary file named "a.out"; the formatof the contents will depend on which target is in use, so for instancea MIPS-targeting GCC will produce ECOFF or ELF executables.Note that using MPW include files with a cross-compiler is somewhatdangerous.* Using the Assembler and FriendsThe assembler ("as") and linker ("ld") are faithful ports of theirUnix counterparts. Similarly, the binutils "ar", "cplusfilt", "nm","objcopy", "objdump", "ranlib", "size", "strings", and "strip" are alllike they are under Unix. (Note that "cplusfilt" is usually called"c++filt" under Unix.)* Using GDBThere are two flavors of GDB. "gdb" is an MPW tool that works verymuch like it does in Unix; put a command into the MPW worksheet andtype the <enter> key to send it to GDB. While "gdb" is running, youcannot do anything else in MPW, although you can switch to otherMac applications and use them."SiowGDB" is also a Mac application, but it is GDB using the SIOWpackage to provide console emulation. Commands are exactly as for theMPW tool, but since this is its own application, you can switchbetween it and MPW.BUILDING GNU TOOLSThis port of the GNU tools uses a configure script similar tothat used for GNU tools under Unix, but rewritten for MPW. As withUnix configuration, there is an "object" directory that may bedifferent from the "source" directory. In the example commands below,we will assume that we are currently in the object directory, and thatthe source directory is "{Boot}Cygnus:src:".* Requirements for BuildingIn addition to the sources, you will need a set of tools that theconfigure and build scripts assume to be available. These tools(and their versions, if relevant) are as follows:byacc toolflex (2.3.7) tool (and Flex.skel file)forward-include scriptMoveIfChange scriptmpw-touch scriptmpw-true scriptNewFolderRecursive scriptnull-command scriptopen-brace scriptsed (1.13) tooltr-7to8 scripttrue scriptThe scripts are in the sources, under utils:mpw:. You must arrange toget the other tools yourself (they are readily available from the"usual" net sites, and are also on many CDROMS). In addition, therewill usually be a set of these available at ftp.cygnus.com, in pub/mac.You may put the build tools in your usual Tools or Scriptsdirectories, or keep them in a separate directories. We prefer tomake a directory called "buildtools" and we put this in one of ourUserStartup files:set Commands "{Boot}Cygnus:buildtools:,{Commands}"Flex uses an environment variable FLEX_SKELETON to locate its skeletonfile, so you need to do something like this, preferably in a UserStartup:Set FLEX_SKELETON "{Boot}"Cygnus:buildtools:Flex.skelExport FLEX_SKELETON* ConfiguringBefore you can build anything, you must configure. You do this bycreating an directory where object files will be stored, setdirectoryto that directory and do a configure command:{Boot}Cygnus:src:mpw-configure --target <name> --cc <compiler> --srcdir {Boot}Cygnus:src: --prefix <whatever>If the source directory is not in your {Commands} list, then you mustsupply a full pathname to mpw-configure, since mpw-configure invokesitself after switching into each subdirectory. Using a relativepathname, even something like ':mpw-configure', will therefore not work.<name> must be a known target. Valid ones include "m68k-apple-macos","powerpc-apple-macos", "i386-unknown-go32", "mips-idt-ecoff", and"sh-hitachi-hms". Not all target types are accepted for all of thetools yet.<compiler> must be the name of the compiler to use. It defaults to "mpwc".(m68k)mpwc MPW Csc68k Symantec Cmwc68k Metrowerks C (Codewarrior)gcc68k GCC(powerpc)ppcc PPCCmrc Macintosh on RisC (Mister C, aka(?) Frankenstein)scppc Symantec Cmwcppc Metrowerks C (Codewarrior)gccppc GCCNot all compilers will compile all tools equally well! For m68k Macs,MPW C has the best record so far (it has problems, but they can beworked around), while for PowerMacs, CodeWarrior is the only compilerthat has successfully compiled everything into running code.<prefix> is the path that "gcc" will prepend when looking for toolsto execute. GCC_EXEC_PREFIX overrides this value, so you need notinclude it if you plan to use GCC_EXEC_PREFIX.As an example, here is the configure line that you could use to buildnative PowerMac GCC:"{Boot}"Cygnus:src:mpw-configure --cc mwcppc --target powerpc-apple-macos --srcdir "{Boot}"Cygnus:src: --prefix "{Boot}"GNUTools:* BuildingIf you use CodeWarrior, you *must* first set MWCIncludes to{CIncludes}. This is because you will be building MPW tools, andtheir standard I/O works by making references to data that is part ofthe MPW Shell, which means that the code must be compiled and linkedwith macros that refer to that data, and those macros are in{CIncludes}, not the default {MWCIncludes}. Without this change, youwill encounter problems compiling libiberty/mpw.c, but tweaking thatfile only masks the real problem, and does not fix it.The commandmpw-buildwill build everything. Building will take over an hour on a Quadra 800or PowerMac 8100/110, longer if the sources are on a shared volume.You may see some warnings; these are mostly likely benign, typicallydisagreements about declarations of library and system functions.* InstallingTo install the just-built tools, use the commandmpw-build installThis part of the installation procedure just copies files to thelocation specified at configure time by <prefix>, and, in some cases,renames them from temporary internal names to their usual names. Thisinstall process is *not* the same as what the Install script does;Install can copy tools from the installation location chosen atconfiguration time to a user-chosen place, and sets up a UserStartupfile. Note that while the Install script is optional, the installbuild action performs some tasks would be very hard to replicatemanually, so you should always do it before using the tools.* Known Problems With Using Various Compilers to BuildMost versions of MPW C have problems with compiling GNU software.MPW C 3.2.x has preprocessing bugs that render it incapable ofcompiling the BFD library, so it can't be used at all for building BFD.MPW C 3.3, 3.3.1, and 3.3.2 will spontaneously claim to have founderrors in the source code, but in fact the code is perfectly fine. Ifthis happens, just set the working directory back to the top-levelobjdir (where the configure command above was performed), and type"mpw-build all" again. If it goes on through the supposed error, thenyou got one of the spurious errors. A full build may require a numberof these restarts.MPW C 3.3.3 seems to work OK, at least with the aid of a number ofworkarounds that are in the sources (look for #ifdef MPW_C).Versions of MPW Make earlier than 4.0d2 have exhibited bizarre behavior,failure to substitute variables and the like.Metrowerks CW6 PPC linker (MWLinkPPC) seems to do bad things with memoryif the "Modern Memory Manager" is turned on (in the Memory control panel),but works OK if it is turned off.Metrowerks CW6 loses bigtime compiling opcodes:ppc-opc.c, which hassome deeply nested macros. (CW7 is OK.) There is a way to patch thefile, by substituting constant values. If you need to do this,contact shebs@cygnus.com for details.<Gestalt.h> is missing from {CIncludes} in the MPW version that comeswith CW7. You can just copy the one in CW7's {MWCIncludes}.CW8 and later have changes to headers and such that will require changesto the source in order to be able to use them to rebuild.KNOWN BUGSThe declarations for memcpy and memcmp in some versions of header filesmay conflict with GCC's builtin definition. Either use -fno-builtinor ignore the warnings.This is not a bug, but - watch out for cr/nl translation! For instance,if config/mpw-mh-mpw is not properly translated because it has beencopied or updated separately, then everything will almost build, butyou will get puzzling error messages from make or the compiler.'/' or ' ' embedded in any device, directory, or file name may or maynot work.objcopy -O srec foo.o makes random output filenames.Mac-x-mips requires -mgas but Unix hosts don't.GDB will frequently require a '/' on the front of a device name in orderto recognize it as an absolute rather than a relative pathname.GDB doesn't seem to use the printer port correctly, although it tries.The cursor doesn't always spin as much as it should. To get elaboratestatistics and warnings about spin rates, add this to UserStartup:set MEASURE_SPIN allexport MEASURE_SPIN

