123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431 |
- {
- $Id$
- Copyright (c) 1993-98 by Florian Klaempfl
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- ****************************************************************************}
- {
- possible compiler switches (* marks a currently required switch):
- -----------------------------------------------------------------
- USE_RHIDE generates errors and warning in an format recognized
- by rhide
- TP to compile the compiler with Turbo or Borland Pascal
- GDB* support of the GNU Debugger
- I386 generate a compiler for the Intel i386+
- M68K generate a compiler for the M68000
- MULLER release special debug code of Pierre Muller
- (needs some extra units)
- USEOVERLAY compiles a TP version which uses overlays
- EXTDEBUG some extra debug code is executed
- SUPPORT_MMX only i386: releases the compiler switch
- MMX which allows the compiler to generate
- MMX instructions
- EXTERN_MSG Don't compile the msgfiles in the compiler, always
- use external messagefiles
- -----------------------------------------------------------------
- Required switches for a i386 compiler be compiled by Free Pascal Compiler:
- GDB;I386
- Required switches for a i386 compiler be compiled by Turbo Pascal:
- GDB;I386;TP
- Required switches for a 68000 compiler be compiled by Turbo Pascal:
- GDB;M68k;TP
- }
- {$ifdef FPC}
- {$ifndef GDB}
- { people can try to compile without GDB }
- { $error The compiler switch GDB must be defined}
- {$endif GDB}
- { but I386 or M68K must be defined }
- { and only one of the two }
- {$ifndef I386}
- {$ifndef M68K}
- {$fatal One of the switches I386 or M68K must be defined}
- {$endif M68K}
- {$endif I386}
- {$ifdef I386}
- {$ifdef M68K}
- {$fatal ONLY one of the switches I386 or M68K must be defined}
- {$endif M68K}
- {$endif I386}
- {$ifdef support_mmx}
- {$ifndef i386}
- {$fatal I386 switch must be on for MMX support}
- {$endif i386}
- {$endif support_mmx}
- {$endif}
- {$ifdef TP}
- {$IFNDEF DPMI}
- {$M 24576,0,655360}
- {$ELSE}
- {$M 65000}
- {$ENDIF DPMI}
- {$E+,N+,F+,S-,R-}
- {$endif TP}
- program pp;
- {$IFDEF TP}
- {$UNDEF PROFILE}
- {$IFDEF DPMI}
- {$UNDEF USEOVERLAY}
- {$ENDIF}
- {$ENDIF}
- {$ifdef FPC}
- {$UNDEF USEOVERLAY}
- {$UNDEF USEPMD}
- {$ENDIF}
- uses
- {$ifdef fpc}
- {$ifdef GO32V2}
- emu387,
- dpmiexcp,
- {$endif GO32V2}
- {$endif}
- {$ifdef useoverlay}
- {$ifopt o+}
- Overlay,ppovin,
- {$else}
- { warn when not $O+ is used }
- - You must compile with the $O+ switch
- {$endif}
- {$endif useoverlay}
- {$ifdef lock}
- lock,
- {$endif lock}
- {$ifdef profile}
- profile,
- {$endif profile}
- {$ifdef muller}
- openfile,
- {$ifdef usepmd}
- usepmd,
- {$endif usepmd}
- {$endif}
- {$ifdef LINUX}
- catch,
- {$endif LINUX}
- {$IfDef PMD}
- OpenFile,
- BBError,
- ObjMemory,
- PMD, MemCheck,
- {$EndIf}
- {$ifdef TP}
- objects,
- {$endif}
- dos,cobjects,
- globals,parser,systems,tree,symtable,options,link,import,files,
- verb_def,verbose;
- {$ifdef useoverlay}
- {$O files}
- {$O globals}
- {$O hcodegen}
- {$O pass_1}
- {$O tree}
- {$O types}
- {$O objects}
- {$O options}
- {$O cobjects}
- {$O globals}
- {$O systems}
- {$O parser}
- {$O dos}
- {$O scanner}
- {$O symtable}
- {$O objects}
- {$O aasm}
- {$ifdef gdb}
- {$O gdb}
- {$endif gdb}
- {$ifdef i386}
- {$O opts386}
- {$O cgi386}
- {$O aopt386}
- {$O cgai386}
- {$O i386}
- {$O radi386}
- {$O rai386}
- {$O ratti386}
- {$O tgeni386}
- {$endif}
- {$ifdef m68k}
- {$O opts68k}
- {$O cg68k}
- {$O ra68k}
- {$O ag68kgas}
- {$endif}
- {$endif useoverlay}
- function getrealtime : real;
- var
- h,m,s,s100 : word;
- begin
- dos.gettime(h,m,s,s100);
- getrealtime:=h*3600.0+m*60.0+s+s100/100.0;
- end;
- var
- oldexit : pointer;
- procedure myexit;{$ifndef FPC}far;{$endif}
- begin
- exitproc:=oldexit;
- {$ifdef tp}
- if use_big then
- symbolstream.done;
- {$endif}
- if (erroraddr<>nil) then
- begin
- case exitcode of
- 202 : begin
- erroraddr:=nil;
- Writeln('Error: Stack Overflow');
- end;
- 203 : begin
- erroraddr:=nil;
- Writeln('Error: Out of memory');
- end;
- else
- begin
- erroraddr:=nil;
- Writeln('Error: Runtime Error ',exitcode);
- end;
- end;
- {when the module is assigned, then the messagefile is also loaded}
- if assigned(current_module) and assigned(current_module^.current_inputfile) then
- Writeln('Compilation aborted at line ',current_module^.current_inputfile^.line_no);
- end;
- end;
- {$ifdef tp}
- procedure do_streamerror;
- begin
- if symbolstream.status=-2 then
- WriteLn('Error: Not enough EMS memory')
- else
- WriteLn('Error: EMS Error ',symbolstream.status);
- {$ifndef MULLER}
- halt(1);
- {$else MULLER}
- runerror(190);
- {$endif MULLER}
- end;
- {$ifdef USEOVERLAY}
- function _heaperror(size:word):integer;far;
- type
- heaprecord=record
- next:pointer;
- values:longint;
- end;
- var
- l,m:longint;
- begin
- l:=ovrgetbuf-ovrminsize;
- if (size>maxavail) and (l>=size) then
- begin
- m:=((longint(size)+$3fff) and $ffffc000);
- {Clear the overlay buffer.}
- ovrclearbuf;
- {Shrink it.}
- ovrheapend:=ovrheapend-m shr 4;
- heaprecord(ptr(ovrheapend,0)^).next:=freelist;
- heaprecord(ptr(ovrheapend,0)^).values:=m shl 12;
- heaporg:=ptr(ovrheapend,0);
- freelist:=heaporg;
- Writeln('Warning: Overlay buffer shrinked, because of memory shortage');
- _heaperror:=2;
- end
- else
- _heaperror:=0;
- end;
- {$endif USEOVERLAY}
- {$endif TP}
- var
- start : real;
- {$IfDef Extdebug}
- EntryMemAvail : longint;
- {$EndIf}
- begin
- oldexit:=exitproc;
- exitproc:=@myexit;
- {$ifdef linux}
- heapblocks:=true;
- {$else}
- {$ifdef go32v2}
- heapblocks:=true;
- {$endif}
- {$endif}
- {$ifdef EXTDEBUG}
- EntryMemAvail:=MemAvail;
- {$endif}
- {$ifdef MULLER}
- {$ifdef DPMI}
- HeapBlock:=$ff00;
- {$endif DPMI}
- {$endif MULLER}
- {$ifdef TP}
- {$IFDEF USEOVERLAY}
- heaperror:=@_heaperror;
- {$ENDIF USEOVERLAY}
- if use_big then
- begin
- streamerror:=@do_streamerror;
- { symbolstream.init('TMPFILE',stcreate,16000); }
- {$ifndef dpmi}
- symbolstream.init(10000,4000000); {using ems streams}
- {$else}
- symbolstream.init(1000000,16000); {using memory streams}
- {$endif}
- if symbolstream.errorinfo=stiniterror then
- do_streamerror;
- { write something, because pos 0 means nil pointer }
- symbolstream.writestr(@inputfile);
- end;
- {$endif tp}
- { inits which need to be done before the arguments are parsed }
- get_exepath;
- init_tree;
- globalsinit;
- init_symtable;
- linker.init;
- { read the arguments }
- read_arguments;
- { inits which depend on arguments }
- initparser;
- initimport;
- {show some info}
- Message1(general_i_compilername,FixFileName(paramstr(0)));
- Message1(general_i_unitsearchpath,unitsearchpath);
- Message1(general_d_sourceos,source_os.name);
- Message1(general_i_targetos,target_os.name);
- Message1(general_u_exepath,exepath);
- {$ifdef linux}
- Message1(general_u_gcclibpath,Linker.librarysearchpath);
- {$endif}
- {$ifdef TP}
- Comment(V_Info,'Memory: '+tostr(MemAvail)+' Bytes Free');
- {$endif}
- start:=getrealtime;
- compile(inputdir+inputfile+inputextension,false);
- if status.errorcount=0 then
- begin
- start:=getrealtime-start;
- Message2(general_i_abslines_compiled,tostr(status.compiledlines),tostr(trunc(start))+'.'+tostr(trunc(frac(start)*10)));
- end;
- clearnodes;
- done_symtable;
- {$ifdef TP}
- Comment(V_Info,'Memory: '+tostr(MemAvail)+' Bytes Free');
- {$endif}
- {$ifdef EXTDEBUG}
- Comment(V_Info,'Memory lost = '+tostr(EntryMemAvail-MemAvail));
- {$endif EXTDEBUG}
- { exits with error 1 if no codegeneration }
- if status.errorcount=0 then
- halt(0)
- else
- halt(1);
- end.
- {
- $Log$
- Revision 1.13 1998-06-13 00:10:11 peter
- * working browser and newppu
- * some small fixes against crashes which occured in bp7 (but not in
- fpc?!)
- Revision 1.12 1998/05/23 01:21:23 peter
- + aktasmmode, aktoptprocessor, aktoutputformat
- + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
- + $LIBNAME to set the library name where the unit will be put in
- * splitted cgi386 a bit (codeseg to large for bp7)
- * nasm, tasm works again. nasm moved to ag386nsm.pas
- Revision 1.11 1998/05/20 09:42:35 pierre
- + UseTokenInfo now default
- * unit in interface uses and implementation uses gives error now
- * only one error for unknown symbol (uses lastsymknown boolean)
- the problem came from the label code !
- + first inlined procedures and function work
- (warning there might be allowed cases were the result is still wrong !!)
- * UseBrower updated gives a global list of all position of all used symbols
- with switch -gb
- Revision 1.10 1998/05/12 10:47:00 peter
- * moved printstatus to verb_def
- + V_Normal which is between V_Error and V_Warning and doesn't have a
- prefix like error: warning: and is included in V_Default
- * fixed some messages
- * first time parameter scan is only for -v and -T
- - removed old style messages
- Revision 1.9 1998/05/11 13:07:56 peter
- + $ifdef NEWPPU for the new ppuformat
- + $define GDB not longer required
- * removed all warnings and stripped some log comments
- * no findfirst/findnext anymore to remove smartlink *.o files
- Revision 1.8 1998/05/08 09:21:57 michael
- + Librarysearchpath is now a linker object field;
- Revision 1.7 1998/05/04 17:54:28 peter
- + smartlinking works (only case jumptable left todo)
- * redesign of systems.pas to support assemblers and linkers
- + Unitname is now also in the PPU-file, increased version to 14
- Revision 1.6 1998/04/29 13:40:23 peter
- + heapblocks:=true
- Revision 1.5 1998/04/29 10:33:59 pierre
- + added some code for ansistring (not complete nor working yet)
- * corrected operator overloading
- * corrected nasm output
- + started inline procedures
- + added starstarn : use ** for exponentiation (^ gave problems)
- + started UseTokenInfo cond to get accurate positions
- Revision 1.3 1998/04/21 10:16:48 peter
- * patches from strasbourg
- * objects is not used anymore in the fpc compiled version
- Revision 1.2 1998/04/07 13:19:47 pierre
- * bugfixes for reset_gdb_info
- in MEM parsing for go32v2
- better external symbol creation
- support for rhgdb.exe (lowercase file names)
- }
|