[GHC] #15916: GHC doesn't build on powerpc64 architecture on systems other than GNU / Linux
GHC
ghc-devs at haskell.org
Sun Jan 13 11:56:20 UTC 2019
#15916: GHC doesn't build on powerpc64 architecture on systems other than GNU /
Linux
-------------------------------------+-------------------------------------
Reporter: pkubaj | Owner: trommler
Type: feature request | Status: patch
Priority: normal | Milestone: 8.10.1
Component: Compiler | Version: 8.6.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: powerpc64
Type of failure: Building GHC | Test Case:
failed |
Blocked By: 15411 | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/81
-------------------------------------+-------------------------------------
Comment (by pkubaj):
OK.
You need FreeBSD sources in {{{/usr/src}}} and the current ports tree in
{{{/usr/ports}}} (all on amd64).
{{{
cd /usr/src
pkg install devel/powerpc64-xtoolchain-gcc
make CROSS_TOOLCHAIN=powerpc64-gcc TARGET=powerpc TARGET_ARCH=powerpc64
buildworld
make CROSS_TOOLCHAIN=powerpc64-gcc TARGET=powerpc TARGET_ARCH=powerpc64
installworld DESTDIR=/sysroots/powerpc64
make CROSS_TOOLCHAIN=powerpc64-gcc TARGET=powerpc TARGET_ARCH=powerpc64
distribution DESTDIR=/sysroots/powerpc64
}}}
Now you need wrappers for toolchain. I put mine to ~/bin:
powerpc64-portbld-freebsd-ar:
#!/bin/sh
exec /usr/local/bin/powerpc64-unknown-freebsd12.0-ar "$@"
powerpc64-portbld-freebsd-g++:
#!/bin/sh
exec /usr/local/bin/powerpc64-unknown-freebsd12.0-g++
--sysroot=/sysroots/powerpc64 "$@"
powerpc64-portbld-freebsd-gcc:
#!/bin/sh
exec /usr/local/bin/powerpc64-unknown-freebsd12.0-gcc
--sysroot=/sysroots/powerpc64 "$@"
powerpc64-portbld-freebsd-ld:
#!/bin/sh
exec /usr/local/bin/powerpc64-unknown-freebsd12.0-ld
--sysroot=/sysroots/powerpc64 "$@"
powerpc64-portbld-freebsd-nm:
#!/bin/sh
exec /usr/local/bin/powerpc64-unknown-freebsd12.0-gcc-nm "$@"
powerpc64-portbld-freebsd-objdump:
#!/bin/sh
exec /usr/local/bin/powerpc64-unknown-freebsd12.0-objdump "$@"
powerpc64-portbld-freebsd-ranlib:
#!/bin/sh
exec /usr/local/bin/powerpc64-unknown-freebsd12.0-ranlib "$@"
powerpc64-portbld-freebsd-strip:
#!/bin/sh
exec /usr/local/bin/powerpc64-unknown-freebsd12.0-strip "$@"
{{{
cd /usr/ports/lang/ghc
}}}
Put your patches to {{{files}}}.
{{{
make patch
cd work/ghc-8.6.3
cp mk/build.mk.sample mk/build.mk
}}}
Add to mk/build.mk:
{{{
INTEGER_LIBRARY = integer-simple
BIN_DIST_NAME=ghc-8.6.3-boot
BIN_DIST_TAR=ghc-8.6.3-boot.tar
DYNAMIC_GHC_PROGRAMS = NO
}}}
Then it doesn't build with dtrace):
{{{
./configure --target=powerpc64-portbld-freebsd --disable-dtrace
gmake
gmake binary-dist TAR_COMP=xz
mv ghc-8.6.3-boot-powerpc64-portbld-freebsd.tar.xz ghc-8.6.3-boot-
powerpc64-freebsd.tar.xz
}}}
And copy ghc-8.6.3-boot-powerpc64-freebsd.tar.xz to my POWER box to
{{{/usr/ports/distfiles}}}. On it, I have the same set of patches and a
patch to {{{lang/ghc/bsd.ghc.mk}}}:
{{{
Index: bsd.ghc.mk
===================================================================
--- bsd.ghc.mk (revision 489844)
+++ bsd.ghc.mk (working copy)
@@ -5,12 +5,13 @@
# Maintained by: haskell at FreeBSD.org
#
-ONLY_FOR_ARCHS= aarch64 amd64 armv6 armv7 i386
+ONLY_FOR_ARCHS= aarch64 amd64 armv6 armv7 i386 powerpc64
DATADIR= ${PREFIX}/share/ghc-${GHC_VERSION}
EXAMPLESDIR= ${PREFIX}/share/examples/ghc-${GHC_VERSION}
-USES= autoreconf gmake iconv:translit localbase:ldflags ncurses
perl5 tar:xz
+USES= autoreconf compiler:c11 gmake iconv:translit
localbase:ldflags \
+ ncurses perl5 tar:xz
USE_LOCALE= en_US.UTF-8
USE_PERL5= build
NO_CCACHE= ccache: error: Failed to create directory
/nonexistent/.ccache/tmp: Permission denied
@@ -83,6 +84,8 @@
.if empty(PORT_OPTIONS:MBOOT)
. if ${ARCH} == armv6 || ${ARCH} == armv7
BOOT_GHC_VERSION= 8.4.2
+.elif ${ARCH} == powerpc64
+BOOT_GHC_VERSION= 8.6.3
. else
BOOT_GHC_VERSION= 8.4.3
. endif
}}}
You also need to add a proper SHA256 and SIZE entries to
{{{lang/ghc/distinfo}}}:
{{{
SHA256 (ghc-8.6.3-boot-powerpc64-freebsd.tar.xz) =
258f4d41d2cf7977f756e6a5ac718e5ed140065d31ba89c8aee4f654d57a6315
SIZE (ghc-8.6.3-boot-powerpc64-freebsd.tar.xz) = 179817644
}}}
SHA256 is returned by {{{sha256}}} and SIZE is from {{{stat -f %z
ghc-8.6.3-boot-powerpc64-freebsd.tar.xz}}}.
Then:
{{{
cd /usr/ports/lang/ghc
make (I disable all options to avoid further problems)
}}}
Then just wait for an error.
Alternatively, you could mark a BOOT option, and install ghc locally like
this.
{{{
cd /usr/ports/distfiles
tar xvvf ghc-8.6.3-boot-powerpc64-freebsd.tar.xz
cd ghc-8.6.3-boot
CFLAGS="-Wl,-rpath=/usr/local/lib/gcc8 -isystem /usr/local/include"
CXXFLAGS="-Wl,-rpath=/usr/local/lib/gcc8 -isystem /usr/local/include"
CC=gcc8 CXX=g++8 ./configure
gmake install
}}}
I hope it's clear enough :)
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15916#comment:30>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list