Przeglądaj źródła

* 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 -

Jonas Maebe 10 lat temu
rodzic
commit
3946971c73

+ 19 - 0
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

+ 5 - 0
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}

+ 6 - 0
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);