* fixed placing of .sl directories

* use -b again for base-file selection
  * fixed group writing for linux with smartlinking
This commit is contained in:
peter 2000-01-11 09:52:06 +00:00
parent 9e78512a5e
commit 6607475609
7 changed files with 119 additions and 77 deletions

View File

@ -77,11 +77,12 @@ type
procedure WriteAsmList;virtual; procedure WriteAsmList;virtual;
end; end;
var
SmartLinkFilesCnt : longint;
Procedure GenerateAsm(smart:boolean); Procedure GenerateAsm(smart:boolean);
Procedure OnlyAsm; Procedure OnlyAsm;
var
SmartLinkFilesCnt : longint;
Implementation Implementation
@ -267,6 +268,8 @@ begin
end; end;
AsmFile:=Path+FixFileName(s+tostr(SmartLinkFilesCnt)+target_info.asmext); AsmFile:=Path+FixFileName(s+tostr(SmartLinkFilesCnt)+target_info.asmext);
ObjFile:=Path+FixFileName(s+tostr(SmartLinkFilesCnt)+target_info.objext); ObjFile:=Path+FixFileName(s+tostr(SmartLinkFilesCnt)+target_info.objext);
{ insert in container so it can be cleared after the linking }
SmartLinkOFiles.Insert(Objfile);
end; end;
@ -435,13 +438,14 @@ begin
name:=FixFileName(current_module^.modulename^); name:=FixFileName(current_module^.modulename^);
OutCnt:=0; OutCnt:=0;
SmartLinkFilesCnt:=0; SmartLinkFilesCnt:=0;
SmartLinkOFiles.Clear;
place:=cut_normal; place:=cut_normal;
SmartAsm:=smart; SmartAsm:=smart;
SmartHCount:=0; SmartHCount:=0;
{ Which path will be used ? } { Which path will be used ? }
if SmartAsm then if SmartAsm then
begin begin
path:=current_module^.path^+FixFileName(current_module^.modulename^)+target_info.smartext; path:=current_module^.outputpath^+FixFileName(current_module^.modulename^)+target_info.smartext;
{$I-} {$I-}
mkdir(path); mkdir(path);
{$I+} {$I+}
@ -449,7 +453,7 @@ begin
path:=FixPath(path,false); path:=FixPath(path,false);
end end
else else
path:=current_module^.path^; path:=current_module^.outputpath^;
end; end;
@ -560,11 +564,15 @@ begin
dispose(a,Done); dispose(a,Done);
end; end;
end. end.
{ {
$Log$ $Log$
Revision 1.59 2000-01-07 01:14:19 peter Revision 1.60 2000-01-11 09:52:06 peter
* fixed placing of .sl directories
* use -b again for base-file selection
* fixed group writing for linux with smartlinking
Revision 1.59 2000/01/07 01:14:19 peter
* updated copyright to 2000 * updated copyright to 2000
Revision 1.58 1999/11/12 11:03:49 peter Revision 1.58 1999/11/12 11:03:49 peter

View File

@ -206,6 +206,7 @@ unit files;
locallibrarysearchpath : TSearchPathList; locallibrarysearchpath : TSearchPathList;
path, { path where the module is find/created } path, { path where the module is find/created }
outputpath, { path where the .s / .o / exe are created }
modulename, { name of the module in uppercase } modulename, { name of the module in uppercase }
objfilename, { fullname of the objectfile } objfilename, { fullname of the objectfile }
asmfilename, { fullname of the assemblerfile } asmfilename, { fullname of the assemblerfile }
@ -252,13 +253,15 @@ unit files;
end; end;
var var
main_module : pmodule; { Main module of the program } main_module : pmodule; { Main module of the program }
current_module : pmodule; { Current module which is compiled or loaded } current_module : pmodule; { Current module which is compiled or loaded }
compiled_module : pmodule; { Current module which is compiled } compiled_module : pmodule; { Current module which is compiled }
current_ppu : pppufile; { Current ppufile which is read } current_ppu : pppufile; { Current ppufile which is read }
global_unit_count : word; global_unit_count : word;
usedunits : tlinkedlist; { Used units for this program } usedunits : tlinkedlist; { Used units for this program }
loaded_units : tlinkedlist; { All loaded units } loaded_units : tlinkedlist; { All loaded units }
SmartLinkOFiles : TStringContainer; { List of .o files which are generated,
used to delete them after linking }
function get_source_file(moduleindex,fileindex : word) : pinputfile; function get_source_file(moduleindex,fileindex : word) : pinputfile;
@ -811,6 +814,7 @@ end;
stringdispose(staticlibfilename); stringdispose(staticlibfilename);
stringdispose(sharedlibfilename); stringdispose(sharedlibfilename);
stringdispose(exefilename); stringdispose(exefilename);
stringdispose(outputpath);
stringdispose(path); stringdispose(path);
{ Create names } { Create names }
fsplit(fn,p,n,e); fsplit(fn,p,n,e);
@ -827,6 +831,7 @@ end;
if (OutputExeDir<>'') then if (OutputExeDir<>'') then
p:=OutputExeDir; p:=OutputExeDir;
end; end;
outputpath:=stringdup(p);
objfilename:=stringdup(p+n+target_info.objext); objfilename:=stringdup(p+n+target_info.objext);
asmfilename:=stringdup(p+n+target_info.asmext); asmfilename:=stringdup(p+n+target_info.asmext);
ppufilename:=stringdup(p+n+target_info.unitext); ppufilename:=stringdup(p+n+target_info.unitext);
@ -1186,6 +1191,7 @@ end;
{$else} {$else}
asmprefix:=stringdup(FixFileName(n)); asmprefix:=stringdup(FixFileName(n));
{$endif} {$endif}
outputpath:=nil;
path:=nil; path:=nil;
setfilename(p+n,true); setfilename(p+n,true);
localunitsearchpath.init; localunitsearchpath.init;
@ -1273,6 +1279,7 @@ end;
stringdispose(staticlibfilename); stringdispose(staticlibfilename);
stringdispose(sharedlibfilename); stringdispose(sharedlibfilename);
stringdispose(exefilename); stringdispose(exefilename);
stringdispose(outputpath);
stringdispose(path); stringdispose(path);
stringdispose(modulename); stringdispose(modulename);
stringdispose(mainsource); stringdispose(mainsource);
@ -1348,7 +1355,12 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.112 2000-01-07 01:14:27 peter Revision 1.113 2000-01-11 09:52:06 peter
* fixed placing of .sl directories
* use -b again for base-file selection
* fixed group writing for linux with smartlinking
Revision 1.112 2000/01/07 01:14:27 peter
* updated copyright to 2000 * updated copyright to 2000
Revision 1.111 1999/12/08 01:01:11 peter Revision 1.111 1999/12/08 01:01:11 peter

View File

@ -63,7 +63,7 @@ Type
procedure SetDefaultInfo;virtual; procedure SetDefaultInfo;virtual;
Function MakeExecutable:boolean;virtual; Function MakeExecutable:boolean;virtual;
Function MakeSharedLibrary:boolean;virtual; Function MakeSharedLibrary:boolean;virtual;
Function MakeStaticLibrary(filescnt:longint):boolean;virtual; Function MakeStaticLibrary:boolean;virtual;
end; end;
Var Var
@ -173,7 +173,16 @@ begin
if (cs_link_static in aktglobalswitches) then if (cs_link_static in aktglobalswitches) then
begin begin
if (flags and uf_static_linked)=0 then if (flags and uf_static_linked)=0 then
Comment(V_Error,'unit '+modulename^+' can''t be static linked') begin
{ if smart not avail then try static linking }
if (flags and uf_static_linked)<>0 then
begin
Comment(V_Hint,'unit '+modulename^+' can''t be static linked, switching to smart linking');
mask:=mask or link_smart;
end
else
Comment(V_Error,'unit '+modulename^+' can''t be smart or static linked');
end
else else
mask:=mask or link_static; mask:=mask or link_static;
end; end;
@ -185,7 +194,7 @@ begin
{ if smart not avail then try static linking } { if smart not avail then try static linking }
if (flags and uf_static_linked)<>0 then if (flags and uf_static_linked)<>0 then
begin begin
Comment(V_Warning,'unit '+modulename^+' can''t be smart linked, switching to static linking'); Comment(V_Hint,'unit '+modulename^+' can''t be smart linked, switching to static linking');
mask:=mask or link_static; mask:=mask or link_static;
end end
else else
@ -202,7 +211,7 @@ begin
{ if shared not avail then try static linking } { if shared not avail then try static linking }
if (flags and uf_static_linked)<>0 then if (flags and uf_static_linked)<>0 then
begin begin
Comment(V_Warning,'unit '+modulename^+' can''t be shared linked, switching to static linking'); Comment(V_Hint,'unit '+modulename^+' can''t be shared linked, switching to static linking');
mask:=mask or link_static; mask:=mask or link_static;
end end
else else
@ -412,11 +421,7 @@ begin
end; end;
Function TLinker.MakeStaticLibrary(filescnt:longint):boolean; Function TLinker.MakeStaticLibrary:boolean;
{
FilesCnt holds the amount of .o files created, if filescnt=0 then
no smartlinking is used
}
var var
smartpath, smartpath,
cmdstr, cmdstr,
@ -426,38 +431,24 @@ var
begin begin
MakeStaticLibrary:=false; MakeStaticLibrary:=false;
smartpath:=current_module^.path^+FixPath(FixFileName(current_module^.modulename^)+target_info.smartext,false); smartpath:=current_module^.outputpath^+FixPath(FixFileName(current_module^.modulename^)+target_info.smartext,false);
SplitBinCmd(target_ar.arcmd,binstr,cmdstr); SplitBinCmd(target_ar.arcmd,binstr,cmdstr);
Replace(cmdstr,'$LIB',current_module^.staticlibfilename^); Replace(cmdstr,'$LIB',current_module^.staticlibfilename^);
if filescnt=0 then Replace(cmdstr,'$FILES',FixFileName(smartpath+current_module^.asmprefix^+'*'+target_info.objext));
Replace(cmdstr,'$FILES',current_module^.objfilename^)
else
Replace(cmdstr,'$FILES',FixFileName(smartpath+current_module^.asmprefix^+'*'+target_info.objext));
success:=DoExec(FindUtil(binstr),cmdstr,false,true); success:=DoExec(FindUtil(binstr),cmdstr,false,true);
{ Clean up } { Clean up }
if not(cs_asm_leave in aktglobalswitches) then if not(cs_asm_leave in aktglobalswitches) then
if not(cs_link_extern in aktglobalswitches) then if not(cs_link_extern in aktglobalswitches) then
begin begin
if filescnt=0 then while not SmartLinkOFiles.Empty do
RemoveFile(current_module^.objfilename^) RemoveFile(SmartLinkOFiles.Get);
else RemoveDir(smartpath);
begin
for cnt:=1 to filescnt do
if not RemoveFile(FixFileName(smartpath+current_module^.asmprefix^+tostr(cnt)+target_info.objext)) then
RemoveFile(FixFileName(smartpath+current_module^.asmprefix^+'e'+tostr(cnt)+target_info.objext));
RemoveDir(smartpath);
end;
end end
else else
begin begin
if filescnt=0 then AsmRes.AddDeleteCommand(FixFileName(smartpath+current_module^.asmprefix^+'*'+target_info.objext));
AsmRes.AddDeleteCommand(current_module^.objfilename^) AsmRes.Add('rmdir '+smartpath);
else
begin
AsmRes.AddDeleteCommand(smartpath+current_module^.asmprefix^+'*'+target_info.objext);
AsmRes.Add('rmdir '+smartpath);
end;
end; end;
MakeStaticLibrary:=success; MakeStaticLibrary:=success;
end; end;
@ -530,7 +521,12 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.79 2000-01-07 01:14:27 peter Revision 1.80 2000-01-11 09:52:06 peter
* fixed placing of .sl directories
* use -b again for base-file selection
* fixed group writing for linux with smartlinking
Revision 1.79 2000/01/07 01:14:27 peter
* updated copyright to 2000 * updated copyright to 2000
Revision 1.78 1999/11/22 22:22:30 pierre Revision 1.78 1999/11/22 22:22:30 pierre

View File

@ -116,6 +116,9 @@ unit parser;
{ open deffile } { open deffile }
DefFile.Init(outputexedir+inputfile+target_os.defext); DefFile.Init(outputexedir+inputfile+target_os.defext);
{ list of generated .o files, so the linker can remove them }
SmartLinkOFiles.init;
end; end;
@ -125,9 +128,12 @@ unit parser;
loaded_units.done; loaded_units.done;
usedunits.done; usedunits.done;
{ close ppas and deffile } { close ppas,deffile }
asmres.done; asmres.done;
deffile.done; deffile.done;
{ free list of .o files }
SmartLinkOFiles.done;
end; end;
@ -581,7 +587,12 @@ unit parser;
end. end.
{ {
$Log$ $Log$
Revision 1.96 2000-01-07 01:14:28 peter Revision 1.97 2000-01-11 09:52:06 peter
* fixed placing of .sl directories
* use -b again for base-file selection
* fixed group writing for linux with smartlinking
Revision 1.96 2000/01/07 01:14:28 peter
* updated copyright to 2000 * updated copyright to 2000
Revision 1.95 2000/01/04 15:15:52 florian Revision 1.95 2000/01/04 15:15:52 florian

View File

@ -76,7 +76,7 @@ unit pmodules;
GenerateAsm(true); GenerateAsm(true);
if target_asm.needar then if target_asm.needar then
Linker^.MakeStaticLibrary(SmartLinkFilesCnt); Linker^.MakeStaticLibrary;
end; end;
{ resource files } { resource files }
@ -1561,7 +1561,12 @@ unit pmodules;
end. end.
{ {
$Log$ $Log$
Revision 1.178 2000-01-07 01:14:29 peter Revision 1.179 2000-01-11 09:52:07 peter
* fixed placing of .sl directories
* use -b again for base-file selection
* fixed group writing for linux with smartlinking
Revision 1.178 2000/01/07 01:14:29 peter
* updated copyright to 2000 * updated copyright to 2000
Revision 1.177 1999/12/20 22:29:26 pierre Revision 1.177 1999/12/20 22:29:26 pierre

View File

@ -310,6 +310,7 @@ begin
s:=librarysearchpath.FindFile('crtn.o',found)+'crtn.o'; s:=librarysearchpath.FindFile('crtn.o',found)+'crtn.o';
if found then if found then
LinkRes.AddFileName(s); LinkRes.AddFileName(s);
LinkRes.Add(')');
{ Write staticlibraries } { Write staticlibraries }
if not StaticLibFiles.Empty then if not StaticLibFiles.Empty then
@ -325,29 +326,32 @@ begin
{ Write sharedlibraries like -l<lib>, also add the needed dynamic linker { Write sharedlibraries like -l<lib>, also add the needed dynamic linker
here to be sure that it gets linked this is needed for glibc2 systems (PFV) } here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
While not SharedLibFiles.Empty do if not SharedLibFiles.Empty then
begin begin
S:=SharedLibFiles.Get; LinkRes.Add('INPUT(');
if s<>'c' then While not SharedLibFiles.Empty do
begin begin
i:=Pos(target_os.sharedlibext,S); S:=SharedLibFiles.Get;
if i>0 then if s<>'c' then
Delete(S,i,255); begin
LinkRes.Add('-l'+s); i:=Pos(target_os.sharedlibext,S);
end if i>0 then
else Delete(S,i,255);
begin LinkRes.Add('-l'+s);
linklibc:=true; end
linkdynamic:=false; { libc will include the ld-linux for us } else
begin
linklibc:=true;
linkdynamic:=false; { libc will include the ld-linux for us }
end;
end; end;
{ be sure that libc is the last lib }
if linklibc then
LinkRes.Add('-lc');
if linkdynamic and (Info.DynamicLinker<>'') then
LinkRes.AddFileName(Info.DynamicLinker);
LinkRes.Add(')');
end; end;
{ be sure that libc is the last lib }
if linklibc then
LinkRes.Add('-lc');
if linkdynamic and (Info.DynamicLinker<>'') then
LinkRes.AddFileName(Info.DynamicLinker);
LinkRes.Add(')');
{ Write and Close response } { Write and Close response }
linkres.writetodisk; linkres.writetodisk;
linkres.done; linkres.done;
@ -435,7 +439,12 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.7 2000-01-09 00:55:51 pierre Revision 1.8 2000-01-11 09:52:07 peter
* fixed placing of .sl directories
* use -b again for base-file selection
* fixed group writing for linux with smartlinking
Revision 1.7 2000/01/09 00:55:51 pierre
* GROUP of smartlink units put before the C libraries * GROUP of smartlink units put before the C libraries
to allow for smartlinking code that uses C code. to allow for smartlinking code that uses C code.

View File

@ -749,10 +749,8 @@ begin
StripStr:=''; StripStr:='';
AsBinStr:=FindExe('asw',found); AsBinStr:=FindExe('asw',found);
if RelocSection then if RelocSection then
RelocStr:='--base-file base.$$$'; { Using short form to avoid problems with 128 char limitation under Dos. }
{ Using short form to avoid problems with 128 char limitation under Dos. RelocStr:='-b base.$$$';
But not all dlltool.exe support this short form
RelocStr:='-b base.$$$'; }
if apptype=at_gui then if apptype=at_gui then
AppTypeStr:='--subsystem windows'; AppTypeStr:='--subsystem windows';
if assigned(DLLImageBase) then if assigned(DLLImageBase) then
@ -831,10 +829,8 @@ begin
StripStr:=''; StripStr:='';
AsBinStr:=FindExe('asw',found); AsBinStr:=FindExe('asw',found);
if RelocSection then if RelocSection then
RelocStr:='--base-file base.$$$'; { Using short form to avoid problems with 128 char limitation under Dos. }
{ Using short form to avoid problems with 128 char limitation under Dos. RelocStr:='-b base.$$$';
But not all dlltool.exe support this short form
RelocStr:='-b base.$$$'; }
if apptype=at_gui then if apptype=at_gui then
AppTypeStr:='--subsystem windows'; AppTypeStr:='--subsystem windows';
if assigned(DLLImageBase) then if assigned(DLLImageBase) then
@ -1083,7 +1079,12 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.16 2000-01-09 00:55:51 pierre Revision 1.17 2000-01-11 09:52:07 peter
* fixed placing of .sl directories
* use -b again for base-file selection
* fixed group writing for linux with smartlinking
Revision 1.16 2000/01/09 00:55:51 pierre
* GROUP of smartlink units put before the C libraries * GROUP of smartlink units put before the C libraries
to allow for smartlinking code that uses C code. to allow for smartlinking code that uses C code.