Re: Bug#807777: ghc: Please adjust linker options for sparc64 (patch supplied)
Hi Joachim!
As per discussion on IRC in #debian-haskell, I have revised my patch
a bit after doing a build test on amd64 which triggered a few warnings
which this new patch eliminates. ghc builds cleanly on amd64 with
my patch applied.
My patch basically is a copy of the patch which added initial platform
support for Alpha, Mipseb and Mipsel upstream [1] minus the part with
the alignment requirement which is not necessary on SPARC and SPARC64
but plus the enforcing of "-no-relax" which is required on SPARC
and SPARC64.
Thus, if you compare my patch with the changes from [1], it should
be obvious that my patch is good and should do the right thing on
sparc64 without the danger of breaking anything else.
Please replace my old patch with the new one. I will also perform
a test build on sparc64 now. However, building on sparc64 is a
tad slower which means we will have to wait several days maybe
so you might as well upload 7.10.3-4 right away with my updated
patch.
Thanks for making me review my changes and test build them!
Adrian
> [1]
https://git.haskell.org/ghc.git/commitdiff/9756690fe7aa26aee6955d0b720377d53170c542
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer - glaubitz@debian.org
`. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Description: Add initial platform support for sparc64
This patch adds initial platform support for sparc64 by mapping
sparc64 to "ArchSPARC64" instead of "ArchUnknown" in aclocal.m4.
Additionally, it adds "ArchSPARC64" to the list of known platforms
in compiler/utils/Platform.hs and various code sections of the
compiler code where the architecture is checked. Finally, it patches
compiler/main/DriverPipeline.hs to explicitly pass "-no-relax" to gcc.
See upstream ticket #11211 and Debian bug #807777.
.
Index: ghc-7.10.3/aclocal.m4
===================================================================
--- ghc-7.10.3.orig/aclocal.m4
+++ ghc-7.10.3/aclocal.m4
@@ -193,6 +193,10 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_V
sparc)
test -z "[$]2" || eval "[$]2=ArchSPARC"
;;
+ sparc64)
+ test -z "[$]2" || eval "[$]2=ArchSPARC64"
+ ;;
+
arm)
GET_ARM_ISA()
test -z "[$]2" || eval "[$]2=\"ArchARM {armISA = \$ARM_ISA, armISAExt = \$ARM_ISA_EXT, armABI = \$ARM_ABI}\""
@@ -209,7 +213,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_V
mipsel)
test -z "[$]2" || eval "[$]2=ArchMipsel"
;;
- hppa|hppa1_1|ia64|m68k|powerpc64le|rs6000|s390|s390x|sh4|sparc64|vax)
+ hppa|hppa1_1|ia64|m68k|powerpc64le|rs6000|s390|s390x|sh4|vax)
test -z "[$]2" || eval "[$]2=ArchUnknown"
;;
*)
Index: ghc-7.10.3/compiler/main/DriverPipeline.hs
===================================================================
--- ghc-7.10.3.orig/compiler/main/DriverPipeline.hs
+++ ghc-7.10.3/compiler/main/DriverPipeline.hs
@@ -2208,6 +2208,7 @@ joinObjectFiles dflags o_files output_fn
-- -r and --relax are incompatible for ld, so
-- disable --relax explicitly.
++ (if platformArch (targetPlatform dflags) == ArchSPARC
+ || platformArch (targetPlatform dflags) == ArchSPARC64
&& ldIsGnuLd
then [SysTools.Option "-Wl,-no-relax"]
else [])
Index: ghc-7.10.3/compiler/nativeGen/AsmCodeGen.hs
===================================================================
--- ghc-7.10.3.orig/compiler/nativeGen/AsmCodeGen.hs
+++ ghc-7.10.3/compiler/nativeGen/AsmCodeGen.hs
@@ -171,6 +171,7 @@ nativeCodeGen dflags this_mod modLoc h u
ArchX86_64 -> nCG' (x86_64NcgImpl dflags)
ArchPPC -> nCG' (ppcNcgImpl dflags)
ArchSPARC -> nCG' (sparcNcgImpl dflags)
+ ArchSPARC64 -> panic "nativeCodeGen: No NCG for SPARC64"
ArchARM {} -> panic "nativeCodeGen: No NCG for ARM"
ArchARM64 -> panic "nativeCodeGen: No NCG for ARM64"
ArchPPC_64 -> panic "nativeCodeGen: No NCG for PPC 64"
Index: ghc-7.10.3/compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs
===================================================================
--- ghc-7.10.3.orig/compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs
+++ ghc-7.10.3/compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs
@@ -111,6 +111,7 @@ trivColorable platform virtualRegSqueeze
ArchX86_64 -> 5
ArchPPC -> 16
ArchSPARC -> 14
+ ArchSPARC64 -> panic "trivColorable ArchSPARC64"
ArchPPC_64 -> panic "trivColorable ArchPPC_64"
ArchARM _ _ _ -> panic "trivColorable ArchARM"
ArchARM64 -> panic "trivColorable ArchARM64"
@@ -136,6 +137,7 @@ trivColorable platform virtualRegSqueeze
ArchX86_64 -> 0
ArchPPC -> 0
ArchSPARC -> 22
+ ArchSPARC64 -> panic "trivColorable ArchSPARC64"
ArchPPC_64 -> panic "trivColorable ArchPPC_64"
ArchARM _ _ _ -> panic "trivColorable ArchARM"
ArchARM64 -> panic "trivColorable ArchARM64"
@@ -161,6 +163,7 @@ trivColorable platform virtualRegSqueeze
ArchX86_64 -> 0
ArchPPC -> 26
ArchSPARC -> 11
+ ArchSPARC64 -> panic "trivColorable ArchSPARC64"
ArchPPC_64 -> panic "trivColorable ArchPPC_64"
ArchARM _ _ _ -> panic "trivColorable ArchARM"
ArchARM64 -> panic "trivColorable ArchARM64"
@@ -186,6 +189,7 @@ trivColorable platform virtualRegSqueeze
ArchX86_64 -> 10
ArchPPC -> 0
ArchSPARC -> 0
+ ArchSPARC64 -> panic "trivColorable ArchSPARC64"
ArchPPC_64 -> panic "trivColorable ArchPPC_64"
ArchARM _ _ _ -> panic "trivColorable ArchARM"
ArchARM64 -> panic "trivColorable ArchARM64"
Index: ghc-7.10.3/compiler/nativeGen/RegAlloc/Linear/FreeRegs.hs
===================================================================
--- ghc-7.10.3.orig/compiler/nativeGen/RegAlloc/Linear/FreeRegs.hs
+++ ghc-7.10.3/compiler/nativeGen/RegAlloc/Linear/FreeRegs.hs
@@ -74,6 +74,7 @@ maxSpillSlots dflags
ArchX86_64 -> X86.Instr.maxSpillSlots dflags
ArchPPC -> PPC.Instr.maxSpillSlots dflags
ArchSPARC -> SPARC.Instr.maxSpillSlots dflags
+ ArchSPARC64 -> panic "maxSpillSlots ArchSPARC64"
ArchARM _ _ _ -> panic "maxSpillSlots ArchARM"
ArchARM64 -> panic "maxSpillSlots ArchARM64"
ArchPPC_64 -> panic "maxSpillSlots ArchPPC_64"
Index: ghc-7.10.3/compiler/nativeGen/RegAlloc/Linear/Main.hs
===================================================================
--- ghc-7.10.3.orig/compiler/nativeGen/RegAlloc/Linear/Main.hs
+++ ghc-7.10.3/compiler/nativeGen/RegAlloc/Linear/Main.hs
@@ -209,6 +209,7 @@ linearRegAlloc dflags entry_ids block_li
ArchX86_64 -> go $ (frInitFreeRegs platform :: X86_64.FreeRegs)
ArchSPARC -> go $ (frInitFreeRegs platform :: SPARC.FreeRegs)
ArchPPC -> go $ (frInitFreeRegs platform :: PPC.FreeRegs)
+ ArchSPARC64 -> panic "linearRegAlloc ArchSPARC64"
ArchARM _ _ _ -> panic "linearRegAlloc ArchARM"
ArchARM64 -> panic "linearRegAlloc ArchARM64"
ArchPPC_64 -> panic "linearRegAlloc ArchPPC_64"
Index: ghc-7.10.3/compiler/nativeGen/TargetReg.hs
===================================================================
--- ghc-7.10.3.orig/compiler/nativeGen/TargetReg.hs
+++ ghc-7.10.3/compiler/nativeGen/TargetReg.hs
@@ -44,6 +44,7 @@ targetVirtualRegSqueeze platform
ArchX86_64 -> X86.virtualRegSqueeze
ArchPPC -> PPC.virtualRegSqueeze
ArchSPARC -> SPARC.virtualRegSqueeze
+ ArchSPARC64 -> panic "targetVirtualRegSqueeze ArchSPARC64"
ArchPPC_64 -> panic "targetVirtualRegSqueeze ArchPPC_64"
ArchARM _ _ _ -> panic "targetVirtualRegSqueeze ArchARM"
ArchARM64 -> panic "targetVirtualRegSqueeze ArchARM64"
@@ -61,6 +62,7 @@ targetRealRegSqueeze platform
ArchX86_64 -> X86.realRegSqueeze
ArchPPC -> PPC.realRegSqueeze
ArchSPARC -> SPARC.realRegSqueeze
+ ArchSPARC64 -> panic "targetRealRegSqueeze ArchSPARC64"
ArchPPC_64 -> panic "targetRealRegSqueeze ArchPPC_64"
ArchARM _ _ _ -> panic "targetRealRegSqueeze ArchARM"
ArchARM64 -> panic "targetRealRegSqueeze ArchARM64"
@@ -77,6 +79,7 @@ targetClassOfRealReg platform
ArchX86_64 -> X86.classOfRealReg platform
ArchPPC -> PPC.classOfRealReg
ArchSPARC -> SPARC.classOfRealReg
+ ArchSPARC64 -> panic "targetClassOfRealReg ArchSPARC64"
ArchPPC_64 -> panic "targetClassOfRealReg ArchPPC_64"
ArchARM _ _ _ -> panic "targetClassOfRealReg ArchARM"
ArchARM64 -> panic "targetClassOfRealReg ArchARM64"
@@ -93,6 +96,7 @@ targetMkVirtualReg platform
ArchX86_64 -> X86.mkVirtualReg
ArchPPC -> PPC.mkVirtualReg
ArchSPARC -> SPARC.mkVirtualReg
+ ArchSPARC64 -> panic "targetMkVirtualReg ArchSPARC64"
ArchPPC_64 -> panic "targetMkVirtualReg ArchPPC_64"
ArchARM _ _ _ -> panic "targetMkVirtualReg ArchARM"
ArchARM64 -> panic "targetMkVirtualReg ArchARM64"
@@ -109,6 +113,7 @@ targetRegDotColor platform
ArchX86_64 -> X86.regDotColor platform
ArchPPC -> PPC.regDotColor
ArchSPARC -> SPARC.regDotColor
+ ArchSPARC64 -> panic "targetRegDotColor ArchSPARC64"
ArchPPC_64 -> panic "targetRegDotColor ArchPPC_64"
ArchARM _ _ _ -> panic "targetRegDotColor ArchARM"
ArchARM64 -> panic "targetRegDotColor ArchARM64"
Index: ghc-7.10.3/compiler/utils/Platform.hs
===================================================================
--- ghc-7.10.3.orig/compiler/utils/Platform.hs
+++ ghc-7.10.3/compiler/utils/Platform.hs
@@ -48,6 +48,7 @@ data Arch
| ArchPPC
| ArchPPC_64
| ArchSPARC
+ | ArchSPARC64
| ArchARM
{ armISA :: ArmISA
, armISAExt :: [ArmISAExt]
Reply to: