VLink Support:

* fixed for MorphOS, added for Amiga/m68k
* enabled as default when running natively on these systems (cross still defaults to GNU LD)
* added -XV command line switch to enable/disable it
* dropped the 'fpc' prefix from vlink binary name on MorphOS

git-svn-id: trunk@32324 -
This commit is contained in:
Károly Balogh 2015-11-15 01:18:30 +00:00
parent 017821f5db
commit 3675fc75cb
5 changed files with 50 additions and 17 deletions

View File

@ -196,8 +196,9 @@ interface
cs_link_strip,cs_link_staticflag,cs_link_on_target,cs_link_extern,cs_link_opt_vtable,
cs_link_opt_used_sections,cs_link_separate_dbg_file,
cs_link_map,cs_link_pthread,cs_link_no_default_lib_order,
cs_link_native,
cs_link_pre_binutils_2_19
cs_link_native,
cs_link_pre_binutils_2_19,
cs_link_vlink
);
tglobalswitches = set of tglobalswitch;

View File

@ -3922,6 +3922,7 @@ F*2Xp<x>_First search for the compiler binary in the directory <x>
**2XS_Try to link units statically (default, defines FPC_LINK_STATIC)
**2Xt_Link with static libraries (-static is passed to linker)
**2Xv_Generate table for Virtual Entry calls
**2XV_Use VLink as external linker (default on Amiga, MorphOS)
**2XX_Try to smartlink units (defines FPC_LINK_SMART)
**1*_
**1?_Show this help

View File

@ -2486,6 +2486,16 @@ begin
begin
ForceStaticLinking;
end;
'V' :
begin
If UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_link_vlink)
else
begin
include(init_settings.globalswitches,cs_link_vlink);
include(init_settings.globalswitches,cs_link_extern);
end;
end;
'X' :
begin
def_system_macro('FPC_LINK_SMART');
@ -3686,7 +3696,14 @@ begin
if not(cs_link_extern in init_settings.globalswitches) and
((target_info.link=ld_none) or
(cs_link_nolink in init_settings.globalswitches)) then
include(init_settings.globalswitches,cs_link_extern);
begin
include(init_settings.globalswitches,cs_link_extern);
{$ifdef hasamiga}
{ enable vlink as default linker on Amiga/MorphOS, but not for cross compilers (for now) }
if target_info.system in [system_m68k_amiga,system_powerpc_amiga,system_powerpc_morphos] then
include(init_settings.globalswitches,cs_link_vlink);
{$endif}
end;
{ turn off stripping if compiling with debuginfo or profile }
if (

View File

@ -34,6 +34,7 @@ type
PLinkerAmiga = ^TLinkerAmiga;
TLinkerAmiga = class(texternallinker)
private
UseVLink: boolean;
function WriteResponseFile(isdll: boolean): boolean;
procedure SetAmiga68kInfo;
procedure SetAmigaPPCInfo;
@ -61,17 +62,28 @@ implementation
constructor TLinkerAmiga.Create;
begin
UseVLink:=(cs_link_vlink in current_settings.globalswitches);
Inherited Create;
{ allow duplicated libs (PM) }
SharedLibFiles.doubles:=true;
StaticLibFiles.doubles:=true;
end;
procedure TLinkerAmiga.SetAmiga68kInfo;
begin
with Info do begin
ExeCmd[1]:='ld $DYNLINK $OPT -d -n -o $EXE $RES';
end;
with Info do
begin
if not UseVLink then
begin
ExeCmd[1]:='ld $DYNLINK $OPT -d -n -o $EXE $RES';
end
else
begin
ExeCmd[1]:='vlink -b amigahunk $OPT $STRIP -o $EXE -T $RES';
end;
end;
end;
procedure TLinkerAmiga.SetAmigaPPCInfo;
@ -131,6 +143,9 @@ begin
s:=ObjectFiles.GetFirst;
if s<>'' then
begin
{ vlink doesn't use SEARCH_DIR for object files }
if UseVLink then
s:=FindObjectFile(s,'',false);
LinkRes.AddFileName(Unix2AmigaPath(maybequoted(s)));
end;
end;
@ -138,8 +153,12 @@ begin
{ Write staticlibraries }
if not StaticLibFiles.Empty then
begin
LinkRes.Add(')');
LinkRes.Add('GROUP(');
{ vlink doesn't need, and doesn't support GROUP }
if not UseVLink then
begin
LinkRes.Add(')');
LinkRes.Add('GROUP(');
end;
while not StaticLibFiles.Empty do
begin
S:=StaticLibFiles.GetFirst;
@ -147,7 +166,7 @@ begin
end;
end;
if (cs_link_on_target in current_settings.globalswitches) then
if not UseVLink then
begin
LinkRes.Add(')');

View File

@ -53,17 +53,12 @@ implementation
Constructor TLinkerMorphOS.Create;
begin
UseVLink:=(cs_link_vlink in current_settings.globalswitches);
Inherited Create;
{ allow duplicated libs (PM) }
SharedLibFiles.doubles:=true;
StaticLibFiles.doubles:=true;
{ TODO: always use vlink on MorphOS for now, but allow ld for cross compiling,
we need a command line switch to switch between vlink and ld later. (KB) }
{$IFDEF MORPHOS}
UseVLink:=true;
{$ELSE}
UseVLink:=(cs_link_on_target in current_settings.globalswitches);
{$ENDIF}
end;
@ -78,7 +73,7 @@ begin
end
else
begin
ExeCmd[1]:='fpcvlink -b elf32amiga $OPT $STRIP -o $EXE -T $RES';
ExeCmd[1]:='vlink -b elf32amiga $OPT $STRIP -o $EXE -T $RES';
end;
end;
end;