* some scanner optimizes

* automaticly aout2exe for go32v1
  * fixed dynamiclinker option which was added at the wrong place
This commit is contained in:
peter 1998-05-27 00:20:31 +00:00
parent d307cedd31
commit 5d25d6f1d6
3 changed files with 209 additions and 129 deletions

View File

@ -124,7 +124,7 @@ var
ext : extstr; ext : extstr;
begin begin
FSplit(s,path,name,ext); FSplit(s,path,name,ext);
ExeName:=Path+Name+target_os.ExeExt; ExeName:=Path+Name+target_info.ExeExt;
end; end;
@ -257,10 +257,7 @@ Var
i : longint; i : longint;
prtobj,s,s2 : string; prtobj,s,s2 : string;
begin begin
{ Open linkresponse and write header } WriteResponseFile:=False;
assign(linkresponse,inputdir+LinkResName);
rewrite(linkresponse);
{ set special options for some targets } { set special options for some targets }
prtobj:='prt0'; prtobj:='prt0';
case target_info.target of case target_info.target of
@ -275,7 +272,21 @@ begin
end; end;
end; end;
{ Add library searchpath } { Fix command line options }
If not SharedLibFiles.Empty then
LinkOptions:='-dynamic-linker='+DynamicLinker+' '+LinkOptions;
if Strip then
LinkOptions:=LinkOptions+target_link.stripopt;
{ Open linkresponse and write header }
assign(linkresponse,inputdir+LinkResName);
{$I-}
rewrite(linkresponse);
{$I+}
if ioresult<>0 then
exit;
{ Write library searchpath }
S2:=LibrarySearchPath; S2:=LibrarySearchPath;
Repeat Repeat
i:=Pos(';',S2); i:=Pos(';',S2);
@ -297,6 +308,7 @@ begin
if s<>'' then if s<>'' then
Writeln(linkresponse,s); Writeln(linkresponse,s);
end; end;
{ Write sharedlibraries like -l<lib> } { Write sharedlibraries like -l<lib> }
While not SharedLibFiles.Empty do While not SharedLibFiles.Empty do
begin begin
@ -330,9 +342,8 @@ Function TLinker.MakeExecutable:boolean;
var var
bindbin : string[80]; bindbin : string[80];
bindfound : boolean; bindfound : boolean;
_stacksize,i, i : longint;
_heapsize : longint; s : string;
s,s2 : string;
dummy : file; dummy : file;
success : boolean; success : boolean;
begin begin
@ -346,11 +357,6 @@ begin
end; end;
{$endif Linux} {$endif Linux}
If not SharedLibFiles.Empty then
LinkOptions:='-dynamic-linker='+DynamicLinker+' '+LinkOptions;
if Strip then
LinkOptions:=LinkOptions+target_link.stripopt;
{ Write used files and libraries } { Write used files and libraries }
WriteResponseFile; WriteResponseFile;
@ -362,25 +368,20 @@ begin
Replace(s,'$OPT',LinkOptions); Replace(s,'$OPT',LinkOptions);
Replace(s,'$RES',inputdir+LinkResName); Replace(s,'$RES',inputdir+LinkResName);
success:=DoExec(FindLinker,s,true,false); success:=DoExec(FindLinker,s,true,false);
{Bind} {Bind}
if target_info.target=target_os2 then if target_link.bindbin<>'' then
begin begin
{Calculate the stack and heap size in kilobytes, rounded upwards.} s:=target_link.bindcmd;
_stacksize:=(stacksize+1023) shr 10; Replace(s,'$EXE',exename);
{Minimum stacksize for EMX is 32K.} Replace(s,'$HEAPKB',tostr((heapsize+1023) shr 10));
if _stacksize<32 then Replace(s,'$STACKKB',tostr((stacksize+1023) shr 10));
_stacksize:=32; bindbin:=FindExe(target_link.bindbin,bindfound);
str(_stacksize,s);
_heapsize:=(heapsize+1023) shr 10;
str(_heapsize,s2);
bindbin:=FindExe('emxbind',bindfound);
if (not bindfound) and (not externlink) then if (not bindfound) and (not externlink) then
begin begin
Message(exec_w_binder_not_found); Message1(exec_w_binder_not_found,bindbin);
externlink:=true; externlink:=true;
end; end;
DoExec(bindbin,'-k'+s+' -o '+exename+'.exe '+exename+' -aim -s'+s2,false,false); DoExec(bindbin,s,false,false);
end; end;
{Remove ReponseFile} {Remove ReponseFile}
if (success) and (not externlink) then if (success) and (not externlink) then
@ -438,7 +439,12 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.10 1998-05-22 12:32:47 peter Revision 1.11 1998-05-27 00:20:31 peter
* some scanner optimizes
* automaticly aout2exe for go32v1
* fixed dynamiclinker option which was added at the wrong place
Revision 1.10 1998/05/22 12:32:47 peter
* fixed -L on the commandline, Dos commandline is only 128 bytes * fixed -L on the commandline, Dos commandline is only 128 bytes
Revision 1.9 1998/05/12 10:46:59 peter Revision 1.9 1998/05/12 10:46:59 peter

View File

@ -147,11 +147,11 @@ unit scanner;
orgpattern, orgpattern,
pattern : string; pattern : string;
macrobuffer : ^tmacrobuffer; macrobuffer : ^tmacrobuffer;
comment_level : word;
inputbuffer : pchar; inputbuffer : pchar;
inputpointer : pchar; inputpointer : pchar;
parse_types, { true, if type declarations are parsed } { parse_types, } { true, if type declarations are parsed }
s_point : boolean; s_point : boolean;
comment_level,
yylexcount, yylexcount,
macropos, macropos,
lastlinepos, lastlinepos,
@ -412,8 +412,15 @@ unit scanner;
readstring[i]:=c; readstring[i]:=c;
end; end;
{ get next char } { get next char }
readchar; c:=inputpointer^;
if c=#0 then
reload
else
inc(longint(inputpointer));
end; end;
{ was the next char a linebreak ? }
if c in [#10,#13] then
linebreak;
readstring[0]:=chr(i); readstring[0]:=chr(i);
end; end;
@ -458,12 +465,16 @@ unit scanner;
readnumber[i]:=c; readnumber[i]:=c;
end; end;
{ get next char } { get next char }
readchar; c:=inputpointer^;
if c=#0 then
reload
else
inc(longint(inputpointer));
end; end;
readnumber[0]:=chr(i);
{ was the next char a linebreak ? } { was the next char a linebreak ? }
{ if c in [#10,#13] then if c in [#10,#13] then
linebreak; } linebreak;
readnumber[0]:=chr(i);
end; end;
@ -498,7 +509,14 @@ unit scanner;
end; end;
end; end;
end; end;
readchar; { readchar; }
c:=inputpointer^;
if c=#0 then
reload
else
inc(longint(inputpointer));
if c in [#10,#13] then
linebreak;
until false; until false;
readcomment[0]:=chr(i); readcomment[0]:=chr(i);
end; end;
@ -508,14 +526,15 @@ unit scanner;
begin begin
while c in [' ',#9..#13] do while c in [' ',#9..#13] do
begin begin
readchar; { readchar; }
{c:=inputpointer^; c:=inputpointer^;
if c=#0 then if c=#0 then
reload reload
else else
inc(longint(inputpointer)); inc(longint(inputpointer));
if c in [#10,#13] then if c in [#10,#13] then
linebreak; } linebreak;
end; end;
end; end;
@ -544,12 +563,15 @@ unit scanner;
else else
found:=0; found:=0;
end; end;
readchar; { readchar;}
{c:=inputpointer^; c:=inputpointer^;
if c=#0 then if c=#0 then
reload reload
else else
inc(longint(inputpointer));} inc(longint(inputpointer));
if c in [#10,#13] then
linebreak;
until (found=2); until (found=2);
end; end;
@ -570,14 +592,15 @@ unit scanner;
'}' : dec_comment_level; '}' : dec_comment_level;
#26 : Message(scan_f_end_of_file); #26 : Message(scan_f_end_of_file);
end; end;
readchar; { readchar; }
{c:=inputpointer^; c:=inputpointer^;
if c=#0 then if c=#0 then
reload reload
else else
inc(longint(inputpointer));} inc(longint(inputpointer));
if c in [#10,#13] then
linebreak;
end; end;
{if (c=#10) or (c=#13) then linebreak;}
end; end;
@ -633,12 +656,14 @@ unit scanner;
else else
found:=0; found:=0;
end; end;
readchar; { readchar; }
{c:=inputpointer^; c:=inputpointer^;
if c=#0 then if c=#0 then
reload reload
else else
inc(longint(inputpointer));} inc(longint(inputpointer));
if c in [#10,#13] then
linebreak;
until (found=2); until (found=2);
end; end;
end; end;
@ -655,14 +680,14 @@ unit scanner;
label label
exit_label; exit_label;
begin begin
tokenpos.line:=current_module^.current_inputfile^.line_no;
tokenpos.column:=get_current_col;
tokenpos.fileindex:=current_module^.current_index;
{ was the last character a point ? } { was the last character a point ? }
{ this code is needed because the scanner if there is a 1. found if } { this code is needed because the scanner if there is a 1. found if }
{ this is a floating point number or range like 1..3 } { this is a floating point number or range like 1..3 }
if s_point then if s_point then
begin begin
tokenpos.line:=current_module^.current_inputfile^.line_no;
tokenpos.column:=get_current_col;
tokenpos.fileindex:=current_module^.current_index;
s_point:=false; s_point:=false;
if c='.' then if c='.' then
begin begin
@ -674,6 +699,7 @@ unit scanner;
goto exit_label; goto exit_label;
end; end;
{ Skip all spaces and comments }
repeat repeat
case c of case c of
'{' : skipcomment; '{' : skipcomment;
@ -683,14 +709,17 @@ unit scanner;
end; end;
until false; until false;
{ Save current token position }
lasttokenpos:=longint(inputpointer); lasttokenpos:=longint(inputpointer);
tokenpos.line:=current_module^.current_inputfile^.line_no; tokenpos.line:=current_module^.current_inputfile^.line_no;
tokenpos.column:=get_current_col; tokenpos.column:=get_current_col;
tokenpos.fileindex:=current_module^.current_index; tokenpos.fileindex:=current_module^.current_index;
{ will become line:=lasttokenpos ??;}
case c of
'_','A'..'Z', { Check first for a identifier/keyword, this is 20+% faster (PFV) }
'a'..'z' : begin
if c in ['_','A'..'Z','a'..'z'] then
begin
orgpattern:=readstring; orgpattern:=readstring;
pattern:=upper(orgpattern); pattern:=upper(orgpattern);
if (length(pattern) in [2..id_len]) and is_keyword(y) then if (length(pattern) in [2..id_len]) and is_keyword(y) then
@ -747,7 +776,10 @@ unit scanner;
yylex:=ID; yylex:=ID;
end; end;
goto exit_label; goto exit_label;
end; end
else
begin
case c of
'$' : begin '$' : begin
pattern:=readnumber; pattern:=readnumber;
yylex:=INTCONST; yylex:=INTCONST;
@ -946,7 +978,6 @@ unit scanner;
readchar; readchar;
c:=upcase(c); c:=upcase(c);
if not(block_type=bt_type) and (c in ['A'..'Z']) then if not(block_type=bt_type) and (c in ['A'..'Z']) then
{ if not(block_type=bt_type) and (c in [#64..#128]) then}
begin begin
pattern:=chr(ord(c)-64); pattern:=chr(ord(c)-64);
readchar; readchar;
@ -1056,6 +1087,8 @@ unit scanner;
Message(scan_f_illegal_char); Message(scan_f_illegal_char);
end; end;
end; end;
end;
exit_label: exit_label:
end; end;
@ -1069,9 +1102,14 @@ unit scanner;
end end
else else
readchar; readchar;
tokenpos.line:=current_module^.current_inputfile^.line_no; with tokenpos do
tokenpos.column:=get_current_col; begin
tokenpos.fileindex:=current_module^.current_index;
line:=current_module^.current_inputfile^.line_no;
column:=get_current_col;
fileindex:=current_module^.current_index;
end;
case c of case c of
'{' : begin '{' : begin
skipcomment; skipcomment;
@ -1137,11 +1175,15 @@ unit scanner;
procedure get_cur_file_pos(var fileinfo : tfileposinfo); procedure get_cur_file_pos(var fileinfo : tfileposinfo);
begin begin
fileinfo.line:=current_module^.current_inputfile^.line_no; with fileinfo do
begin
line:=current_module^.current_inputfile^.line_no;
{fileinfo.fileindex:=current_module^.current_inputfile^.ref_index;} {fileinfo.fileindex:=current_module^.current_inputfile^.ref_index;}
{ should allways be the same !! } { should allways be the same !! }
fileinfo.fileindex:=current_module^.current_index; fileindex:=current_module^.current_index;
fileinfo.column:=get_current_col; column:=get_current_col;
end;
end; end;
procedure set_cur_file_pos(const fileinfo : tfileposinfo); procedure set_cur_file_pos(const fileinfo : tfileposinfo);
@ -1214,7 +1256,12 @@ unit scanner;
end. end.
{ {
$Log$ $Log$
Revision 1.20 1998-05-23 01:21:30 peter Revision 1.21 1998-05-27 00:20:32 peter
* some scanner optimizes
* automaticly aout2exe for go32v1
* fixed dynamiclinker option which was added at the wrong place
Revision 1.20 1998/05/23 01:21:30 peter
+ aktasmmode, aktoptprocessor, aktoutputformat + aktasmmode, aktoptprocessor, aktoutputformat
+ smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
+ $LIBNAME to set the library name where the unit will be put in + $LIBNAME to set the library name where the unit will be put in

View File

@ -78,6 +78,8 @@ unit systems;
tlinkinfo = record tlinkinfo = record
linkbin : string[8]; linkbin : string[8];
linkcmd : string[50]; linkcmd : string[50];
bindbin : string[8];
bindcmd : string[50];
stripopt : string[2]; stripopt : string[2];
libpathprefix : string[12]; libpathprefix : string[12];
libpathsuffix : string[2]; libpathsuffix : string[2];
@ -97,7 +99,8 @@ unit systems;
unitext, unitext,
unitlibext, unitlibext,
asmext, asmext,
objext : string[4]; objext,
exeext : string[4];
os : tos; os : tos;
link : tlink; link : tlink;
assem : tasm; assem : tasm;
@ -129,7 +132,7 @@ implementation
staticlibext : '.A'; staticlibext : '.A';
sourceext : '.PP'; sourceext : '.PP';
pasext : '.PAS'; pasext : '.PAS';
exeext : '.EXE'; exeext : ''; { No .exe, the linker only output a.out ! }
scriptext : '.BAT'; scriptext : '.BAT';
Cprefix : '_'; Cprefix : '_';
newline : #13#10; newline : #13#10;
@ -327,6 +330,8 @@ implementation
( (
linkbin : 'ld'; linkbin : 'ld';
linkcmd : '$OPT -o $EXE $RES'; linkcmd : '$OPT -o $EXE $RES';
bindbin : '';
bindcmd : '';
stripopt : '-s'; stripopt : '-s';
libpathprefix : 'SEARCH_DIR('; libpathprefix : 'SEARCH_DIR(';
libpathsuffix : ')'; libpathsuffix : ')';
@ -340,6 +345,8 @@ implementation
,( ,(
linkbin : 'ld'; linkbin : 'ld';
linkcmd : '-oformat coff-go32 $OPT -o $EXE @$RES'; linkcmd : '-oformat coff-go32 $OPT -o $EXE @$RES';
bindbin : 'aout2exe';
bindcmd : '$EXE';
stripopt : '-s'; stripopt : '-s';
libpathprefix : '-L'; libpathprefix : '-L';
libpathsuffix : ''; libpathsuffix : '';
@ -352,6 +359,8 @@ implementation
,( ,(
linkbin : 'ld'; linkbin : 'ld';
linkcmd : '-oformat coff-go32-exe $OPT -o $EXE @$RES'; linkcmd : '-oformat coff-go32-exe $OPT -o $EXE @$RES';
bindbin : '';
bindcmd : '';
stripopt : '-s'; stripopt : '-s';
libpathprefix : '-L'; libpathprefix : '-L';
libpathsuffix : ''; libpathsuffix : '';
@ -364,6 +373,8 @@ implementation
,( ,(
linkbin : 'ldw'; linkbin : 'ldw';
linkcmd : '$OPT -o $EXE $RES'; linkcmd : '$OPT -o $EXE $RES';
bindbin : '';
bindcmd : '';
stripopt : '-s'; stripopt : '-s';
libpathprefix : 'SEARCH_DIR('; libpathprefix : 'SEARCH_DIR(';
libpathsuffix : ')'; libpathsuffix : ')';
@ -376,6 +387,8 @@ implementation
,( ,(
linkbin : 'ld'; linkbin : 'ld';
linkcmd : '-o $EXE @$RES'; linkcmd : '-o $EXE @$RES';
bindbin : 'emxbind';
bindcmd : '-o $EXE.exe $EXE -k$STACKKB -aim -s$HEAPKB';
stripopt : '-s'; stripopt : '-s';
libpathprefix : '-L'; libpathprefix : '-L';
libpathsuffix : ''; libpathsuffix : '';
@ -402,6 +415,7 @@ implementation
unitlibext : '.PPL'; unitlibext : '.PPL';
asmext : '.S1'; asmext : '.S1';
objext : '.O1'; objext : '.O1';
exeext : ''; { The linker procedures a.out }
os : os_GO32V1; os : os_GO32V1;
link : link_ldgo32v1; link : link_ldgo32v1;
assem : as_o assem : as_o
@ -417,12 +431,14 @@ implementation
unitlibext : '.PPL'; unitlibext : '.PPL';
asmext : '.S'; asmext : '.S';
objext : '.O'; objext : '.O';
exeext : '.EXE';
{$else UseAnsiString} {$else UseAnsiString}
smartext : '.SL'; smartext : '.SL';
unitext : '.PAU'; unitext : '.PAU';
unitlibext : '.PPL'; unitlibext : '.PPL';
asmext : '.SA'; asmext : '.SA';
objext : '.OA'; objext : '.OA';
exeext : '.EXE';
{$endif UseAnsiString} {$endif UseAnsiString}
os : os_GO32V2; os : os_GO32V2;
link : link_ldgo32v2; link : link_ldgo32v2;
@ -438,6 +454,7 @@ implementation
unitlibext : '.ppl'; unitlibext : '.ppl';
asmext : '.s'; asmext : '.s';
objext : '.o'; objext : '.o';
exeext : '';
os : os_Linux; os : os_Linux;
link : link_ld; link : link_ld;
assem : as_o assem : as_o
@ -452,6 +469,7 @@ implementation
unitlibext : '.ppl'; unitlibext : '.ppl';
asmext : '.so2'; asmext : '.so2';
objext : '.oo2'; objext : '.oo2';
exeext : ''; { The linker procedures a.out }
os : os_OS2; os : os_OS2;
link : link_ldos2; link : link_ldos2;
assem : as_o assem : as_o
@ -466,6 +484,7 @@ implementation
unitlibext : '.ppl'; unitlibext : '.ppl';
asmext : '.s'; asmext : '.s';
objext : '.o'; objext : '.o';
exeext : '.exe';
os : os_Win32; os : os_Win32;
link : link_ldw; link : link_ldw;
assem : as_o assem : as_o
@ -480,6 +499,7 @@ implementation
unitlibext : '.ppl'; unitlibext : '.ppl';
asmext : '.asm'; asmext : '.asm';
objext : '.o'; objext : '.o';
exeext : '';
os : os_Amiga; os : os_Amiga;
link : link_ld; link : link_ld;
assem : as_o assem : as_o
@ -494,6 +514,7 @@ implementation
unitlibext : '.ppl'; unitlibext : '.ppl';
asmext : '.s'; asmext : '.s';
objext : '.o'; objext : '.o';
exeext : '';
os : os_Atari; os : os_Atari;
link : link_ld; link : link_ld;
assem : as_o assem : as_o
@ -508,6 +529,7 @@ implementation
unitlibext : '.ppl'; unitlibext : '.ppl';
asmext : '.s'; asmext : '.s';
objext : '.o'; objext : '.o';
exeext : '';
os : os_Mac68k; os : os_Mac68k;
link : link_ld; link : link_ld;
assem : as_o assem : as_o
@ -606,7 +628,12 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.12 1998-05-23 01:21:32 peter Revision 1.13 1998-05-27 00:20:33 peter
* some scanner optimizes
* automaticly aout2exe for go32v1
* fixed dynamiclinker option which was added at the wrong place
Revision 1.12 1998/05/23 01:21:32 peter
+ aktasmmode, aktoptprocessor, aktoutputformat + aktasmmode, aktoptprocessor, aktoutputformat
+ smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
+ $LIBNAME to set the library name where the unit will be put in + $LIBNAME to set the library name where the unit will be put in