Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 583400

Summary: dev-lang/ghc: add ppc64le support
Product: Gentoo Linux Reporter: Leno Hou <lenohou>
Component: [OLD] DevelopmentAssignee: Gentoo's Haskell Language team <haskell>
Status: RESOLVED FIXED    
Severity: enhancement CC: ac, bugs, noring, ppc64, tsmksubc
Priority: Normal    
Version: unspecified   
Hardware: PPC64   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: full build log where cross-ghc fails to build target (ppc64le) ghc

Description Leno Hou 2016-05-18 11:24:10 UTC
>>> Emerging (1 of 4) dev-lang/ghc-7.8.4::gentoo
 * Fetching files in the background.
 * To view fetch progress, run in another terminal:
 * tail -f /var/log/emerge-fetch.log
 * ghc-7.8.4-src.tar.bz2 SHA256 SHA512 size ;-) ...                                                                                                                                                         [ ok ]
 * ghc-bin-7.8.4-ppc64.tbz2 SHA256 SHA512 size ;-) ...                                                                                                                                                      [ ok ]
 * ghc-7.8.4-ia64-CLOSUREs-regenerated.patch.gz SHA256 SHA512 size ;-) ...                                                                                                                                  [ ok ]
/var/tmp/portage/dev-lang/ghc-7.8.4/temp/environment: line 86: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
>>> Unpacking source...
>>> Unpacking ghc-7.8.4-src.tar.bz2 to /var/tmp/portage/dev-lang/ghc-7.8.4/work
>>> Unpacking ghc-bin-7.8.4-ppc64.tbz2 to /var/tmp/portage/dev-lang/ghc-7.8.4/work

bzip2: /var/tmp/portage/dev-lang/ghc-7.8.4/distdir/ghc-bin-7.8.4-ppc64.tbz2: trailing garbage after EOF ignored
>>> Unpacking ghc-7.8.4-ia64-CLOSUREs-regenerated.patch.gz to /var/tmp/portage/dev-lang/ghc-7.8.4/work
>>> Source unpacked in /var/tmp/portage/dev-lang/ghc-7.8.4/work
/var/tmp/portage/dev-lang/ghc-7.8.4/temp/environment: line 86: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
>>> Preparing source in /var/tmp/portage/dev-lang/ghc-7.8.4/work/ghc-7.8.4 ...
 * PT_PAX marking -m /var/tmp/portage/dev-lang/ghc-7.8.4/work/usr/lib64/ghc-7.8.4/bin/ghc with scanelf
 * XATTR_PAX marking -me /var/tmp/portage/dev-lang/ghc-7.8.4/work/usr/lib64/ghc-7.8.4/bin/ghc with setfattr
/var/tmp/portage/dev-lang/ghc-7.8.4/temp/ghc-pkg-7.8.4-orig: line 11: /var/tmp/portage/dev-lang/ghc-7.8.4/work/usr/lib64/ghc-7.8.4/bin/ghc-pkg: cannot execute binary file: Exec format error
/var/tmp/portage/dev-lang/ghc-7.8.4/temp/ghc-pkg-7.8.4-orig: line 11: /var/tmp/portage/dev-lang/ghc-7.8.4/work/usr/lib64/ghc-7.8.4/bin/ghc-pkg: Success
 * ERROR: dev-lang/ghc-7.8.4::gentoo failed (prepare phase):
 *   failed to update cache after relocation
 * 
 * Call stack:
 *     ebuild.sh, line  133:  Called src_prepare
 *   environment, line 3695:  Called relocate_ghc '/var/tmp/portage/dev-lang/ghc-7.8.4/work'
 *   environment, line 3457:  Called die
 * The specific snippet of code:
 *       "$gp_back" recache || die "failed to update cache after relocation";
 * 
 * If you need support, post the output of `emerge --info '=dev-lang/ghc-7.8.4::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=dev-lang/ghc-7.8.4::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/dev-lang/ghc-7.8.4/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-lang/ghc-7.8.4/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-lang/ghc-7.8.4/work/ghc-7.8.4'
 * S: '/var/tmp/portage/dev-lang/ghc-7.8.4/work/ghc-7.8.4'
/var/tmp/portage/dev-lang/ghc-7.8.4/temp/environment: line 86: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

Reproducible: Always

Actual Results:  
emerge ghc failed

Expected Results:  
emerge ghc successfully
Comment 1 Leno Hou 2016-05-18 11:27:17 UTC
Attached emerge --info ghc :

localhost / # emerge --info '=dev-lang/ghc-7.8.4::gentoo'
setlocale: unsupported locale setting
setlocale: unsupported locale setting
Portage 2.2.28 (python 3.4.3-final-0, default/linux/powerpc/ppc64/13.0/64bit-userland/little-endian/systemd, gcc-5.3.0, glibc-2.22-r4, 4.1.15-gentoo-r1 ppc64le)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.1.15-gentoo-r1-ppc64le-POWER8E_-raw-,_altivec_supported-with-gentoo-2.2
sh bash 4.3_p42-r1
ld GNU ld (Gentoo 2.25.1 p1.1) 2.25.1
app-shells/bash:          4.3_p42-r1::gentoo
dev-lang/perl:            5.20.2::gentoo
dev-lang/python:          2.7.10-r1::gentoo, 3.4.3-r1::gentoo
dev-util/pkgconfig:       0.28-r2::gentoo
sys-apps/baselayout:      2.2::gentoo
sys-apps/sandbox:         2.10-r1::gentoo
sys-devel/autoconf:       2.69::gentoo
sys-devel/automake:       1.15::gentoo
sys-devel/binutils:       2.25.1-r1::gentoo
sys-devel/gcc:            5.3.0::gentoo
sys-devel/gcc-config:     1.7.3::gentoo
sys-devel/libtool:        2.4.6::gentoo
sys-devel/make:           4.1-r1::gentoo
sys-kernel/linux-headers: 4.3::gentoo (virtual/os-headers)
sys-libs/glibc:           2.22-r4::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000

ACCEPT_KEYWORDS="ppc64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="powerpc64le-unknown-linux-gnu"
CFLAGS="-O2 -pipe -mcpu=power8 -mtune=power8 -mabi=elfv2"
CHOST="powerpc64le-unknown-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="acl altivec berkdb bindist bzip2 cli cracklib crypt cxx dri fortran gdbm ibm iconv ipv6 modules ncurses nls nptl openmp pam pcre ppc64 readline session ssl systemd tcpd udev unicode xattr zlib" ABI_PPC="64" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby20 ruby21" USERLAND="GNU" VIDEO_CARDS="fbdev mach64 mga nv r128 radeon dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, MAKEOPTS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 2 Sergei Trofimovich (RETIRED) gentoo-dev 2016-05-31 21:41:11 UTC
ghc-8 has basic support for ppc64 NCG and improved cross-compiling support.
Should be feasible to bootstrap ghc binaries there.
Comment 3 Sergei Trofimovich (RETIRED) gentoo-dev 2017-04-08 21:51:09 UTC
cross-building was substantially improved in ghc-HEAD this month.
I hope to get full cross-compilation support for upcoming ghc-8.2.1.

It will ease initial porting of ghc to any new arch with a few
crosdev/emerge-${CTARGET} commands.
Comment 4 Leno Hou 2017-04-09 09:15:59 UTC
Thanks Sergei Trofimovich for you effort on this cross-building.
Comment 5 Scott Howard 2020-01-02 20:10:59 UTC
The cross-building system is broken for me. I read the following guide and used crossdev with CTARGET=powerpc64le-unknown-linux-gnu:
https://trofi.github.io/posts/200-ghc-as-a-crosscompiler-update.html

I used the overlay repo (https://github.com/gentoo-haskell/gentoo-haskell) for this output but the standard repo also has the same issue with ghc-8.4.3.

I encountered the same error as this while cross-compiling from my x86_64 laptop:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=910664#10

Any insight about the best way to get ghc-8.2.1 or later working on ppc64le will be appreciated.



# emerge --info '=cross-powerpc64le-unknown-linux-gnu/ghc-8.4.4::crossdev'
Portage 2.3.79 (python 3.6.9-final-0, default/linux/amd64/17.1/no-multilib, gcc-9.2.0, glibc-2.29-r7, 4.19.86-gentoo x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.19.86-gentoo-x86_64-Intel-R-_Core-TM-_i7-8559U_CPU_@_2.70GHz-with-gentoo-2.6
KiB Mem:     4037172 total,   1279288 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Thu, 02 Jan 2020 00:45:01 +0000
Head commit of repository haskell: a702e87a91117c1fbe49d3d76f537a982e01b448

sh bash 4.4_p23-r1
ld GNU ld (Gentoo 2.32 p2) 2.32.0
app-shells/bash:          4.4_p23-r1::gentoo
dev-lang/perl:            5.30.1::gentoo
dev-lang/python:          2.7.17::gentoo, 3.6.9::gentoo
sys-apps/baselayout:      2.6-r1::gentoo
sys-apps/openrc:          0.41.2::gentoo
sys-apps/sandbox:         2.13::gentoo
sys-devel/autoconf:       2.69-r4::gentoo
sys-devel/automake:       1.16.1-r1::gentoo
sys-devel/binutils:       2.32-r1::gentoo
sys-devel/gcc:            9.2.0-r2::gentoo
sys-devel/gcc-config:     2.1::gentoo
sys-devel/libtool:        2.4.6-r3::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 4.19::gentoo (virtual/os-headers)
sys-libs/glibc:           2.29-r7::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: webrsync
    sync-uri: https://gentoo.osuosl.org/
    priority: -1000
    sync-webrsync-verify-signature: yes

crossdev
    location: /usr/local/crossdev
    masters: gentoo

haskell
    location: /var/db/repos/gentoo-haskell
    sync-type: git
    sync-uri: https://github.com/gentoo-haskell/gentoo-haskell.git
    masters: gentoo

local
    location: /usr/local/portage
    masters: gentoo

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="https://gentoo.osuosl.org/"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j4"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="acl amd64 berkdb bzip2 cli crypt cxx device-mapper dri fortran gdbm iconv ipv6 libtirpc ncurses nls nptl openmp pam pcre readline seccomp split-usr ssl tcpd unicode xattr zlib" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="pc" INPUT_DEVICES="libinput keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" NETBEANS_MODULES="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-2" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python2_7 python3_6" RUBY_TARGETS="ruby24 ruby25" USERLAND="GNU" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 6 Scott Howard 2020-01-05 17:21:20 UTC
I have a more thorough report to amend the previous one. The previous error was from memory starvation. Now using the same commands (but reducing parallelism and adding more swap) I am able to successfully build the cross-ghc. The cross-ghc now runs into a linker error that I cannot solve.

localhost ~ # emerge-powerpc64le-unknown-linux-gnu -pqv '=dev-lang/ghc-8.6.5::gentoo'
[ebuild  N    ] dev-lang/ghc-8.6.5 to /usr/powerpc64le-unknown-linux-gnu/ USE="ghcbootstrap gmp -binary -doc -ghcmakebinary -profile -test" 

selected output:

"inplace/bin/ghc-stage1" -hisuf hi -osuf  o -hcsuf hc -static  -H32m -O  -Wall      -this-unit-id base-4.12.0.0 -hide-all-packages -i -ilibraries/base/. -ilibraries/base/dist-install/build -Ilibraries/base/dist-install/build -ilibraries/base/dist-install/build/./autogen -Ilibraries/base/dist-install/build/./autogen -Ilibraries/base/include -Ilibraries/base/dist-install/build/include   -optP-DOPTIMISE_INTEGER_GCD_LCM -optP-include -optPlibraries/base/dist-install/build/./autogen/cabal_macros.h -package-id ghc-prim-0.5.3 -package-id integer-gmp-1.0.2.0 -package-id rts -this-unit-id base -Wcompat -Wnoncanonical-monad-instances -XHaskell2010 -O2 -haddock  -no-user-package-db -rtsopts  -Wno-trustworthy-safe -Wno-deprecated-flags     -Wnoncanonical-monad-instances  -odir libraries/base/dist-install/build -hidir libraries/base/dist-install/build -stubdir libraries/base/dist-install/build  -split-sections -dynamic-too -c libraries/base/./Text/ParserCombinators/ReadPrec.hs -o libraries/base/dist-install/build/Text/ParserCombinators/ReadPrec.o -dyno libraries/base/dist-install/build/Text/ParserCombinators/ReadPrec.dyn_o
"inplace/bin/ghc-stage1" -hisuf hi -osuf  o -hcsuf hc -static  -H32m -O  -Wall      -this-unit-id base-4.12.0.0 -hide-all-packages -i -ilibraries/base/. -ilibraries/base/dist-install/build -Ilibraries/base/dist-install/build -ilibraries/base/dist-install/build/./autogen -Ilibraries/base/dist-install/build/./autogen -Ilibraries/base/include -Ilibraries/base/dist-install/build/include   -optP-DOPTIMISE_INTEGER_GCD_LCM -optP-include -optPlibraries/base/dist-install/build/./autogen/cabal_macros.h -package-id ghc-prim-0.5.3 -package-id integer-gmp-1.0.2.0 -package-id rts -this-unit-id base -Wcompat -Wnoncanonical-monad-instances -XHaskell2010 -O2 -haddock  -no-user-package-db -rtsopts  -Wno-trustworthy-safe -Wno-deprecated-flags     -Wnoncanonical-monad-instances  -odir libraries/base/dist-install/build -hidir libraries/base/dist-install/build -stubdir libraries/base/dist-install/build  -split-sections -dynamic-too -c libraries/base/./GHC/Float.hs -o libraries/base/dist-install/build/GHC/Float.o -dyno libraries/base/dist-install/build/GHC/Float.dyn_o
"inplace/bin/ghc-stage1" -hisuf hi -osuf  o -hcsuf hc -static  -H32m -O  -Wall      -this-unit-id base-4.12.0.0 -hide-all-packages -i -ilibraries/base/. -ilibraries/base/dist-install/build -Ilibraries/base/dist-install/build -ilibraries/base/dist-install/build/./autogen -Ilibraries/base/dist-install/build/./autogen -Ilibraries/base/include -Ilibraries/base/dist-install/build/include   -optP-DOPTIMISE_INTEGER_GCD_LCM -optP-include -optPlibraries/base/dist-install/build/./autogen/cabal_macros.h -package-id ghc-prim-0.5.3 -package-id integer-gmp-1.0.2.0 -package-id rts -this-unit-id base -Wcompat -Wnoncanonical-monad-instances -XHaskell2010 -O2 -haddock  -no-user-package-db -rtsopts  -Wno-trustworthy-safe -Wno-deprecated-flags     -Wnoncanonical-monad-instances  -odir libraries/base/dist-install/build -hidir libraries/base/dist-install/build -stubdir libraries/base/dist-install/build  -split-sections -dynamic-too -c libraries/base/./GHC/Event/PSQ.hs -o libraries/base/dist-install/build/GHC/Event/PSQ.o -dyno libraries/base/dist-install/build/GHC/Event/PSQ.dyn_o
/usr/libexec/gcc/powerpc64le-unknown-linux-gnu/ld: cannot find /usr/powerpc64le-unknown-linux-gnu/tmp/portage/dev-lang/ghc-8.6.5/temp/ghc27300_0/ghc_8.o inside /usr/powerpc64le-unknown-linux-gnu
/usr/libexec/gcc/powerpc64le-unknown-linux-gnu/ld: cannot find /usr/powerpc64le-unknown-linux-gnu/tmp/portage/dev-lang/ghc-8.6.5/temp/ghc27300_0/ghc_7.o inside /usr/powerpc64le-unknown-linux-gnu
collect2: error: ld returned 1 exit status
`powerpc64le-unknown-linux-gnu-gcc' failed in phase `Linker'. (Exit code: 1)
make[1]: *** [libraries/base/ghc.mk:4: libraries/base/dist-install/build/GHC/Float.o] Error 1
make: *** [Makefile:127: ghc/stage2/build/tmp/ghc-stage2] Error 2




localhost ~ # emerge-powerpc64le-unknown-linux-gnu --info '=dev-lang/ghc-8.6.5::gentoo'
Portage 2.3.79 (python 3.6.9-final-0, embedded, gcc-9.2.0, unavailable, 4.19.86-gentoo x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.19.86-gentoo-x86_64-Intel-R-_Core-TM-_i7-8559U_CPU_@_2.70GHz-with-gentoo-2.6
KiB Mem:     4037140 total,   2541580 free
KiB Swap:    4194300 total,   4189940 free
Timestamp of repository gentoo: Thu, 02 Jan 2020 00:45:01 +0000
Head commit of repository gentoo: b5dba65b9334dfb0306973e0c723a10c50e2243f
sh bash 4.4_p23-r1
ld GNU ld (Gentoo 2.33.1 p1) 2.33.1
app-shells/bash:          4.4_p23-r1::gentoo
dev-lang/perl:            5.30.1::gentoo
dev-lang/python:          3.6.9::gentoo
sys-apps/sandbox:         2.13::gentoo
sys-kernel/linux-headers: 5.4::gentoo (virtual/os-headers)
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-metamanifest: yes
    sync-rsync-extra-opts: 

ACCEPT_KEYWORDS="ppc64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -fomit-frame-pointer"
CHOST="powerpc64le-unknown-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -fomit-frame-pointer"
DISTDIR="/var/cache/distfiles"
FCFLAGS="-Os -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news nodoc noinfo noman parallel-fetch pid-sandbox preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-Os -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.utf8"
LDFLAGS=""
LINGUAS="en"
MAKEOPTS="-j4"
PKGDIR="/usr/powerpc64le-unknown-linux-gnu/packages/"
PORTAGE_CONFIGROOT="/usr/powerpc64le-unknown-linux-gnu/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/usr/powerpc64le-unknown-linux-gnu/tmp/"
USE="kdrive minimal multicall ppc64 ssl unicode zlib" ELIBC="glibc" INPUT_DEVICES="evdev mouse keyboard" KERNEL="linux" PYTHON_TARGETS="python3_6" USERLAND="GNU" VIDEO_CARDS="fbdev"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, ENV_UNSET, INSTALL_MASK, LC_ALL, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 7 Scott Howard 2020-01-05 17:23:12 UTC
Created attachment 602608 [details]
full build log where cross-ghc fails to build target (ppc64le) ghc
Comment 8 Sergei Trofimovich (RETIRED) gentoo-dev 2020-01-09 07:32:55 UTC
I suggest also using USE=ghcmakebinary flag. That might make bundled libffi building less problematic.

> /usr/libexec/gcc/powerpc64le-unknown-linux-gnu/ld: cannot find /usr/powerpc64le-unknown-linux-gnu/tmp/portage/dev-lang/ghc-8.6.5/temp/ghc27300_0/ghc_8.o inside /usr/powerpc64le-unknown-linux-gnu
> /usr/libexec/gcc/powerpc64le-unknown-linux-gnu/ld: cannot find /usr/powerpc64le-unknown-linux-gnu/tmp/portage/dev-lang/ghc-8.6.5/temp/ghc27300_0/ghc_7.o inside /usr/powerpc64le-unknown-linux-gnu
collect2: error: ld returned 1 exit status

Hm, that is unusual. Is it a reproducible failure or a one-off bug? I'll try locally as well.
Comment 9 Sergei Trofimovich (RETIRED) gentoo-dev 2020-01-09 22:53:12 UTC
Tried to bootstrap ghc-8.8.1 into ppc64le today and it built the package just fine:
    https://slyfox.uni.cx/distfiles/cross-ghc-bin-8.8.1-powerpc64le-unknown-linux-gnu.tbz2

I'll try to dump it onto ppc64le machine and see if i can bootstrap native 8.8.1 on it and then 8.6.5 from it.
Comment 10 Scott Howard 2020-01-10 18:40:43 UTC
I get the linker error every time. I wish I knew what was causing the issue with my cross build environment.

That being said, your binary package gets me over the main hurdle. I was able to use that as the arch_binary in my local 8.8.1 ebuild and ghcbootstrap my own 8.8.1 on top of that. I might use what I have now to go back to 8.6.5 but 8.8.1 works just fine. Thanks for revisiting this!
Comment 12 Fredrik Noring 2020-02-09 12:56:53 UTC
Thank you Sergei, this was very helpful. I managed to install your dev-lang/ghc-8.8.1. However, there is some kind of problem with app-admin/haskell-updater-1.2.10:

[5 of 7] Compiling Distribution.Gentoo.GHC ( Distribution/Gentoo/GHC.hs, dist/build/haskell-updater/haskell-updater-tmp/Distribution/Gentoo/GHC.dyn_o )

Distribution/Gentoo/GHC.hs:63:57: error:
    • Couldn't match expected type ‘Distribution.Utils.IOData.IODataMode’
                  with actual type ‘Bool’
    • In the 7th argument of ‘rawSystemStdInOut’, namely ‘False’
      In a stmt of a 'do' block:
        (out, _, _) <- rawSystemStdInOut
                         silent cmd args Nothing Nothing Nothing False
      In the expression:
        do (out, _, _) <- rawSystemStdInOut
                            silent cmd args Nothing Nothing Nothing False
           return out
   |
63 |                                                         False   -- is output in binary mode
   |                                                         ^^^^^

Distribution/Gentoo/GHC.hs:64:26: error:
    • Couldn't match type ‘Distribution.Utils.IOData.IOData’
                     with ‘[Char]’
      Expected type: IO String
        Actual type: IO Distribution.Utils.IOData.IOData
    • In a stmt of a 'do' block: return out
      In the expression:
        do (out, _, _) <- rawSystemStdInOut
                            silent cmd args Nothing Nothing Nothing False
           return out
      In an equation for ‘rawCommand’:
          rawCommand cmd args
            = do (out, _, _) <- rawSystemStdInOut
                                  silent cmd args Nothing Nothing Nothing False
                 return out
   |
64 |                          return out
   |                          ^^^^^^^^^^
[6 of 7] Compiling Paths_haskell_updater ( dist/build/haskell-updater/autogen/Paths_haskell_updater.hs, dist/build/haskell-updater/haskell-updater-tmp/Paths_haskell_updater.dyn_o )
 * ERROR: app-admin/haskell-updater-1.2.10::gentoo failed (compile phase):
 *   setup build failed
Comment 13 Sergei Trofimovich (RETIRED) gentoo-dev 2020-02-09 13:59:36 UTC
Yeah. Note: ghc-8.6.* and ghc-8.8.* are not yet keyworded on any ARCH in gentoo. There will be quite a bit of breakage. We usually recommend trying ::haskell overlay for beleeding-edge software until it's moved to ::gentoo.

ghc-8.6.5 should be less broken, but still not perfect.
Comment 14 Larry the Git Cow gentoo-dev 2021-02-14 16:25:06 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d66b01c15d475c3ccb5562c957780063a577f7b5

commit d66b01c15d475c3ccb5562c957780063a577f7b5
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2021-02-14 16:23:31 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2021-02-14 16:25:03 +0000

    profiles/arch/powerpc/ppc64/package.use.mask: various dev-util/diffoscope masks
    
    Bug: https://bugs.gentoo.org/769956
    Bug: https://bugs.gentoo.org/583400
    Signed-off-by: Sam James <sam@gentoo.org>

 profiles/arch/powerpc/ppc64/package.use.mask | 11 +++++++++++
 1 file changed, 11 insertions(+)
Comment 15 matoro archtester 2021-11-11 22:18:38 UTC
Hello, is there any news in getting ghc working on ppc64?  I see that there are no bootstrap binaries for any recent version?
Comment 16 Larry the Git Cow gentoo-dev 2022-07-22 22:16:40 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ba7a7c2811d41d7708a22e0953c3b71acb37d6c0

commit ba7a7c2811d41d7708a22e0953c3b71acb37d6c0
Author:     matoro <matoro@users.noreply.github.com>
AuthorDate: 2022-07-13 18:47:19 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-07-22 22:14:47 +0000

    dev-lang/ghc: keyword 9.0.2 for ~amd64, ~ppc64, ~x86
    
    Closes: https://bugs.gentoo.org/583400
    Signed-off-by: matoro <matoro@users.noreply.github.com>
    Signed-off-by: Sam James <sam@gentoo.org>

 dev-lang/ghc/Manifest                              |  1 +
 .../ghc/files/ghc-9.0.2-modorigin-semigroup.patch  | 27 +++++++++++++++
 dev-lang/ghc/ghc-9.0.2.ebuild                      | 40 +++++++++++++---------
 3 files changed, 51 insertions(+), 17 deletions(-)