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 - glaub...@debian.org `. `' Freie Universitaet Berlin - glaub...@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 #80. . 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' (ppcNcgImpldflags) 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,
Re: Bug#807777: ghc: Please adjust linker options for sparc64 (patch supplied)
On 12/13/2015 07:04 PM, John Paul Adrian Glaubitz wrote: > On 12/13/2015 12:32 PM, John Paul Adrian Glaubitz wrote: >> I am about to file an upstream bug report in ghc so upstream can >> develop a proper fix similar to the older fix for sparc [2]. > > Attaching a proposed fix which I have also posted upstream [1]. Oops, just saw there was a copy-and-paste error, attaching refreshed patch. I forgot to change ArchSPARC to ArchSPARC64 after copying the map section from sparc to sparc64. Sorry for the noise! Cheers, Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaub...@debian.org `. `' Freie Universitaet Berlin - glaub...@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 patches compiler/main/DriverPipeline.hs to explicitly pass -no-relax to gcc. See upstream ticket #11211 and Debian bug #80. . 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/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]
Re: Bug#807777: ghc: Please adjust linker options for sparc64 (patch supplied)
On 12/13/2015 12:32 PM, John Paul Adrian Glaubitz wrote: > I am about to file an upstream bug report in ghc so upstream can > develop a proper fix similar to the older fix for sparc [2]. Attaching a proposed fix which I have also posted upstream [1]. Cheers, Adrian > [1] https://ghc.haskell.org/trac/ghc/ticket/11211 -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaub...@debian.org `. `' Freie Universitaet Berlin - glaub...@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 patches compiler/main/DriverPipeline.hs to explicitly pass -no-relax to gcc. See upstream ticket #11211 and Debian bug #80. . --- 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=ArchSPARC" +;; + 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" ;; *) --- 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 []) --- 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]
Re: Bug#807777: ghc: Please adjust linker options for sparc64 (patch supplied)
On 12/13/2015 12:05 PM, John Paul Adrian Glaubitz wrote: > Ok, this seems to be a bit more complicated as the linker settings have > to be explicitly set in the ghc source code directly. I have tried > building hscolour manually which initially works but eventually fails > with: > > Language/Haskell/HsColour.hs:94:55: Warning: Tab character > [ 1 of 16] Compiling Language.Haskell.HsColour.General ( > Language/Haskell/HsColour/General.hs, > dist-ghc/build/Language/Haskell/HsColour/General.p_o ) > /usr/bin/ld: --relax and -r may not be used together > collect2: error: ld returned 1 exit status > make: *** [build-ghc-stamp] Error 1 > /usr/share/cdbs/1/class/hlibrary.mk:147: recipe for target > 'build-ghc-stamp' failed > dpkg-buildpackage: error: debian/rules build-arch gave error exit status 2 Temporary workaround: root@andi:/srv/disk1/chroots/unstable-sparc64-sbuild/usr/lib/ghc# diff -u settings.orig settings --- settings.orig 2015-12-12 15:18:11.0 +0100 +++ settings2015-12-13 11:45:21.52801 +0100 @@ -1,6 +1,6 @@ [("GCC extra via C opts", " -fwrapv"), ("C compiler command", "/usr/bin/gcc"), - ("C compiler flags", " -fno-stack-protector"), + ("C compiler flags", " -fno-stack-protector -Wl,-no-relax"), ("C compiler link flags", ""), ("Haskell CPP command","/usr/bin/gcc"), ("Haskell CPP flags","-E -undef -traditional "), root@andi:/srv/disk1/chroots/unstable-sparc64-sbuild/usr/lib/ghc# So, in case the patch from message #5 [1] in this bug report is applied, please make sure to also patch the settings file for ghc as above on sparc64 to make sure -Wl,-no-relax is always used in ghc on sparc64. I am about to file an upstream bug report in ghc so upstream can develop a proper fix similar to the older fix for sparc [2]. Cheers, Adrian > [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=80#5 > [2] https://ghc.haskell.org/trac/ghc/ticket/3791 -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaub...@debian.org `. `' Freie Universitaet Berlin - glaub...@physik.fu-berlin.de `-GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Re: Bug#807777: ghc: Please adjust linker options for sparc64 (patch supplied)
On 12/12/2015 10:27 PM, John Paul Adrian Glaubitz wrote: > I just successfully built the first ghc Debian packages for sparc64 with the > help of bootstrapping ghc on amd64. In order to successfully build ghc on > sparc64, I had to add -optl-Wl,-no-relax to SRC_HC_OPTS as otherwise gcc > would pass "-r" and "--relax" to ld which is not allowed on sparc*. Ok, this seems to be a bit more complicated as the linker settings have to be explicitly set in the ghc source code directly. I have tried building hscolour manually which initially works but eventually fails with: Language/Haskell/HsColour.hs:94:55: Warning: Tab character [ 1 of 16] Compiling Language.Haskell.HsColour.General ( Language/Haskell/HsColour/General.hs, dist-ghc/build/Language/Haskell/HsColour/General.p_o ) /usr/bin/ld: --relax and -r may not be used together collect2: error: ld returned 1 exit status make: *** [build-ghc-stamp] Error 1 /usr/share/cdbs/1/class/hlibrary.mk:147: recipe for target 'build-ghc-stamp' failed dpkg-buildpackage: error: debian/rules build-arch gave error exit status 2 Full build log here [1]. Thus, we have to make sure that ghc does not just set "-Wl,-no-relax" when building itself but also when building any other Haskell sources. Or, alternatively, we could try to convince the gcc/binutils developers to fix the behavior of gcc/binutils when "-Wl,-r" are set. Apparently, this could be interpreted as a bug in gcc which actually sets "-no-relax" when "-r" is passed but not when "-Wl,-r" is passed. qemu is affected by the same problem, see [2]. Anyone on the Debian sparc mailing list with an idea? Cheers, Adrian > [1] https://people.debian.org/~glaubitz/hscolour_1.23-3+sparc64_sparc64-20151213-0722 > [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=807006 -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaub...@debian.org `. `' Freie Universitaet Berlin - glaub...@physik.fu-berlin.de `-GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Re: Bug#807777: ghc: Please adjust linker options for sparc64 (patch supplied)
On 12/12/2015 10:27 PM, John Paul Adrian Glaubitz wrote: > ghc upstream actually contains a fix for this [1] which, unfortuntely, > applies to sparc but not sparc64 as the latter is not natively supported > by ghc yet and not detected as ArchSPARC. Oops, forgot the link: > [1] https://ghc.haskell.org/trac/ghc/ticket/3791 -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaub...@debian.org `. `' Freie Universitaet Berlin - glaub...@physik.fu-berlin.de `-GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Bug#807777: ghc: Please adjust linker options for sparc64 (patch supplied)
Package: ghc Version: 7.10.3-3 Severity: important Tags: patch User: debian-sparc@lists.debian.org Usertags: sparc64 Hello! I just successfully built the first ghc Debian packages for sparc64 with the help of bootstrapping ghc on amd64. In order to successfully build ghc on sparc64, I had to add -optl-Wl,-no-relax to SRC_HC_OPTS as otherwise gcc would pass "-r" and "--relax" to ld which is not allowed on sparc*. ghc upstream actually contains a fix for this [1] which, unfortuntely, applies to sparc but not sparc64 as the latter is not natively supported by ghc yet and not detected as ArchSPARC. Native sparc64 support could possibly happen in the future though since ghc already seems to have NGC support for SPARCv9 according to the source code. Anyway, please apply the attached patch to make ghc build on sparc64. Thanks, Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaub...@debian.org `. `' Freie Universitaet Berlin - glaub...@physik.fu-berlin.de `-GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 --- debian/rules.orig 2015-12-06 13:56:27.0 +0100 +++ debian/rules 2015-12-12 22:16:57.646797482 +0100 @@ -43,6 +43,9 @@ override_dh_auto_configure: dh_autoreconf perl -- boot echo "SRC_HC_OPTS += -lffi -optl-pthread" >> mk/build.mk +ifneq (,$(filter $(DEB_HOST_ARCH), sparc64)) + echo "SRC_HC_OPTS += -optl-Wl,-no-relax" >> mk/build.mk +endif echo "HADDOCK_DOCS := YES" >> mk/build.mk echo "XSLTPROC_OPTS += --nonet" >> mk/build.mk ifneq (,$(findstring $(DEB_HOST_ARCH), arm64 armel armhf))