[GHC] #15338: ghc-pkg misbehaves after possible miscompilation on m68k and sh4
GHC
ghc-devs at haskell.org
Wed Jul 4 02:24:00 UTC 2018
#15338: ghc-pkg misbehaves after possible miscompilation on m68k and sh4
-------------------------------------+-------------------------------------
Reporter: glaubitz | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.4.3
Keywords: | Operating System: Linux
Architecture: m68k | Type of failure: Incorrect result
| at runtime
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
We have observed in Debian that GHC can produce a erratically behaving
version of ghc-pkg which causes issues when piping it's output to another
program.
Example:
{{{
make_setup_recipe
Running ghc --make Setup.hs -o debian/hlibrary.setup
[1 of 1] Compiling Main ( Setup.hs, Setup.o )
Linking debian/hlibrary.setup ...
. /usr/share/haskell-devscripts/Dh_Haskell.sh && \
configure_recipe
Running debian/hlibrary.setup configure --ghc -v2 --package-
db=/var/lib/ghc/package.conf.d --prefix=/usr --libdir=/usr/lib/haskell-
packages/ghc/lib --libexecdir=/usr/lib --builddir=dist-ghc --ghc-option
=-optl-Wl\,-z\,relro --haddockdir=/usr/lib/ghc-doc/haddock/base-prelude-/
--datasubdir=base-prelude --htmldir=/usr/share/doc/libghc-base-prelude-
doc/html/ --enable-library-profiling
Configuring base-prelude-1.2.1...
Warning: cannot determine version of /usr/bin/ghc-pkg :
""
hlibrary.setup: The program 'ghc-pkg' is required but the version of
/usr/bin/ghc-pkg could not be determined.
}}}
(Full log: https://buildd.debian.org/status/fetch.php?pkg=haskell-base-
prelude&arch=m68k&ver=1.2.1-1&stamp=1530588494&raw=0)
Examining the behavior of the affected ghc-pkg binary on m68k shows what's
going on:
{{{
root at pacman:~# uname -a
Linux pacman 4.16.0-2-m68k #1 Debian 4.16.16-1 (2018-06-19) m68k GNU/Linux
root at pacman:~# ghc-pkg --version
GHC package manager version 8.2.2
root at pacman:~# ghc-pkg --version | cat
root at pacman:~#
}}}
Comparing that to an x86_64 machine shows that piping to cat should
actually output something:
{{{
glaubitz at epyc:~$ uname -a
Linux epyc 4.16.0-2-amd64 #1 SMP Debian 4.16.12-1 (2018-05-27) x86_64
GNU/Linux
glaubitz at epyc:~$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.2.2
glaubitz at epyc:~$ ghc --version | cat
The Glorious Glasgow Haskell Compilation System, version 8.2.2
glaubitz at epyc:~$
}}}
Further investigation shows that the problem is partially resolved when
building GHC with reduced optimization:
{{{
echo "SRC_HC_OPTS += -O0 -H64m" >> mk/build.mk
echo "GhcStage1HcOpts = -O" >> mk/build.mk
echo "GhcStage2HcOpts = -O0" >> mk/build.mk
echo "GhcLibHcOpts = -O" >> mk/build.mk
}}}
The above issue goes away, but ghc-pkg itself still shows some strange
behavior:
{{{
make_setup_recipe
Running ghc --make Setup.hs -o debian/hlibrary.setup
[1 of 1] Compiling Main ( Setup.hs, Setup.o )
Linking debian/hlibrary.setup ...
. /usr/share/haskell-devscripts/Dh_Haskell.sh && \
configure_recipe
Running debian/hlibrary.setup configure --ghc -v2 --package-
db=/var/lib/ghc/package.conf.d --prefix=/usr --libdir=/usr/lib/haskell-
packages/ghc/lib --libexecdir=/usr/lib --builddir=dist-ghc --ghc-option
=-optl-Wl\,-z\,relro --haddockdir=/usr/lib/ghc-doc/haddock/microlens-
ghc-0.4.8.0/ --datasubdir=microlens-ghc --htmldir=/usr/share/doc/libghc-
microlens-ghc-doc/html/ --enable-library-profiling
Configuring microlens-ghc-0.4.8.0...
hlibrary.setup: ghc-pkg dump failed: dieVerbatim: user error
(hlibrary.setup:
'/usr/bin/ghc-pkg' exited with an error:
ghc-pkg: <stdout>: commitBuffer: invalid argument (invalid character)
)
}}}
(Full log: https://buildd.debian.org/status/fetch.php?pkg=haskell-
microlens-ghc&arch=m68k&ver=0.4.8.0-2&stamp=1529960552&raw=0)
To reproduce the issue, GHC can be tested using QEMU which has pretty good
support for the m68k target these days.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15338>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list