+ AIX target definition and info for the compiler and ppudump

git-svn-id: trunk@20790 -
This commit is contained in:
Jonas Maebe 2012-04-11 18:00:29 +00:00
parent 452414e1a7
commit 462de0f5fd
9 changed files with 541 additions and 3 deletions

2
.gitattributes vendored
View File

@ -521,6 +521,7 @@ compiler/symtype.pas svneol=native#text/plain
compiler/symutil.pas svneol=native#text/plain
compiler/systems.inc svneol=native#text/plain
compiler/systems.pas svneol=native#text/plain
compiler/systems/i_aix.pas svneol=native#text/plain
compiler/systems/i_amiga.pas svneol=native#text/plain
compiler/systems/i_atari.pas svneol=native#text/plain
compiler/systems/i_beos.pas svneol=native#text/plain
@ -546,6 +547,7 @@ compiler/systems/i_wdosx.pas svneol=native#text/plain
compiler/systems/i_wii.pas svneol=native#text/plain
compiler/systems/i_win.pas svneol=native#text/plain
compiler/systems/mac_crea.txt svneol=native#text/plain
compiler/systems/t_aix.pas svneol=native#text/plain
compiler/systems/t_amiga.pas svneol=native#text/plain
compiler/systems/t_atari.pas svneol=native#text/plain
compiler/systems/t_beos.pas svneol=native#text/plain

View File

@ -116,6 +116,9 @@ uses
{$ifdef nativent}
,i_nativent
{$endif nativent}
{$ifdef aix}
,i_aix
{$endif aix}
,globtype;
function Compile(const cmd:TCmdStr):longint;

View File

@ -53,6 +53,9 @@ implementation
{$ifndef NOTARGETWII}
,t_wii
{$endif}
{$ifndef NOTARGETAIX}
,t_aix
{$endif}
{**************************************
Assemblers

View File

@ -41,6 +41,9 @@ implementation
{$ifndef NOTARGETBSD}
,t_bsd
{$endif}
{$ifndef NOTARGETAIX}
,t_aix
{$endif}
{**************************************
Assemblers

View File

@ -148,7 +148,9 @@
system_i386_iphonesim, { 69 }
system_powerpc_wii, { 70 }
system_x86_64_openbsd, { 71 }
system_x86_64_netbsd { 72 }
system_x86_64_netbsd, { 72 }
system_powerpc_aix, { 73 }
system_powerpc64_aix { 74 }
);
type
@ -202,7 +204,7 @@
,res_single_file);
tdbg = (dbg_none
,dbg_stabs,dbg_dwarf2,dbg_dwarf3,dbg_dwarf4
,dbg_stabs,dbg_stabx,dbg_dwarf2,dbg_dwarf3,dbg_dwarf4
);
tscripttype = (script_none

View File

@ -227,6 +227,8 @@ interface
systems_bsd = systems_freebsd + systems_netbsd + systems_openbsd;
systems_aix = [system_powerpc_aix,system_powerpc64_aix];
{ all real windows systems, no cripple ones like wince, wdosx et. al. }
systems_windows = [system_i386_win32,system_x86_64_win64,system_ia64_win64];
@ -806,6 +808,10 @@ begin
{$define default_target_set}
{$endif}
{$endif cpupowerpc}
{$ifdef aix}
default_target(system_powerpc_aix);
{$define default_target_set}
{$endif}
{$ifndef default_target_set}
default_target(system_powerpc_linux);
{$endif default_target_set}
@ -824,6 +830,10 @@ begin
default_target(system_powerpc64_linux);
{$define default_target_set}
{$endif}
{$ifdef aix}
default_target(system_powerpc64_aix);
{$define default_target_set}
{$endif}
{$endif cpupowerpc64}
{$ifndef default_target_set}
default_target(system_powerpc64_linux);

169
compiler/systems/i_aix.pas Normal file
View File

@ -0,0 +1,169 @@
{
Copyright (c) 1998-2008 by Peter Vreman
Copyright (c) 2011 by Jonas Maebe
This unit implements support information structures for AIX
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
****************************************************************************
}
unit i_aix;
{$i fpcdefs.inc}
interface
uses
systems, rescmn;
const
system_powerpc_aix_info : tsysteminfo =
(
system : system_powerpc_aix;
name : 'AIX for PowerPC';
shortname : 'AIX';
flags : [tf_files_case_sensitive,tf_requires_proper_alignment,
tf_smartlink_sections,tf_has_winlike_resources];
cpu : cpu_powerpc;
unit_env : '';
extradefines : 'UNIX;HASUNIX';
exeext : '';
defext : '.def';
scriptext : '.sh';
smartext : '.sl';
unitext : '.ppu';
unitlibext : '.ppl';
asmext : '.s';
objext : '.o';
resext : '.res';
resobjext : '.or';
sharedlibext : '.a';
staticlibext : '.a';
staticlibprefix : 'libp';
sharedlibprefix : 'lib';
sharedClibext : '.so';
staticClibext : '.a';
staticClibprefix : 'lib';
sharedClibprefix : 'lib';
importlibprefix : 'libimp';
importlibext : '.a';
Cprefix : '';
newline : #10;
dirsep : '/';
assem : as_powerpc_xcoff;
assemextern : as_powerpc_xcoff;
link : nil;
linkextern : nil;
ar : ar_gnu_ar;
res : res_elf;
dbg : dbg_stabx;
script : script_unix;
endian : endian_big;
alignment :
(
procalign : 4;
loopalign : 4;
jumpalign : 0;
constalignmin : 0;
constalignmax : 4;
varalignmin : 0;
varalignmax : 4;
localalignmin : 4;
localalignmax : 4;
recordalignmin : 0;
recordalignmax : 4;
maxCrecordalign : 8
);
first_parm_offset : 8;
stacksize : 32*1024*1024;
abi : abi_powerpc_aix;
);
system_powerpc64_aix_info : tsysteminfo =
(
system : system_powerpc64_aix;
name : 'AIX for PowerPC64';
shortname : 'AIX';
flags : [tf_needs_symbol_size,tf_needs_symbol_type,tf_files_case_sensitive,
tf_requires_proper_alignment,tf_smartlink_sections,tf_has_winlike_resources];
cpu : cpu_powerpc64;
unit_env : '';
extradefines : 'UNIX;HASUNIX';
exeext : '';
defext : '.def';
scriptext : '.sh';
smartext : '.sl';
unitext : '.ppu';
unitlibext : '.ppl';
asmext : '.s';
objext : '.o';
resext : '.res';
resobjext : '.or';
sharedlibext : '.so';
staticlibext : '.a';
staticlibprefix : 'libp';
sharedlibprefix : 'lib';
sharedClibext : '.so';
staticClibext : '.a';
staticClibprefix : 'lib';
sharedClibprefix : 'lib';
importlibprefix : 'libimp';
importlibext : '.a';
Cprefix : '';
newline : #10;
dirsep : '/';
assem : as_powerpc_xcoff;
assemextern : as_powerpc_xcoff;
link : nil;
linkextern : nil;
ar : ar_gnu_ar;
res : res_elf;
dbg : dbg_stabx;
script : script_unix;
endian : endian_big;
alignment :
(
procalign : 8;
loopalign : 4;
jumpalign : 0;
constalignmin : 4;
constalignmax : 16;
varalignmin : 4;
varalignmax : 16;
localalignmin : 0;
localalignmax : 16;
recordalignmin : 0;
recordalignmax : 16;
maxCrecordalign : 8
);
first_parm_offset : 8;
stacksize : 10*1024*1024;
abi : abi_powerpc_aix
);
implementation
initialization
{$ifdef CPUPOWERPC32}
{$ifdef linux}
set_source_info(system_powerpc_aix_info);
{$endif linux}
{$endif CPUPOWERPC32}
{$ifdef CPUPOWERPC64}
{$ifdef linux}
set_source_info(system_powerpc64_aix_info);
{$endif linux}
{$endif CPUPOWERPC64}
end.

344
compiler/systems/t_aix.pas Normal file
View File

@ -0,0 +1,344 @@
{
Copyright (c) 2011 by Jonas Maebe
This unit implements support import,export,link routines
for the AIX target
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
****************************************************************************
}
unit t_aix;
{$i fpcdefs.inc}
interface
uses
aasmdata,
symsym,symdef,ppu,
import,export,expunix,link;
type
timportlibaix=class(timportlib)
procedure generatelib;override;
end;
texportlibaix=class(texportlibunix)
procedure setfininame(list: TAsmList; const s: string); override;
end;
TLinkerAIX=class(texternallinker)
private
prtobj : string[80];
Function WriteResponseFile(isdll:boolean) : Boolean;
public
constructor Create;override;
procedure SetDefaultInfo;override;
function MakeExecutable:boolean;override;
function MakeSharedLibrary:boolean;override;
end;
implementation
uses
SysUtils,
cutils,cfileutl,cclasses,
verbose,systems,globtype,globals,
symconst,script,
fmodule,
aasmbase,aasmtai,aasmcpu,cpubase,
cgbase,cgobj,cgutils,ogbase,ncgutil,
comprsrc,
rescmn, i_aix
;
{*****************************************************************************
timportlibaix
*****************************************************************************}
procedure timportlibaix.generatelib;
var
i : longint;
ImportLibrary : TImportLibrary;
begin
for i:=0 to current_module.ImportLibraryList.Count-1 do
begin
ImportLibrary:=TImportLibrary(current_module.ImportLibraryList[i]);
current_module.linkothersharedlibs.add(ImportLibrary.Name,link_always);
end;
end;
{*****************************************************************************
texportlibaix
*****************************************************************************}
procedure texportlibaix.setfininame(list: TAsmList; const s: string);
begin
inherited setfininame(list,s);
end;
{*****************************************************************************
TLinkerAIX
*****************************************************************************}
Constructor TLinkerAIX.Create;
begin
Inherited Create;
if not Dontlinkstdlibpath then
if not(cs_profile in current_settings.moduleswitches) then
LibrarySearchPath.AddPath(sysrootpath,'/usr/lib;/usr/X11R6/lib;/opt/freeware/lib',true)
else
LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/profiled;/usr/X11R6/lib;/opt/freeware/lib',true)
end;
procedure TLinkerAIX.SetDefaultInfo;
const
{$ifdef powerpc}platform_select='-b32';{$endif}
{$ifdef POWERPC64} platform_select='-b64';{$endif}
begin
with Info do
begin
ExeCmd[1]:='ld '+platform_select+' $OPT $STRIP -L. -o $EXE $CATRES';
DllCmd[1]:='ld '+platform_select+' $OPT $INITFINI $STRIP -L. -o $EXE $CATRES';
end;
{$if defined(powerpc)}
if not(cs_profile in current_settings.moduleswitches) then
prtobj:=sysrootpath+'/lib/crt0.o'
else
prtobj:=sysrootpath+'/lib/gcrt0.o';
{$elseif defined(powerpc64)}
if not(cs_profile in current_settings.moduleswitches) then
prtobj:=sysrootpath+'/lib/crt0_64.o'
else
prtobj:=sysrootpath+'/lib/gcrt0_64.o';
{$else}
{$error unsupported AIX architecture}
{$endif}
end;
Function TLinkerAIX.WriteResponseFile(isdll:boolean) : Boolean;
Var
linkres : TLinkRes;
i : longint;
HPath : TCmdStrListItem;
s,s1 : TCmdStr;
begin
result:=False;
{ Open link.res file }
LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
with linkres do
begin
{ Write path to search libraries }
HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
while assigned(HPath) do
begin
Add('-L'+HPath.Str);
HPath:=TCmdStrListItem(HPath.Next);
end;
HPath:=TCmdStrListItem(LibrarySearchPath.First);
while assigned(HPath) do
begin
Add('-L'+HPath.Str);
HPath:=TCmdStrListItem(HPath.Next);
end;
{ add objectfiles, start with prt0 always }
AddFileName(maybequoted(FindObjectFile(prtobj,'',false)));
{ main objectfiles }
while not ObjectFiles.Empty do
begin
s:=ObjectFiles.GetFirst;
if s<>'' then
AddFileName(maybequoted(s));
end;
{ Write staticlibraries }
if not StaticLibFiles.Empty then
begin
While not StaticLibFiles.Empty do
begin
S:=StaticLibFiles.GetFirst;
AddFileName(maybequoted(s))
end;
end;
{ Write sharedlibraries like -l<lib> }
While not SharedLibFiles.Empty do
begin
S:=SharedLibFiles.GetFirst;
i:=Pos(target_info.sharedlibext,S);
if i>0 then
Delete(S,i,255);
Add('-l'+s);
end;
{ when we have -static for the linker the we also need libgcc }
if (cs_link_staticflag in current_settings.globalswitches) then
begin
Add('-lgcc');
if librarysearchpath.FindFile('libgcc_eh.a',false,s1) then
Add('-lgcc_eh');
end;
{ Write and Close response }
writetodisk;
Free;
end;
WriteResponseFile:=True;
end;
function TLinkerAIX.MakeExecutable:boolean;
var
linkscript: TAsmScript;
binstr,
cmdstr : TCmdStr;
success : boolean;
StripStr : string[40];
begin
if not(cs_link_nolink in current_settings.globalswitches) then
Message1(exec_i_linking,current_module.exefilename^);
{ Create some replacements }
StripStr:='';
if (cs_link_strip in current_settings.globalswitches) and
not(cs_link_separate_dbg_file in current_settings.globalswitches) then
StripStr:='-s';
if (cs_link_map in current_settings.globalswitches) then
StripStr:='-bmap:'+maybequoted(ChangeFileExt(current_module.exefilename^,'.map'));
{ Write used files and libraries }
WriteResponseFile(false);
{ Call linker }
SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
binstr:=FindUtil(utilsprefix+BinStr);
Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename^));
Replace(cmdstr,'$OPT',Info.ExtraOptions);
Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
Replace(cmdstr,'$STRIP',StripStr);
{ create dynamic symbol table? }
if HasExports then
cmdstr:=cmdstr+' -E';
{ custom sysroot? (for cross-compiling -> assume gnu ld) }
if sysrootpath<>'' then
cmdstr:=cmdstr+' --sysroot='+sysrootpath;
if not(cs_link_nolink in current_settings.globalswitches) and
not(tf_no_backquote_support in source_info.flags) then
begin
{ we have to use a script to use the IFS hack }
linkscript:=TAsmScriptUnix.create(outputexedir+'ppaslink');
linkscript.AddLinkCommand(binstr,CmdStr,'');
// if (extdbgbinstr<>'') then
// linkscript.AddLinkCommand(extdbgbinstr,extdbgcmdstr,'');
linkscript.WriteToDisk;
BinStr:=linkscript.fn;
if not path_absolute(BinStr) then
BinStr:='./'+BinStr;
CmdStr:='';
end;
success:=DoExec(BinStr,cmdstr,true,true);
{ Remove ReponseFile }
if (success) and not(cs_link_nolink in current_settings.globalswitches) then
begin
DeleteFile(outputexedir+Info.ResName);
DeleteFile(outputexedir+'ppaslink.sh');
end;
MakeExecutable:=success; { otherwise a recursive call to link method }
end;
Function TLinkerAIX.MakeSharedLibrary:boolean;
var
exportedsyms: text;
InitFiniStr : string[80];
StripStr,
binstr,
cmdstr : TCmdStr;
success : boolean;
begin
MakeSharedLibrary:=false;
if not(cs_link_nolink in current_settings.globalswitches) then
Message1(exec_i_linking,current_module.sharedlibfilename^);
{ Write used files and libraries }
WriteResponseFile(true);
{ Create some replacements }
InitFiniStr:='-binitfini:'+exportlib.initname+':'+exportlib.fininame;
if cs_link_strip in current_settings.globalswitches then
StripStr:='-s'
else
StripStr:='';
{ Call linker }
SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename^));
Replace(cmdstr,'$OPT',Info.ExtraOptions);
Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
Replace(cmdstr,'$INITFINI',InitFiniStr);
Replace(cmdstr,'$STRIP',StripStr);
success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,false);
{ exported symbols }
if not texportlibunix(exportlib).exportedsymnames.empty then
begin
assign(exportedsyms,outputexedir+'linksyms.fpc');
rewrite(exportedsyms);
repeat
writeln(exportedsyms,texportlibunix(exportlib).exportedsymnames.getfirst);
until texportlibunix(exportlib).exportedsymnames.empty;
close(exportedsyms);
cmdstr:=cmdstr+' -bE:'+maybequoted(outputexedir)+'linksyms.fpc';
end;
{ Remove ReponseFile }
if (success) and not(cs_link_nolink in current_settings.globalswitches) then
begin
DeleteFile(outputexedir+Info.ResName);
DeleteFile(outputexedir+'linksyms.fpc');
end;
MakeSharedLibrary:=success; { otherwise a recursive call to link method }
end;
{*****************************************************************************
Initialize
*****************************************************************************}
initialization
{$ifdef powerpc}
RegisterExternalLinker(system_powerpc_aix_info,TLinkerAIX);
RegisterImport(system_powerpc_aix,timportlibaix);
RegisterExport(system_powerpc_aix,texportlibaix);
RegisterTarget(system_powerpc_aix_info);
{$endif powerpc}
{$ifdef powerpc64}
RegisterExternalLinker(system_powerpc64_aix_info,TLinkerAIX);
RegisterImport(system_powerpc64_aix,timportlibaix);
RegisterExport(system_powerpc64_aix,texportlibaix);
RegisterTarget(system_powerpc64_aix_info);
{$endif powerpc64}
RegisterRes(res_elf_info,TWinLikeResourceFile);
end.

View File

@ -149,7 +149,9 @@ const
{ 69 } 'iPhoneSim-i386',
{ 70 } 'Wii-powerpc',
{ 71 } 'OpenBSD-x86-64',
{ 72 } 'NetBSD-x86-64'
{ 72 } 'NetBSD-x86-64',
{ 73 } 'AIX-powerpc',
{ 74 } 'AIX-powerpc64'
);
const