Merged revisions 3894 via svnmerge from

svn+ssh://marco@svn.freepascal.org/FPC/svn/fpc/trunk

........
r3894 | marco | 2006-06-19 16:17:45 +0200 (Mon, 19 Jun 2006) | 3 lines

 * Link ordering working FreeBSD implementation


........

git-svn-id: branches/fixes_2_0@3919 -
This commit is contained in:
marco 2006-06-21 20:40:35 +00:00
parent 16cdc956c1
commit d75793a0f1
4 changed files with 29 additions and 15 deletions

View File

@ -352,7 +352,7 @@ type
end;
Const WeightDefault = 100;
Const WeightDefault = 1000;
Type
TLinkRec = record
@ -2417,7 +2417,7 @@ end;
function TLinkStrMap.AddWeight(keyvalue:String):boolean;
var i : Longint;
var i,j : Longint;
Code : Word;
s : AnsiString;
@ -2427,10 +2427,10 @@ begin
if i=0 then
exit;
s:=Copy(KeyValue,i+1,length(KeyValue)-i);
val(s,i,code);
if code<>0 Then
val(s,j,code);
if code=0 Then
begin
Add(Copy(KeyValue,1,i-1),'',i);
Add(Copy(KeyValue,1,i-1),'',j);
AddWeight:=True;
end;
end;
@ -2444,7 +2444,7 @@ begin
while i<=k do
begin
j:=i;
while (i<=k) and (keys[i]<>';') do
while (i<=k) and (keys[i]<>',') do
inc(i);
add(copy(keys,j,i-j),'',weight);
inc(i);
@ -2480,7 +2480,8 @@ begin
lookup:=-1;
i:=0;
{$B-}
while (i<itemcnt) and (fmap[i].key<>key) do inc(i);
while (i<itemcnt) and (fmap[i].key<>key) do
inc(i);
{$B+}
if i<>itemcnt then
lookup:=i;
@ -2525,7 +2526,6 @@ begin
dest.add(LibN)
else
dest.addseries(fmap[r].value);
end;
end;
@ -2543,3 +2543,4 @@ end;
end.

View File

@ -128,7 +128,7 @@ than 255 characters. That's why using Ansi Strings}
{ linking }
cs_link_extern,cs_link_static,cs_link_smart,cs_link_shared,cs_link_deffile,
cs_link_strip,cs_link_staticflag,cs_link_on_target,cs_link_internal,
cs_link_map,cs_link_pthread
cs_link_map,cs_link_pthread,cs_link_no_default_lib_order
);
tglobalswitches = set of tglobalswitch;

View File

@ -59,6 +59,7 @@ Type
Function MakeStaticLibrary:boolean;virtual;
procedure ExpandAndApplyOrder(var Src:TStringList);
procedure LoadPredefinedLibraryOrder;virtual;
function ReOrderEntries : boolean;
end;
TExternalLinker = class(TLinker)
@ -458,10 +459,11 @@ begin
if (LinkLibraryAliases.count=0) and (LinkLibraryOrder.Count=0) Then
exit;
p:=TLinkStrMap.Create;
// expand libaliases, clears src
LinkLibraryAliases.expand(src,p);
// writeln(src.count,' ',p.count,' ',linklibraryorder.count,' ',linklibraryaliases.count);
// apply order
p.UpdateWeights(LinkLibraryOrder);
p.SortOnWeight;
@ -477,6 +479,12 @@ procedure TLinker.LoadPredefinedLibraryOrder;
begin
end;
function TLinker.ReOrderEntries : boolean;
begin
result:=(LinkLibraryOrder.count>0) or (LinkLibraryAliases.count>0);
end;
{*****************************************************************************
TEXTERNALLINKER
*****************************************************************************}

View File

@ -1188,8 +1188,9 @@ begin
DefaultReplacements(rlinkpath);
More:='';
end;
'L' : begin // -XLO is link order -XLA is link alias
if (j=length(more)) or not ((more[j+1]='O') or (more[j+1]='A')) then
'L' : begin // -XLO is link order -XLA is link alias. -XLD avoids load defaults.
// these are not aggregable.
if (j=length(more)) or not (more[j+1] in ['O','A','D']) then
IllegalPara(opt)
else
begin
@ -1201,11 +1202,15 @@ begin
end;
'O' : begin
s:=Copy(more,3,length(More)-2);
if not LinkLibraryAliases.AddWeight(s) Then
if not LinkLibraryOrder.AddWeight(s) Then
IllegalPara(opt);
end;
end;
end;
'D' : include(initglobalswitches,cs_link_no_default_lib_order)
else
IllegalPara(opt);
end; {case}
j:=length(more);
end; {else begin}
end;
'S' :
begin