* static/shared linking updates

This commit is contained in:
peter 1998-08-17 09:17:43 +00:00
parent 7936f4e13b
commit cc64a929aa
8 changed files with 255 additions and 175 deletions

View File

@ -31,25 +31,24 @@ const
{$ifdef tp} {$ifdef tp}
AsmOutSize=1024; AsmOutSize=1024;
{$else} {$else}
AsmOutSize=10000; AsmOutSize=32768;
{$endif} {$endif}
type type
PAsmList=^TAsmList; PAsmList=^TAsmList;
TAsmList=object TAsmList=object
{filenames} {filenames}
path : dirstr; path : pathstr;
name : namestr; name : namestr;
asmfile, asmfile, { current .s and .o file }
objfile, objfile,
srcfile,
as_bin : string; as_bin : string;
{outfile} {outfile}
AsmSize, AsmSize,
outcnt : longint; outcnt : longint;
outbuf : array[0..AsmOutSize-1] of char; outbuf : array[0..AsmOutSize-1] of char;
outfile : file; outfile : file;
Constructor Init(const fn:string); Constructor Init;
Destructor Done; Destructor Done;
Function FindAssembler:string; Function FindAssembler:string;
Function CallAssembler(const command,para:string):Boolean; Function CallAssembler(const command,para:string):Boolean;
@ -67,12 +66,11 @@ type
procedure WriteAsmList;virtual; procedure WriteAsmList;virtual;
end; end;
Procedure GenerateAsm(const fn:string); Procedure GenerateAsm;
Procedure OnlyAsm(const fn:string); Procedure OnlyAsm;
var var
SmartLinkFilesCnt : longint; SmartLinkFilesCnt : longint;
Function SmartLinkPath(const s:string):string;
Implementation Implementation
@ -107,20 +105,6 @@ uses
; ;
{*****************************************************************************
SmartLink Helpers
*****************************************************************************}
Function SmartLinkPath(const s:string):string;
var
p : dirstr;
n : namestr;
e : extstr;
begin
FSplit(s,p,n,e);
SmartLinkPath:=FixFileName(n+target_info.smartext);
end;
{***************************************************************************** {*****************************************************************************
TAsmList TAsmList
*****************************************************************************} *****************************************************************************}
@ -191,10 +175,10 @@ begin
if cs_asm_leave in aktglobalswitches then if cs_asm_leave in aktglobalswitches then
exit; exit;
if cs_asm_extern in aktglobalswitches then if cs_asm_extern in aktglobalswitches then
AsmRes.AddDeleteCommand(asmfile) AsmRes.AddDeleteCommand(AsmFile)
else else
begin begin
assign(g,asmfile); assign(g,AsmFile);
{$I-} {$I-}
erase(g); erase(g);
{$I+} {$I+}
@ -364,28 +348,29 @@ begin
end; end;
Constructor TAsmList.Init(const fn:string); Constructor TAsmList.Init;
var var
ext : extstr; i : word;
i : word;
begin begin
{Create filenames for easier access} { load start values }
fsplit(fn,path,name,ext);
srcfile:=fn; asmfile:=current_module^.asmfilename^;
asmfile:=path+name+target_info.asmext; objfile:=current_module^.objfilename^;
objfile:=path+name+target_info.objext; name:=FixFileName(current_module^.modulename^);
OutCnt:=0; OutCnt:=0;
{Smartlinking}
SmartLinkFilesCnt:=0; SmartLinkFilesCnt:=0;
{ Which path will be used ? }
if (cs_smartlink in aktmoduleswitches) then if (cs_smartlink in aktmoduleswitches) then
begin begin
path:=SmartLinkPath(name); path:=current_module^.path^+FixFileName(current_module^.modulename^)+target_info.smartext;
{$I-} {$I-}
mkdir(path); mkdir(path);
{$I+} {$I+}
i:=ioresult; i:=ioresult;
end; path:=FixPath(path);
path:=FixPath(path); end
else
path:=current_module^.path^;
end; end;
@ -398,34 +383,34 @@ end;
Generate Assembler Files Main Procedure Generate Assembler Files Main Procedure
*****************************************************************************} *****************************************************************************}
Procedure GenerateAsm(const fn:string); Procedure GenerateAsm;
var var
a : PAsmList; a : PAsmList;
begin begin
case aktoutputformat of case aktoutputformat of
{$ifdef i386} {$ifdef i386}
{$ifndef NoAg386Att} {$ifndef NoAg386Att}
as_o : a:=new(pi386attasmlist,Init(fn)); as_o : a:=new(pi386attasmlist,Init);
{$endif NoAg386Att} {$endif NoAg386Att}
{$ifndef NoAg386Nsm} {$ifndef NoAg386Nsm}
as_nasmcoff, as_nasmcoff,
as_nasmelf, as_nasmelf,
as_nasmobj : a:=new(pi386nasmasmlist,Init(fn)); as_nasmobj : a:=new(pi386nasmasmlist,Init);
{$endif NoAg386Nsm} {$endif NoAg386Nsm}
{$ifndef NoAg386Int} {$ifndef NoAg386Int}
as_tasm : a:=new(pi386intasmlist,Init(fn)); as_tasm : a:=new(pi386intasmlist,Init);
{$endif NoAg386Int} {$endif NoAg386Int}
{$endif} {$endif}
{$ifdef m68k} {$ifdef m68k}
{$ifndef NoAg68kGas} {$ifndef NoAg68kGas}
as_o, as_o,
as_gas : a:=new(pm68kgasasmlist,Init(fn)); as_gas : a:=new(pm68kgasasmlist,Init);
{$endif NoAg86KGas} {$endif NoAg86KGas}
{$ifndef NoAg68kMot} {$ifndef NoAg68kMot}
as_mot : a:=new(pm68kmotasmlist,Init(fn)); as_mot : a:=new(pm68kmotasmlist,Init);
{$endif NoAg86kMot} {$endif NoAg86kMot}
{$ifndef NoAg68kMit} {$ifndef NoAg68kMit}
as_mit : a:=new(pm68kmitasmlist,Init(fn)); as_mit : a:=new(pm68kmitasmlist,Init);
{$endif NoAg86KMot} {$endif NoAg86KMot}
{$endif} {$endif}
else else
@ -439,11 +424,11 @@ begin
end; end;
Procedure OnlyAsm(const fn:string); Procedure OnlyAsm;
var var
a : PAsmList; a : PAsmList;
begin begin
a:=new(pasmlist,Init(fn)); a:=new(pasmlist,Init);
a^.DoAssemble; a^.DoAssemble;
dispose(a,Done); dispose(a,Done);
end; end;
@ -452,7 +437,10 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.16 1998-08-14 21:56:30 peter Revision 1.17 1998-08-17 09:17:43 peter
* static/shared linking updates
Revision 1.16 1998/08/14 21:56:30 peter
* setting the outputfile using -o works now to create static libs * setting the outputfile using -o works now to create static libs
Revision 1.15 1998/08/14 18:16:09 peter Revision 1.15 1998/08/14 18:16:09 peter

View File

@ -126,7 +126,8 @@ unit files;
objfilename, { fullname of the objectfile } objfilename, { fullname of the objectfile }
asmfilename, { fullname of the assemblerfile } asmfilename, { fullname of the assemblerfile }
ppufilename, { fullname of the ppufile } ppufilename, { fullname of the ppufile }
libfilename, { fullname of the libraryfile/exefile } staticlibfilename, { fullname of the static libraryfile }
sharedlibfilename, { fullname of the shared libraryfile }
exefilename, { fullname of the exefile } exefilename, { fullname of the exefile }
asmprefix, { prefix for the smartlink asmfiles } asmprefix, { prefix for the smartlink asmfiles }
mainsource : pstring; { name of the main sourcefile } mainsource : pstring; { name of the main sourcefile }
@ -229,13 +230,13 @@ unit files;
{ unit flags } { unit flags }
uf_init = $1; uf_init = $1;
uf_has_dbx = $2; uf_finalize = $2;
uf_has_browser = $4; uf_big_endian = $4;
uf_in_library = $8; uf_has_dbx = $8;
uf_shared_library = $10; uf_has_browser = $10;
uf_big_endian = $20; uf_in_library = $20;
uf_smartlink = $40; uf_static_library = $40;
uf_finalize = $80; uf_shared_library = $80;
{$endif} {$endif}
var var
@ -410,7 +411,8 @@ unit files;
stringdispose(objfilename); stringdispose(objfilename);
stringdispose(asmfilename); stringdispose(asmfilename);
stringdispose(ppufilename); stringdispose(ppufilename);
stringdispose(libfilename); stringdispose(staticlibfilename);
stringdispose(sharedlibfilename);
stringdispose(exefilename); stringdispose(exefilename);
stringdispose(path); stringdispose(path);
fsplit(fn,p,n,e); fsplit(fn,p,n,e);
@ -422,7 +424,8 @@ unit files;
{ lib and exe could be loaded with a file specified with -o } { lib and exe could be loaded with a file specified with -o }
if OutputFile<>'' then if OutputFile<>'' then
s:=OutputFile; s:=OutputFile;
libfilename:=stringdup(s+target_os.staticlibext); staticlibfilename:=stringdup(target_os.libprefix+s+target_os.staticlibext);
sharedlibfilename:=stringdup(target_os.libprefix+s+target_os.sharedlibext);
exefilename:=stringdup(s+target_os.exeext); exefilename:=stringdup(s+target_os.exeext);
end; end;
@ -489,12 +492,19 @@ unit files;
do_compile:=false; do_compile:=false;
if (flags and uf_in_library)=0 then if (flags and uf_in_library)=0 then
begin begin
if (flags and uf_smartlink)<>0 then if (flags and uf_static_linked)<>0 then
begin begin
objfiletime:=getnamedfiletime(libfilename^); objfiletime:=getnamedfiletime(staticlibfilename^);
if (ppufiletime<0) or (objfiletime<0) or (ppufiletime>objfiletime) then if (ppufiletime<0) or (objfiletime<0) or (ppufiletime>objfiletime) then
do_compile:=true; do_compile:=true;
end end
else
if (flags and uf_shared_linked)<>0 then
begin
objfiletime:=getnamedfiletime(sharedlibfilename^);
if (ppufiletime<0) or (objfiletime<0) or (ppufiletime>objfiletime) then
do_compile:=true;
end
else else
begin begin
{ the objectfile should be newer than the ppu file } { the objectfile should be newer than the ppu file }
@ -548,7 +558,7 @@ unit files;
singlepathstring:=FixPath(copy(unitpath,start,i-start)); singlepathstring:=FixPath(copy(unitpath,start,i-start));
delete(unitpath,start,i-start+1); delete(unitpath,start,i-start+1);
{ Check for PPL file } { Check for PPL file }
if not (cs_link_static in aktglobalswitches) then if not Found then
begin begin
Found:=UnitExists(target_info.unitlibext); Found:=UnitExists(target_info.unitlibext);
if Found then if Found then
@ -558,7 +568,7 @@ unit files;
End; End;
end; end;
{ Check for PPU file } { Check for PPU file }
if not (cs_link_dynamic in aktglobalswitches) and not Found then if not Found then
begin begin
Found:=UnitExists(target_info.unitext); Found:=UnitExists(target_info.unitext);
if Found then if Found then
@ -869,14 +879,15 @@ unit files;
ppufilename:=nil; ppufilename:=nil;
objfilename:=nil; objfilename:=nil;
asmfilename:=nil; asmfilename:=nil;
libfilename:=nil; staticlibfilename:=nil;
sharedlibfilename:=nil;
exefilename:=nil; exefilename:=nil;
{ go32v2 has the famous 8.3 limit ;) } { go32v2 has the famous 8.3 limit ;) }
{$ifdef go32v2} {$ifdef go32v2}
asmprefix:=stringdup('as'); asmprefix:=stringdup('as');
{$else} {$else}
asmprefix:=stringdup(Lower(n)); asmprefix:=stringdup(Lower(n));
{$endif} {$endif}
path:=nil; path:=nil;
setfilename(p+n); setfilename(p+n);
@ -933,7 +944,8 @@ unit files;
stringdispose(objfilename); stringdispose(objfilename);
stringdispose(asmfilename); stringdispose(asmfilename);
stringdispose(ppufilename); stringdispose(ppufilename);
stringdispose(libfilename); stringdispose(staticlibfilename);
stringdispose(sharedlibfilename);
stringdispose(exefilename); stringdispose(exefilename);
stringdispose(path); stringdispose(path);
stringdispose(modulename); stringdispose(modulename);
@ -1024,7 +1036,10 @@ unit files;
end. end.
{ {
$Log$ $Log$
Revision 1.34 1998-08-14 21:56:31 peter Revision 1.35 1998-08-17 09:17:44 peter
* static/shared linking updates
Revision 1.34 1998/08/14 21:56:31 peter
* setting the outputfile using -o works now to create static libs * setting the outputfile using -o works now to create static libs
Revision 1.33 1998/08/11 14:09:08 peter Revision 1.33 1998/08/11 14:09:08 peter

View File

@ -46,12 +46,12 @@ Type
function FindLibraryFile(s:string;const ext:string) : string; function FindLibraryFile(s:string;const ext:string) : string;
Procedure AddObject(const S : String); Procedure AddObject(const S : String);
Procedure AddStaticLibrary(const S : String); Procedure AddStaticLibrary(const S : String);
Procedure AddSharedLibrary(const S : String); Procedure AddSharedLibrary(S : String);
Function FindLinker:String; { Find linker, sets Name } Function FindLinker:String; { Find linker, sets Name }
Function DoExec(const command,para:string;info,useshell:boolean):boolean; Function DoExec(const command,para:string;info,useshell:boolean):boolean;
Function WriteResponseFile:Boolean; Function WriteResponseFile:Boolean;
Function MakeExecutable:boolean; Function MakeExecutable:boolean;
Procedure MakeStaticLibrary(const path:string;filescnt:longint); Procedure MakeStaticLibrary(filescnt:longint);
Procedure MakeSharedLibrary; Procedure MakeSharedLibrary;
end; end;
PLinker=^TLinker; PLinker=^TLinker;
@ -191,8 +191,17 @@ begin
end; end;
Procedure TLinker.AddSharedLibrary(const S:String); Procedure TLinker.AddSharedLibrary(S:String);
begin begin
{ remove prefix 'lib' }
if Copy(s,1,length(target_os.libprefix))=target_os.libprefix then
Delete(s,1,length(target_os.libprefix));
{ remove extension if any }
if Copy(s,length(s)-length(target_os.sharedlibext)+1,length(target_os.sharedlibext))=target_os.sharedlibext then
Delete(s,length(s)-length(target_os.sharedlibext)+1,length(target_os.sharedlibext)+1);
{ ready to be inserted }
SharedLibFiles.Insert (S); SharedLibFiles.Insert (S);
end; end;
@ -232,7 +241,7 @@ begin
if cs_link_extern in aktglobalswitches then if cs_link_extern in aktglobalswitches then
begin begin
if info then if info then
AsmRes.AddLinkCommand(Command,Para,current_module^.libfilename^) AsmRes.AddLinkCommand(Command,Para,current_module^.exefilename^)
else else
AsmRes.AddLinkCommand(Command,Para,''); AsmRes.AddLinkCommand(Command,Para,'');
end; end;
@ -291,7 +300,7 @@ begin
{ Fix command line options } { Fix command line options }
If not SharedLibFiles.Empty then If not SharedLibFiles.Empty then
LinkOptions:='-dynamic-linker='+DynamicLinker+' '+LinkOptions; LinkOptions:='-dynamic-linker='+DynamicLinker+' '+LinkOptions;
if Strip then if Strip and not(cs_debuginfo in aktmoduleswitches) then
LinkOptions:=LinkOptions+target_link.stripopt; LinkOptions:=LinkOptions+target_link.stripopt;
{ Open linkresponse and write header } { Open linkresponse and write header }
@ -376,9 +385,7 @@ function TLinker.MakeExecutable:boolean;
var var
bindbin : string[80]; bindbin : string[80];
bindfound : boolean; bindfound : boolean;
i : longint;
s : string; s : string;
dummy : file;
success : boolean; success : boolean;
begin begin
{$ifdef linux} {$ifdef linux}
@ -419,26 +426,27 @@ begin
end; end;
{Remove ReponseFile} {Remove ReponseFile}
if (success) and not(cs_link_extern in aktglobalswitches) then if (success) and not(cs_link_extern in aktglobalswitches) then
begin RemoveFile(LinkResName);
assign(dummy,LinkResName);
{$I-}
erase(dummy);
{$I+}
i:=ioresult;
end;
MakeExecutable:=success; { otherwise a recursive call to link method } MakeExecutable:=success; { otherwise a recursive call to link method }
end; end;
Procedure TLinker.MakeStaticLibrary(const path:string;filescnt:longint); Procedure TLinker.MakeStaticLibrary(filescnt:longint);
{
FilesCnt holds the amount of .o files created, if filescnt=0 then
no smartlinking is used
}
var var
smartpath,
s, s,
arbin : string; arbin : string;
arfound : boolean; arfound : boolean;
cnt : longint; cnt : longint;
i : word; i : word;
f : file;
begin begin
smartpath:=current_module^.path^+FixPath(FixFileName(current_module^.modulename^)+target_info.smartext);
{ find ar binary }
arbin:=FindExe(target_ar.arbin,arfound); arbin:=FindExe(target_ar.arbin,arfound);
if (not arfound) and not(cs_link_extern in aktglobalswitches) then if (not arfound) and not(cs_link_extern in aktglobalswitches) then
begin begin
@ -446,38 +454,51 @@ begin
aktglobalswitches:=aktglobalswitches+[cs_link_extern]; aktglobalswitches:=aktglobalswitches+[cs_link_extern];
end; end;
s:=target_ar.arcmd; s:=target_ar.arcmd;
Replace(s,'$LIB',current_module^.libfilename^); Replace(s,'$LIB',current_module^.staticlibfilename^);
Replace(s,'$FILES',FixPath(path)+current_module^.asmprefix^+'*'+target_info.objext); if filescnt=0 then
Replace(s,'$FILES',current_module^.objfilename^)
else
Replace(s,'$FILES',smartpath+current_module^.asmprefix^+'*'+target_info.objext);
DoExec(arbin,s,false,true); DoExec(arbin,s,false,true);
{ Clean up } { Clean up }
if not(cs_asm_leave in aktglobalswitches) and not(cs_link_extern in aktglobalswitches) then if not(cs_asm_leave in aktglobalswitches) and not(cs_link_extern in aktglobalswitches) then
begin begin
for cnt:=1to filescnt do if filescnt=0 then
RemoveFile(current_module^.objfilename^)
else
begin begin
assign(f,FixPath(path)+current_module^.asmprefix^+tostr(cnt)+target_info.objext);
for cnt:=1 to filescnt do
RemoveFile(smartpath+current_module^.asmprefix^+tostr(cnt)+target_info.objext);
{$I-} {$I-}
erase(f); rmdir(smartpath);
{$I+} {$I+}
i:=ioresult; i:=ioresult;
end; end;
{$I-}
rmdir(path);
{$I+}
i:=ioresult;
end; end;
end; end;
Procedure TLinker.MakeSharedLibrary; Procedure TLinker.MakeSharedLibrary;
var
s : string;
begin begin
DoExec(FindLinker,' -shared -o '+current_module^.libfilename^+' link.res',false,false); s:=' -shared -o $LIB $FILES';
Replace(s,'$LIB',current_module^.sharedlibfilename^);
Replace(s,'$FILES',current_module^.objfilename^);
if DoExec(FindLinker,s,false,false) then
RemoveFile(current_module^.objfilename^);
end; end;
end. end.
{ {
$Log$ $Log$
Revision 1.18 1998-08-14 21:56:34 peter Revision 1.19 1998-08-17 09:17:47 peter
* static/shared linking updates
Revision 1.18 1998/08/14 21:56:34 peter
* setting the outputfile using -o works now to create static libs * setting the outputfile using -o works now to create static libs
Revision 1.17 1998/08/14 18:16:08 peter Revision 1.17 1998/08/14 18:16:08 peter

View File

@ -132,9 +132,7 @@ unit parser;
oldaktoutputformat : tasm; oldaktoutputformat : tasm;
oldaktoptprocessor : tprocessors; oldaktoptprocessor : tprocessors;
oldaktasmmode : tasmmode; oldaktasmmode : tasmmode;
label
done;
begin begin
inc(compile_level); inc(compile_level);
@ -252,45 +250,21 @@ unit parser;
{ reset lexical level } { reset lexical level }
lexlevel:=0; lexlevel:=0;
{ parse source } { If the compile level > 1 we get a nice "unit expected" error
message if we are trying to use a program as unit.}
if (token=_UNIT) or (compile_level>1) then if (token=_UNIT) or (compile_level>1) then
begin begin
current_module^.is_unit:=true; current_module^.is_unit:=true;
{ If the compile level > 1 we get a nice "unit expected" error
message if we are trying to use a program as unit.}
proc_unit; proc_unit;
if current_module^.compiled then
goto done;
end end
else else
begin proc_program(token=_LIBRARY);
proc_program(token=_LIBRARY);
end;
if status.errorcount=0 then if status.errorcount>0 then
begin
GenerateAsm(filename);
if (cs_smartlink in aktmoduleswitches) then
Linker.MakeStaticLibrary(SmartLinkPath(FileName),SmartLinkFilesCnt);
{ add the files for the linker from current_module, this must be
after the makestaticlibrary, because it will add the library
name (PFV) }
Linker.AddModuleFiles(current_module);
{ Check linking => we are at first level in compile }
if (compile_level=1) then
begin
if (cs_link_deffile in aktglobalswitches) then
deffile.writefile;
if (not current_module^.is_unit) then
Linker.MakeExecutable;
end;
end
else
Message1(unit_f_errors_in_unit,tostr(status.errorcount)); Message1(unit_f_errors_in_unit,tostr(status.errorcount));
done:
{ clear memory } { clear memory }
{$ifdef Splitheap} {$ifdef Splitheap}
if testsplit then if testsplit then
@ -398,7 +372,10 @@ done:
end. end.
{ {
$Log$ $Log$
Revision 1.36 1998-08-14 21:56:36 peter Revision 1.37 1998-08-17 09:17:49 peter
* static/shared linking updates
Revision 1.36 1998/08/14 21:56:36 peter
* setting the outputfile using -o works now to create static libs * setting the outputfile using -o works now to create static libs
Revision 1.35 1998/08/12 19:22:09 peter Revision 1.35 1998/08/12 19:22:09 peter

View File

@ -38,7 +38,7 @@ unit pmodules;
uses uses
cobjects,verbose,comphook,systems,globals, cobjects,verbose,comphook,systems,globals,
symtable,aasm,hcodegen, symtable,aasm,hcodegen,
link,assemble,import link,assemble,import,gendef
{$ifndef OLDPPU} {$ifndef OLDPPU}
,ppu ,ppu
{$endif OLDPPU} {$endif OLDPPU}
@ -50,17 +50,38 @@ unit pmodules;
{$endif} {$endif}
,scanner,pbase,psystem,pdecl,psub,parser; ,scanner,pbase,psystem,pdecl,psub,parser;
procedure create_objectfile;
procedure setlinkerfile;
begin begin
{ Add Object File } { create the .s file and assemble it }
if (cs_smartlink in aktmoduleswitches) then GenerateAsm;
current_module^.linkstaticlibs.insert(current_module^.libfilename^)
{ When creating a library call the linker. And insert the output
of the linker files }
if (cs_create_staticlib in aktmoduleswitches) then
Linker.MakeStaticLibrary(SmartLinkFilesCnt)
else
if (cs_create_sharedlib in aktmoduleswitches) then
Linker.MakeSharedLibrary;
{ add the files for the linker from current_module }
Linker.AddModuleFiles(current_module);
end;
procedure insertobjectfile;
{ Insert the used object file for this unit in the used list for this unit }
begin
if (cs_create_staticlib in aktmoduleswitches) then
current_module^.linkstaticlibs.insert(current_module^.staticlibfilename^)
else
if (cs_create_sharedlib in aktmoduleswitches) then
current_module^.linksharedlibs.insert(current_module^.sharedlibfilename^)
else else
current_module^.linkofiles.insert(current_module^.objfilename^); current_module^.linkofiles.insert(current_module^.objfilename^);
end; end;
procedure insertsegment; procedure insertsegment;
procedure fixseg(p:paasmoutput;sec:tsection); procedure fixseg(p:paasmoutput;sec:tsection);
@ -89,6 +110,7 @@ unit pmodules;
fixseg(consts,sec_data); fixseg(consts,sec_data);
end; end;
procedure insertheap; procedure insertheap;
begin begin
if (cs_smartlink in aktmoduleswitches) then if (cs_smartlink in aktmoduleswitches) then
@ -265,7 +287,7 @@ unit pmodules;
begin begin
{ only reassemble ? } { only reassemble ? }
if (current_module^.do_assemble) then if (current_module^.do_assemble) then
OnlyAsm(current_module^.asmfilename^); OnlyAsm;
{ add the files for the linker } { add the files for the linker }
Linker.AddModuleFiles(current_module); Linker.AddModuleFiles(current_module);
end; end;
@ -814,16 +836,7 @@ unit pmodules;
{ a unit compiled at command line must be inside the loaded_unit list } { a unit compiled at command line must be inside the loaded_unit list }
if (compile_level=1) then if (compile_level=1) then
begin loaded_units.insert(current_module);
loaded_units.insert(current_module);
if cs_createlib in initmoduleswitches then
begin
current_module^.flags:=current_module^.flags or uf_in_library;
if cs_shared_lib in initmoduleswitches then
current_module^.flags:=current_module^.flags or uf_shared_library;
end;
end;
{ insert qualifier for the system unit (allows system.writeln) } { insert qualifier for the system unit (allows system.writeln) }
if not(cs_compilesystem in aktmoduleswitches) then if not(cs_compilesystem in aktmoduleswitches) then
@ -971,9 +984,6 @@ unit pmodules;
{$endif dummy} {$endif dummy}
consume(POINT); consume(POINT);
{ add files which need to be linked }
setlinkerfile;
{ size of the static data } { size of the static data }
datasize:=symtablestack^.datasize; datasize:=symtablestack^.datasize;
@ -983,12 +993,12 @@ unit pmodules;
{$ifdef GDB} {$ifdef GDB}
{ add all used definitions even for implementation} { add all used definitions even for implementation}
if (cs_debuginfo in aktmoduleswitches) then if (cs_debuginfo in aktmoduleswitches) then
begin begin
{ all types } { all types }
punitsymtable(symtablestack)^.concattypestabto(debuglist); punitsymtable(symtablestack)^.concattypestabto(debuglist);
{ and all local symbols} { and all local symbols}
symtablestack^.concatstabto(debuglist); symtablestack^.concatstabto(debuglist);
end; end;
{$endif GDB} {$endif GDB}
current_module^.in_implementation:=false; current_module^.in_implementation:=false;
@ -1001,6 +1011,10 @@ unit pmodules;
symtablestack^.symtabletype:=unitsymtable; symtablestack^.symtabletype:=unitsymtable;
punitsymtable(symtablestack)^.is_stab_written:=false; punitsymtable(symtablestack)^.is_stab_written:=false;
{ insert own objectfile }
insertobjectfile;
{Write out the unit if the compile was succesfull.} {Write out the unit if the compile was succesfull.}
if status.errorcount=0 then if status.errorcount=0 then
writeunitas(current_module^.ppufilename^,punitsymtable(symtablestack)); writeunitas(current_module^.ppufilename^,punitsymtable(symtablestack));
@ -1013,12 +1027,21 @@ unit pmodules;
end; end;
inc(datasize,symtablestack^.datasize); inc(datasize,symtablestack^.datasize);
{ leave when we got an error }
if status.errorcount>0 then
exit;
{ generate imports } { generate imports }
if current_module^.uses_imports then if current_module^.uses_imports then
importlib^.generatelib; importlib^.generatelib;
{ finish asmlist by adding segment starts } { finish asmlist by adding segment starts }
insertsegment; insertsegment;
{ assemble }
create_objectfile;
end; end;
@ -1122,7 +1145,10 @@ unit pmodules;
consume(POINT); consume(POINT);
setlinkerfile; { leave when we got an error }
if status.errorcount>0 then
exit;
{ insert heap } { insert heap }
insertheap; insertheap;
@ -1137,12 +1163,32 @@ unit pmodules;
{ finish asmlist by adding segment starts } { finish asmlist by adding segment starts }
insertsegment; insertsegment;
{ insert own objectfile }
insertobjectfile;
{ assemble and link }
create_objectfile;
{ create the executable when we are at level 1 }
if (compile_level=1) then
begin
if (cs_link_deffile in aktglobalswitches) then
deffile.writefile;
if (not current_module^.is_unit) then
Linker.MakeExecutable;
end;
end; end;
end. end.
{ {
$Log$ $Log$
Revision 1.39 1998-08-14 21:56:37 peter Revision 1.40 1998-08-17 09:17:50 peter
* static/shared linking updates
Revision 1.39 1998/08/14 21:56:37 peter
* setting the outputfile using -o works now to create static libs * setting the outputfile using -o works now to create static libs
Revision 1.38 1998/08/10 14:50:13 peter Revision 1.38 1998/08/10 14:50:13 peter

View File

@ -88,14 +88,16 @@ const
ibwidestringdef = 56; ibwidestringdef = 56;
{ unit flags } { unit flags }
uf_init = $1; uf_init = $1;
uf_has_dbx = $2; uf_finalize = $2;
uf_has_browser = $4; uf_big_endian = $4;
uf_big_endian = $8; uf_has_dbx = $8;
uf_in_library = $10; uf_has_browser = $10;
uf_shared_library = $20; uf_smartlink = $20;
uf_smartlink = $40; uf_in_library = $40; { is the file in another file than <ppufile>.* ? }
uf_finalize = $80; uf_static_linked = $80;
uf_shared_linked = $100;
type type
{$ifdef m68k} {$ifdef m68k}
@ -760,7 +762,10 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.8 1998-08-11 15:31:40 peter Revision 1.9 1998-08-17 09:17:51 peter
* static/shared linking updates
Revision 1.8 1998/08/11 15:31:40 peter
* write extended to ppu file * write extended to ppu file
* new version 0.99.7 * new version 0.99.7

View File

@ -180,12 +180,20 @@
{ create unit flags } { create unit flags }
with Current_Module^ do with Current_Module^ do
begin begin
if cs_smartlink in aktmoduleswitches then if cs_create_staticlib in aktmoduleswitches then
begin begin
flags:=flags or uf_smartlink; flags:=flags or uf_static_linked;
if SplitName(ppufilename^)<>SplitName(libfilename^) then if SplitName(ppufilename^)<>SplitName(staticlibfilename^) then
flags:=flags or uf_in_library; flags:=flags or uf_in_library;
end; end;
if cs_create_sharedlib in aktmoduleswitches then
begin
flags:=flags or uf_shared_linked;
if SplitName(ppufilename^)<>SplitName(sharedlibfilename^) then
flags:=flags or uf_in_library;
end;
if cs_smartlink in aktmoduleswitches then
flags:=flags or uf_smartlink;
if use_dbx then if use_dbx then
flags:=flags or uf_has_dbx; flags:=flags or uf_has_dbx;
if target_os.endian=en_big_endian then if target_os.endian=en_big_endian then
@ -315,7 +323,7 @@
procedure readsourcefiles; procedure readsourcefiles;
var var
temp,hs : string; temp,hs : string;
incfile_found : boolean; { incfile_found : boolean; }
ppufiletime, ppufiletime,
source_time : longint; source_time : longint;
{$ifdef UseBrowser} {$ifdef UseBrowser}
@ -344,18 +352,23 @@
begin begin
{ check the date of the source files } { check the date of the source files }
Source_Time:=GetNamedFileTime(current_module^.path^+hs); Source_Time:=GetNamedFileTime(current_module^.path^+hs);
if Source_Time=-1 then { search for include files in the includepathlist, this
can't be done, becuase a .inc file with the same name as
used by a unit will cause the unit to recompile which is
not the intention (PFV) }
{ if Source_Time=-1 then
begin begin
{ search for include files in the includepathlist }
temp:=search(hs,includesearchpath,incfile_found); temp:=search(hs,includesearchpath,incfile_found);
if incfile_found then if incfile_found then
begin begin
hs:=temp+hs; hs:=temp+hs;
Source_Time:=GetNamedFileTime(hs); Source_Time:=GetNamedFileTime(hs);
end; end;
end end
else
hs:=current_module^.path^+hs; else }
hs:=current_module^.path^+hs;
if Source_Time=-1 then if Source_Time=-1 then
begin begin
current_module^.sources_avail:=false; current_module^.sources_avail:=false;
@ -697,7 +710,10 @@
{ {
$Log$ $Log$
Revision 1.11 1998-08-16 20:32:49 peter Revision 1.12 1998-08-17 09:17:53 peter
* static/shared linking updates
Revision 1.11 1998/08/16 20:32:49 peter
* crcs of used units are not important for the current crc, reduces the * crcs of used units are not important for the current crc, reduces the
amount of recompiles amount of recompiles

View File

@ -99,7 +99,6 @@ unit systems;
); );
tosinfo = record tosinfo = record
name : string[30]; name : string[30];
sharedlibext, sharedlibext,
@ -108,6 +107,7 @@ unit systems;
pasext, pasext,
exeext, exeext,
scriptext : string[4]; scriptext : string[4];
libprefix : string[3];
Cprefix : string[2]; Cprefix : string[2];
newline : string[2]; newline : string[2];
endian : tendian; endian : tendian;
@ -205,6 +205,7 @@ implementation
pasext : '.PAS'; pasext : '.PAS';
exeext : ''; { No .exe, the linker only output a.out ! } exeext : ''; { No .exe, the linker only output a.out ! }
scriptext : '.BAT'; scriptext : '.BAT';
libprefix : '';
Cprefix : '_'; Cprefix : '_';
newline : #13#10; newline : #13#10;
endian : endian_little; endian : endian_little;
@ -218,6 +219,7 @@ implementation
pasext : '.PAS'; pasext : '.PAS';
exeext : '.EXE'; exeext : '.EXE';
scriptext : '.BAT'; scriptext : '.BAT';
libprefix : '';
Cprefix : '_'; Cprefix : '_';
newline : #13#10; newline : #13#10;
endian : endian_little; endian : endian_little;
@ -231,6 +233,7 @@ implementation
pasext : '.pas'; pasext : '.pas';
exeext : ''; exeext : '';
scriptext : '.sh'; scriptext : '.sh';
libprefix : 'lib';
Cprefix : ''; Cprefix : '';
newline : #10; newline : #10;
endian : endian_little; endian : endian_little;
@ -244,6 +247,7 @@ implementation
pasext : '.pp'; pasext : '.pp';
exeext : '.exe'; exeext : '.exe';
scriptext : '.cmd'; scriptext : '.cmd';
libprefix : '';
Cprefix : '_'; Cprefix : '_';
newline : #13#10; newline : #13#10;
endian : endian_little; endian : endian_little;
@ -257,6 +261,7 @@ implementation
pasext : '.pas'; pasext : '.pas';
exeext : '.exe'; exeext : '.exe';
scriptext : '.bat'; scriptext : '.bat';
libprefix : 'lib';
Cprefix : '_'; Cprefix : '_';
newline : #13#10; newline : #13#10;
endian : endian_little; endian : endian_little;
@ -272,6 +277,7 @@ implementation
pasext : '.pas'; pasext : '.pas';
exeext : ''; exeext : '';
scriptext : ''; scriptext : '';
libprefix : '';
Cprefix : ''; Cprefix : '';
newline : #10; newline : #10;
endian : en_big_endian; endian : en_big_endian;
@ -285,6 +291,7 @@ implementation
pasext : '.pas'; pasext : '.pas';
exeext : '.tpp'; exeext : '.tpp';
scriptext : ''; scriptext : '';
libprefix : '';
Cprefix : ''; Cprefix : '';
newline : #10; newline : #10;
endian : en_big_endian; endian : en_big_endian;
@ -298,6 +305,7 @@ implementation
pasext : '.pas'; pasext : '.pas';
exeext : '.tpp'; exeext : '.tpp';
scriptext : ''; scriptext : '';
libprefix : '';
Cprefix : ''; Cprefix : '';
newline : #13; newline : #13;
endian : en_big_endian; endian : en_big_endian;
@ -311,6 +319,7 @@ implementation
pasext : '.pas'; pasext : '.pas';
exeext : ''; exeext : '';
scriptext : '.sh'; scriptext : '.sh';
libprefix : 'lib';
Cprefix : ''; Cprefix : '';
newline : #10; newline : #10;
endian : en_big_endian; endian : en_big_endian;
@ -866,7 +875,10 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.23 1998-06-25 08:48:20 florian Revision 1.24 1998-08-17 09:17:54 peter
* static/shared linking updates
Revision 1.23 1998/06/25 08:48:20 florian
* first version of rtti support * first version of rtti support
Revision 1.22 1998/06/17 14:10:21 peter Revision 1.22 1998/06/17 14:10:21 peter