From 3946971c7367f6867d0584fe0a926bd7d30dda86 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sat, 14 Mar 2015 18:35:16 +0000 Subject: [PATCH] * default to ppc64le/elfv2 when compiling on a ppc64le platform * default to elfv2 abi when targeting ppc64le and no abi has been specified git-svn-id: trunk@30193 - --- compiler/options.pas | 19 +++++++++++++++++++ compiler/systems/i_linux.pas | 5 +++++ compiler/systems/t_linux.pas | 6 ++++++ 3 files changed, 30 insertions(+) diff --git a/compiler/options.pas b/compiler/options.pas index 13304022f9..d19d03e581 100644 --- a/compiler/options.pas +++ b/compiler/options.pas @@ -36,6 +36,7 @@ Type NoPressEnter, FPCHelpLines, LogoWritten, + ABISetExplicitly, FPUSetExplicitly, CPUSetExplicitly, OptCPUSetExplicitly: boolean; @@ -1115,6 +1116,7 @@ begin s:=upper(copy(more,j+1,length(more)-j)); if not(SetAbiType(s,target_info.abi)) then IllegalPara(opt); + ABISetExplicitly:=true; break; end; @@ -3065,6 +3067,7 @@ begin LogoWritten:=false; NoPressEnter:=false; FirstPass:=false; + ABISetExplicitly:=false; FPUSetExplicitly:=false; CPUSetExplicitly:=false; OptCPUSetExplicitly:=false; @@ -3888,6 +3891,22 @@ if (target_info.abi = abi_eabihf) then end; {$endif} +{$if defined(powerpc64)} + { on sysv targets, default to elfv2 for little endian and to elfv1 for + big endian (unless specified otherwise). As the gcc man page says: + "Overriding the default ABI requires special system support and is + likely to fail in spectacular ways" } + if not option.ABISetExplicitly then + begin + if (target_info.abi=abi_powerpc_sysv) and + (target_info.endian=endian_little) then + target_info.abi:=abi_powerpc_elfv2 + else + if (target_info.abi=abi_powerpc_elfv2) and + (target_info.endian=endian_big) then + target_info.abi:=abi_powerpc_sysv + end; +{$endif} { Section smartlinking conflicts with import sections on Windows } if GenerateImportSection and diff --git a/compiler/systems/i_linux.pas b/compiler/systems/i_linux.pas index 751b81aa3c..0298341800 100644 --- a/compiler/systems/i_linux.pas +++ b/compiler/systems/i_linux.pas @@ -982,6 +982,11 @@ initialization {$ifdef CPUPOWERPC64} {$ifdef linux} set_source_info(system_powerpc64_linux_info); + { on a little endian PPC64 platform -> source is elfv2 } + {$ifdef FPC_LITTLE_ENDIAN} + source_info.endian:=endian_little; + source_info.abi:=abi_powerpc_elfv2; + {$endif} {$endif linux} {$endif CPUPOWERPC64} {$ifdef CPUARM} diff --git a/compiler/systems/t_linux.pas b/compiler/systems/t_linux.pas index bebd8f7e04..6462d90b53 100644 --- a/compiler/systems/t_linux.pas +++ b/compiler/systems/t_linux.pas @@ -1518,6 +1518,12 @@ initialization RegisterTarget(system_powerpc_linux_info); {$endif powerpc} {$ifdef powerpc64} + { default to little endian either when compiling with -dppc64le, or when + compiling on a little endian ppc64 platform } + {$if defined(ppc64le) or (defined(cpupowerpc64) and defined(FPC_LITTLE_ENDIAN))} + system_powerpc64_linux_info.endian:=endian_little; + system_powerpc64_linux_info.abi:=abi_powerpc_elfv2; + {$endif} RegisterImport(system_powerpc64_linux,timportliblinux); RegisterExport(system_powerpc64_linux,texportliblinux); RegisterTarget(system_powerpc64_linux_info);