GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2020-02-25T01:04:40Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/17442GHC HEAD-only panic (emitPrimOp: handled above in cgOpApp)2020-02-25T01:04:40ZRyan ScottGHC HEAD-only panic (emitPrimOp: handled above in cgOpApp)I noticed this issue originally as `deriving-compat-0.5.7`'s test suite fails to compile on HEAD. Here is a minimized version of the test suite that compiles successfully with optimizations on GHC 8.8.1 and earlier:
```hs
{-# LANGUAGE M...I noticed this issue originally as `deriving-compat-0.5.7`'s test suite fails to compile on HEAD. Here is a minimized version of the test suite that compiles successfully with optimizations on GHC 8.8.1 and earlier:
```hs
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE TypeFamilies #-}
module Bug where
import Control.Monad
import GHC.Arr (Ix(..))
import GHC.Base (getTag)
import GHC.Exts
data family D
data instance D = MkD
deriving (Eq, Ord, Show)
instance Ix D where
range (a, b) =
let a# = getTag a
b# = getTag b
in map (\(I# i#) -> tagToEnum# i# :: D)
(enumFromTo (I# a#) (I# b#))
unsafeIndex (a, _) c =
let a# = getTag a
c# = getTag c
d# = c# -# a#
in I# d#
inRange (a, b) c =
let a# = getTag a
b# = getTag b
c# = getTag c
in tagToEnum# (c# >=# a#) && tagToEnum# (c# <=# b#)
shouldBe :: (Eq a, Show a) => a -> a -> IO ()
shouldBe x y =
unless (x == y) $ fail $ show x ++ " is not equal to " ++ show y
ixLaws :: (Ix a, Show a) => a -> a -> a -> IO ()
ixLaws l u i = do
inRange (l,u) i `shouldBe` elem i (range (l,u))
range (l,u) !! index (l,u) i `shouldBe` i
map (index (l,u)) (range (l,u)) `shouldBe` [0..rangeSize (l,u)-1]
rangeSize (l,u) `shouldBe` length (range (l,u))
dIsLawfulIx :: IO ()
dIsLawfulIx = ixLaws MkD MkD MkD
```
However, it panics on GHC HEAD:
```
$ ~/Software/ghc5/inplace/bin/ghc-stage2 Bug.hs -O -fforce-recomp
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 8.9.0.20191023:
emitPrimOp: handled above in cgOpApp
```
Some notes:
* The use of optimization `-O` is critical to triggering the bug.
* The panic goes away if `D` is an ordinary data type instead of a data family.
* The code in the hand-written `Ix` instance is very similar to the code you would get for a derived `Ix` instance, but with one key difference: the hand-written code uses `getTag` instead of a function that does something like this:
```hs
dTag :: D -> Int#
dTag MkD = 0#
```
If you replace all uses of `getTag` with `dTag`, then the panic goes away. As a consequence, you won't trigger the panic if you derive the `Ix` instance.8.10.1John EricsonJohn Ericsonhttps://gitlab.haskell.org/ghc/ghc/-/issues/16685Hadrian: ld crashes linking HStime on macos2019-05-28T10:55:28ZShayne Fletchershayne@shaynefletcher.orgHadrian: ld crashes linking HStime on macos@snowleopard @alp
This commit https://gitlab.haskell.org/ghc/ghc/commit/e529c65eacf595006dd5358491d28c202d673732 is where the breakage happens.
# Summary
MacOS 10.14.5, xcode 10.2 and 10.2.1, `ld` crashes in stage 1 linking `Hstime`....@snowleopard @alp
This commit https://gitlab.haskell.org/ghc/ghc/commit/e529c65eacf595006dd5358491d28c202d673732 is where the breakage happens.
# Summary
MacOS 10.14.5, xcode 10.2 and 10.2.1, `ld` crashes in stage 1 linking `Hstime`.
# Steps to reproduce
Build commands:
```
git clone https://gitlab.haskell.org/ghc/ghc.git
cd ghc
git submodule update --init --recursive
stack build --stack-yaml=hadrian/stack.yaml --only-dependencies
hadrian/build.stack.sh --configure --flavour=quickest -j
```
The error :
```
0 0x1052e2748 __assert_rtn + 129
1 0x1052be30f ld::Fixup::Fixup(unsigned int, ld::Fixup::Cluster, ld::Fixup::Kind, bool, char const*) + 95
2 0x1052e8736 mach_o::relocatable::Parser<x86_64>::addFixup(mach_o::relocatable::Parser<x86_64>::SourceLocation const&, ld::Fixup::Cluster, ld::Fixup::Kind, bool, char const*) + 34
3 0x1052eaa9c mach_o::relocatable::Section<x86_64>::addRelocFixup(mach_o::relocatable::Parser<x86_64>&, macho_relocation_info<Pointer64<LittleEndian> > const*) + 1722
4 0x1052ff61b mach_o::relocatable::Section<x86_64>::makeFixups(mach_o::relocatable::Parser<x86_64>&, mach_o::relocatable::Parser<x86_64>::CFI_CU_InfoArrays const&) + 105
5 0x1052faa66 mach_o::relocatable::Parser<x86_64>::parse(mach_o::relocatable::ParserOptions const&) + 2120
6 0x1052f1250 mach_o::relocatable::Parser<x86_64>::parse(unsigned char const*, unsigned long long, char const*, long, ld::File::Ordinal, mach_o::relocatable::ParserOptions const&) + 282
7 0x10534352a ld::tool::InputFiles::makeFile(Options::FileInfo const&, bool) + 808
8 0x105345f22 ld::tool::InputFiles::parseWorkerThread() + 530
9 0x7fff70a6b2eb _pthread_body + 126
10 0x7fff70a6e249 _pthread_start + 66
A linker snapshot was created at:
/tmp/HStime-1.9.2.o-2019-04-22-132113.ld-snapshot
ld: Assertion failed: (name != NULL), function Fixup, file /Library/Caches/com.apple.xbs/Sources/ld64/ld64-450.3/src/ld/ld.hpp, line 724.
)
```
This happens with at least ghc 8.6.4, resolvers lts-13.14 and lts-13.21.8.10.1John EricsonJohn Ericsonhttps://gitlab.haskell.org/ghc/ghc/-/issues/16658GHC does not build on macOS+nix2019-05-28T03:51:24ZVladislav ZavialovGHC does not build on macOS+nix# Summary
A recent change to GHC broke my development workflow on a macOS. After a `git pull`, I can no longer build GHC. Here's the build system output:
```
| Run Ghc LinkHs Stage1: _build/stage1/utils/runghc/build/Main.dyn_o => _buil...# Summary
A recent change to GHC broke my development workflow on a macOS. After a `git pull`, I can no longer build GHC. Here's the build system output:
```
| Run Ghc LinkHs Stage1: _build/stage1/utils/runghc/build/Main.dyn_o => _build/stage1/bin/runghc
Undefined symbols for architecture x86_64:
"_base_GHCziWord_W64zh_con_info", referenced from:
-u command line option
"_base_GHCziWord_W8zh_con_info", referenced from:
-u command line option
"_base_GHCziInt_I64zh_con_info", referenced from:
-u command line option
"_base_GHCziInt_I32zh_con_info", referenced from:
-u command line option
"_base_GHCziStable_StablePtr_con_info", referenced from:
-u command line option
"_base_GHCziInt_I16zh_con_info", referenced from:
-u command line option
"_base_GHCziInt_I8zh_con_info", referenced from:
-u command line option
"_ghczmprim_GHCziTypes_Dzh_con_info", referenced from:
-u command line option
"_ghczmprim_GHCziTypes_Czh_con_info", referenced from:
-u command line option
"_base_GHCziTopHandler_runMainIO_closure", referenced from:
-u command line option
"_base_GHCziTopHandler_flushStdHandles_closure", referenced from:
-u command line option
"_base_GHCziConcziSignal_runHandlersPtr_closure", referenced from:
-u command line option
"_base_GHCziWord_W16zh_con_info", referenced from:
-u command line option
"_base_GHCziPtr_FunPtr_con_info", referenced from:
-u command line option
"_base_GHCziPtr_Ptr_con_info", referenced from:
-u command line option
"_base_GHCziEventziThread_blockedOnBadFD_closure", referenced from:
-u command line option
"_base_GHCziIOziException_cannotCompactFunction_closure", referenced from:
-u command line option
"_base_GHCziConcziIO_ioManagerCapabilitiesChanged_closure", referenced from:
-u command line option
"_ghczmprim_GHCziTypes_Izh_con_info", referenced from:
-u command line option
"_base_GHCziConcziSync_runSparks_closure", referenced from:
-u command line option
"_base_GHCziConcziIO_ensureIOManagerIsRunning_closure", referenced from:
-u command line option
"_base_GHCziTopHandler_runIO_closure", referenced from:
-u command line option
"_base_GHCziIOziException_cannotCompactPinned_closure", referenced from:
-u command line option
"_base_ControlziExceptionziBase_nonTermination_closure", referenced from:
-u command line option
"_ghczmprim_GHCziTypes_Wzh_con_info", referenced from:
-u command line option
"_base_GHCziIOziException_blockedIndefinitelyOnMVar_closure", referenced from:
-u command line option
"_base_GHCziWeak_runFinalizzerBatch_closure", referenced from:
-u command line option
"_base_GHCziWord_W32zh_con_info", referenced from:
-u command line option
"_base_GHCziIOziException_heapOverflow_closure", referenced from:
-u command line option
"_base_ControlziExceptionziBase_nestedAtomically_closure", referenced from:
-u command line option
"_ZCMain_main_closure", referenced from:
_main in ghc_2.o
"_base_GHCziPack_unpackCString_closure", referenced from:
-u command line option
"_base_GHCziIOziException_cannotCompactMutable_closure", referenced from:
-u command line option
"_base_GHCziIOziException_blockedIndefinitelyOnSTM_closure", referenced from:
-u command line option
"_ghczmprim_GHCziTypes_Fzh_con_info", referenced from:
-u command line option
"_ghczmprim_GHCziTypes_False_closure", referenced from:
-u command line option
"_base_GHCziIOziException_stackOverflow_closure", referenced from:
-u command line option
"_ghczmprim_GHCziTypes_True_closure", referenced from:
-u command line option
"_base_ControlziExceptionziBase_absentSumFieldError_closure", referenced from:
-u command line option
"_ghczmprim_GHCziTuple_Z0T_closure", referenced from:
-u command line option
"_base_GHCziTopHandler_runNonIO_closure", referenced from:
-u command line option
"_base_GHCziIOziException_allocationLimitExceeded_closure", referenced from:
-u command line option
ld: symbol(s) not found for architecture x86_64
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
`cc' failed in phase `Linker'. (Exit code: 1)
Error when running Shake build system:
at action, called at src/Rules.hs:69:19 in main:Rules
at need, called at src/Rules.hs:91:5 in main:Rules
* Depends on: _build/stage1/bin/runghc
* Raised the exception:
user error (Development.Shake.cmd, system command failed
Command line: _build/stage0/bin/ghc -Wall -hisuf dyn_hi -osuf dyn_o -hcsuf dyn_hc -fPIC -dynamic -hide-all-packages -no-user-package-db '-package-db _build/stage1/lib/package.conf.d' '-package-id base-4.13.0.0' '-package-id directory-1.3.3.2' '-package-id filepath-1.4.2.1' '-package-id process-1.6.5.0' '-package-id unix-2.7.2.2' -i -i_build/stage1/utils/runghc/build -i_build/stage1/utils/runghc/build/runghc/autogen -iutils/runghc/. -Iincludes -I_build/generated -I_build/stage1/utils/runghc/build -I/Users/int-index/Projects/ghc/_build/stage1/lib/x86_64-osx-ghc-8.9.0.20190514/process-1.6.5.0/include -I/Users/int-index/Projects/ghc/_build/stage1/lib/x86_64-osx-ghc-8.9.0.20190514/unix-2.7.2.2/include -I/Users/int-index/Projects/ghc/_build/stage1/lib/x86_64-osx-ghc-8.9.0.20190514/time-1.9.2/include -I/Users/int-index/Projects/ghc/_build/stage1/lib/x86_64-osx-ghc-8.9.0.20190514/bytestring-0.10.9.0/include -I/Users/int-index/Projects/ghc/_build/stage1/lib/x86_64-osx-ghc-8.9.0.20190514/base-4.13.0.0/include -I/Users/int-index/Projects/ghc/_build/stage1/lib/x86_64-osx-ghc-8.9.0.20190514/integer-gmp-1.0.2.0/include -I/Users/int-index/Projects/ghc/_build/stage1/lib/x86_64-osx-ghc-8.9.0.20190514/rts-1.0/include -I_build/generated -optc-I_build/generated -optP-include -optP_build/stage1/utils/runghc/build/runghc/autogen/cabal_macros.h -outputdir _build/stage1/utils/runghc/build -dynamic -optl-Wl,-rpath,@loader_path/../lib/x86_64-osx-ghc-8.9.0.20190514 -no-auto-link-packages -rtsopts -Wnoncanonical-monad-instances -optc-Wno-unknown-pragmas _build/stage1/utils/runghc/build/Main.dyn_o -o _build/stage1/bin/runghc -O0 -H64m -XHaskell2010 -ghcversion-file=/Users/int-index/Projects/ghc/_build/generated/ghcversion.h
Exit code: 1
Stderr:
Undefined symbols for architecture x86_64:
"_base_GHCziWord_W64zh_con_info", referenced from:
-u command line option
"_base_GHCziWord_W8zh_con_info", referenced from:
-u command line option
"_base_GHCziInt_I64zh_con_info", referenced from:
-u command line option
"_base_GHCziInt_I32zh_con_info", referenced from:
-u command line option
"_base_GHCziStable_StablePtr_con_info", referenced from:
-u command line option
"_base_GHCziInt_I16zh_con_info", referenced from:
-u command line option
"_base_GHCziInt_I8zh_con_info", referenced from:
-u command line option
"_ghczmprim_GHCziTypes_Dzh_con_info", referenced from:
-u command line option
"_ghczmprim_GHCziTypes_Czh_con_info", referenced from:
-u command line option
"_base_GHCziTopHandler_runMainIO_closure", referenced from:
-u command line option
"_base_GHCziTopHandler_flushStdHandles_closure", referenced from:
-u command line option
"_base_GHCziConcziSignal_runHandlersPtr_closure", referenced from:
-u command line option
"_base_GHCziWord_W16zh_con_info", referenced from:
-u command line option
"_base_GHCziPtr_FunPtr_con_info", referenced from:
-u command line option
"_base_GHCziPtr_Ptr_con_info", referenced from:
-u command line option
"_base_GHCziEventziThread_blockedOnBadFD_closure", referenced from:
-u command line option
"_base_GHCziIOziException_cannotCompactFunction_closure", referenced from:
-u command line option
"_base_GHCziConcziIO_ioManagerCapabilitiesChanged_closure", referenced from:
-u command line option
"_ghczmprim_GHCziTypes_Izh_con_info", referenced from:
-u command line option
"_base_GHCziConcziSync_runSparks_closure", referenced from:
-u command line option
"_base_GHCziConcziIO_ensureIOManagerIsRunning_closure", referenced from:
-u command line option
"_base_GHCziTopHandler_runIO_closure", referenced from:
-u command line option
"_base_GHCziIOziException_cannotCompactPinned_closure", referenced from:
-u command line option
"_base_ControlziExceptionziBase_nonTermination_closure", referenced from:
-u command line option
"_ghczmprim_GHCziTypes_Wzh_con_info", referenced from:
-u command line option
"_base_GHCziIOziException_blockedIndefinitelyOnMVar_closure", referenced from:
-u command line option
"_base_GHCziWeak_runFinalizzerBatch_closure", referenced from:
-u command line option
"_base_GHCziWord_W32zh_con_info", referenced from:
-u command line option
"_base_GHCziIOziException_heapOverflow_closure", referenced from:
-u command line option
"_base_ControlziExceptionziBase_nestedAtomically_closure", referenced from:
-u command line option
"_ZCMain_main_closure", referenced from:
_main in ghc_2.o
"_base_GHCziPack_unpackCString_closure", referenced from:
-u command line option
"_base_GHCziIOziException_cannotCompactMutable_closure", referenced from:
-u command line option
"_base_GHCziIOziException_blockedIndefinitelyOnSTM_closure", referenced from:
-u command line option
"_ghczmprim_GHCziTypes_Fzh_con_info", referenced from:
-u command line option
"_ghczmprim_GHCziTypes_False_closure", referenced from:
-u command line option
"_base_GHCziIOziException_stackOverflow_closure", referenced from:
-u command line option
"_ghczmprim_GHCziTypes_True_closure", referenced from:
-u command line option
"_base_ControlziExceptionziBase_absentSumFieldError_closure", referenced from:
-u command line option
"_ghczmprim_GHCziTuple_Z0T_closure", referenced from:
-u command line option
"_base_GHCziTopHandler_runNonIO_closure", referenced from:
-u command line option
"_base_GHCziIOziException_allocationLimitExceeded_closure", referenced from:
-u command line option
ld: symbol(s) not found for architecture x86_64
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
`cc' failed in phase `Linker'. (Exit code: 1)
)
```
# Steps to reproduce
```
cabal v2-install happy
nix-shell https://github.com/alpmestan/ghc.nix/archive/master.tar.gz
./boot
HAPPY=~/.cabal/bin/happy ./configure
hadrian/build.sh --flavour=Quick
```
# Expected behavior
Successful build.
# Environment
* GHC version used: HEAD.
* Operating System: macOS Mojave 10.14.48.10.1John EricsonJohn Ericson