[GHC] #7940: Building GHC 7.7.20130526 for Windows x86_64 fails with Cmm lint error

#7940: Building GHC 7.7.20130526 for Windows x86_64 fails with Cmm lint error --------------------------------+------------------------------------------- Reporter: awson | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.7 | Keywords: Os: Windows | Architecture: x86_64 (amd64) Failure: Building GHC failed | Blockedby: Blocking: | Related: --------------------------------+------------------------------------------- Building GHC 7.7.20130526 for Windows x86_64 fails with the following error: {{{ "inplace/bin/ghc-stage1.exe" -static -optc-DDEBUG -ticky -DTICKY_TICKY -O -H256m -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Irts -Irts/dist/build -DCOMPILING_RTS -package-name rts -dcmm-lint -i -irts -irts/dist/build -irts/dist/build/autogen -Irts/dist/build -Irts/dist/build/autogen -O2 -O0 -c rts/PrimOps.cmm -o rts/dist/build/PrimOps.debug_o Cmm lint error: in basic block cf in MachOp application: I32[ALLOC_PRIM_adm] + (8 + 8) op is expecting: [W32, W32] arguments provide: [I32, I64] Program was: {offset cc: _cd::I64 = R1; if (I64[CurrentNursery + 16] == 0) goto cg; else goto ci; ci: if (I64[I64[g0] + 56] >= %MO_SS_Conv_W32_W64(I32[large_alloc_lim])) goto cg; else goto ch; cg: HpAlloc = 0; R9 = stg_newByteArrayzh; R1 = _cd::I64; call stg_gc_prim_n(R1) args: 8, res: 0, upd: 8; ch: _cj::I64 = (_cd::I64 + 8 - 1) / 8; _cn::I64 = (8 + 8) / 8 + _cj::I64; _cm::I64 = allocate; _cl::I64 = BaseReg - 24; _ck::I64 = _cn::I64; (_ce::P64) = call "ccall" arg hints: [PtrHint,] result hints: [PtrHint] (_cm::I64)(_cl::I64, _ck::I64); I32[ALLOC_PRIM_ctr] = I32[ALLOC_PRIM_ctr] + 1 :: W32; I32[ALLOC_PRIM_adm] = I32[ALLOC_PRIM_adm] + (8 + 8); I32[ALLOC_PRIM_gds] = I32[ALLOC_PRIM_gds] + _cj::I64 * 8; I32[ALLOC_PRIM_slp] = I32[ALLOC_PRIM_slp] + 0; I64[_ce::P64] = stg_ARR_WORDS_info; I64[_ce::P64 + 8 + 0] = _cd::I64; R1 = _ce::P64; call (P64[(old + 8)])(R1) args: 8, res: 0, upd: 8; } <no location info>: Compilation had errors }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7940 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7940: Building GHC 7.7.20130526 (perf) for Windows x86_64 fails with Cmm lint error -------------------------------+-------------------------------------------- Reporter: awson | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Keywords: | Os: Windows Architecture: x86_64 (amd64) | Failure: Building GHC failed Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | -------------------------------+-------------------------------------------- Changes (by simonpj): * difficulty: => Unknown Comment: Is this still happening? Would anyone care to investigate? Simon -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7940#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7940: Building GHC 7.7.20130526 (perf) for Windows x86_64 fails with Cmm lint error -------------------------------+-------------------------------------------- Reporter: awson | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Keywords: | Os: Windows Architecture: x86_64 (amd64) | Failure: Building GHC failed Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | -------------------------------+-------------------------------------------- Comment(by awson): I've tried fresh 7.7.20130622 and ended on the same error. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7940#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7940: Building GHC 7.7.20130526 (perf) for Windows x86_64 fails with Cmm lint error -------------------------------+-------------------------------------------- Reporter: awson | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Keywords: | Os: Windows Architecture: x86_64 (amd64) | Failure: Building GHC failed Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | -------------------------------+-------------------------------------------- Comment(by thoughtpolice): Out of curiosity I spent 30 minutes or so eyeing this. I think I see what's going on here (hopefully!) I'll get a Win64 build machine up soon to test and push a fix. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7940#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7940: Building GHC 7.7.20130526 (perf) for Windows x86_64 fails with Cmm lint error -------------------------------+-------------------------------------------- Reporter: awson | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Keywords: | Os: Windows Architecture: x86_64 (amd64) | Failure: Building GHC failed Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | -------------------------------+-------------------------------------------- Comment(by thoughtpolice): So, just so others can take note before I mislead myself, I believe the 'root' of the problem is here in StgCmmTicky: {{{ bumpTickyLitBy :: CmmLit -> Int -> FCode () bumpTickyLitBy lhs n = do dflags <- getDynFlags -- All the ticky-ticky counters are declared "unsigned long" in C emit (addToMem (cLong dflags) (CmmLit lhs) n) bumpTickyLitByE :: CmmLit -> CmmExpr -> FCode () bumpTickyLitByE lhs e = do dflags <- getDynFlags -- All the ticky-ticky counters are declared "unsigned long" in C emit (addToMemE (cLong dflags) (CmmLit lhs) e) }}} Essentially when the Cmm parser sees 'TICKY_ALLOC_PRIM` in PrimOps.cmm, it will bump several counters defined in the RTS. The type of those counters (in Cmm terms) is specified as 'cLong dflags' in the above code. But this is only coincidentally correct on the platforms we supported until now. Most unix machines follow the LP64 data model. So on 64 bit machines, 'long' is 64 bit, and so are pointers. 'int' 32 bit. But Windows 64 follows the LLP64 model: both 'long' AND 'int' are 32bit, while 'long long' and ptrs are 64 bit. That means on Win64, 'cLong dflags' will be 32, while on Unix it would be 64. So it is only coincidental that 'long' has aligned with the native word size, until now. The invocation that triggers this in PrimOps.cmm is: {{{ stg_newByteArrayzh ( W_ n ) { W_ words, payload_words; gcptr p; MAYBE_GC_N(stg_newByteArrayzh, n); payload_words = ROUNDUP_BYTES_TO_WDS(n); words = BYTES_TO_WDS(SIZEOF_StgArrWords) + payload_words; ("ptr" p) = ccall allocate(MyCapability() "ptr",words); TICK_ALLOC_PRIM(SIZEOF_StgArrWords,WDS(payload_words),0); // <----- problematic SET_HDR(p, stg_ARR_WORDS_info, CCCS); StgArrWords_bytes(p) = n; return (p); } }}} where SIZEOF_StgArrWords comes down to the literal '8 + 8' via CPP, which I imagine is inferred as a word-sized (64bit) quantity. Thus the type error occurs when addToMemE elaborates the LHS as 32bit thanks to cLong. Also, digging into includes/stg/Types.h, we see: {{{ #if SIZEOF_VOID_P == 8 typedef StgInt64 StgInt; typedef StgWord64 StgWord; typedef StgInt32 StgHalfInt; typedef StgWord32 StgHalfWord; #define FMT_Word FMT_Word64 #define FMT_HexWord FMT_HexWord64 #define FMT_Int FMT_Int64 #else ... }}} and in includes/stg/Ticky.h: {{{ EXTERN StgInt ALLOC_PRIM_ctr INIT(0); EXTERN StgInt ALLOC_PRIM_adm INIT(0); EXTERN StgInt ALLOC_PRIM_gds INIT(0); EXTERN StgInt ALLOC_PRIM_slp INIT(0); }}} So in any case, the Ticky code comments are certainly wrong now: the counters are not of 'unsigned long.' So I think the correct thing is that ticky counters are all word sized. But looking at the code some more, this cLong business seems to be baked into the ticky stuff a bit. I'm copying a CD (slowly) to make a build machine, but perhaps someone can build on my suspicions? Thoughts? I believe Nicholas Frisby was around this area recently, so perhaps he has input. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7940#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7940: Building GHC 7.7.20130526 (perf) for Windows x86_64 fails with Cmm lint error -------------------------------+-------------------------------------------- Reporter: awson | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Keywords: | Os: Windows Architecture: x86_64 (amd64) | Failure: Building GHC failed Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | -------------------------------+-------------------------------------------- Comment(by simonpj): Thank you for looking into this. I think that by now you are the World Expert (Nick was only there incidentally to other stuff). So please go ahead and propose changes and develop a patch. (The patch is easier to review if you articulate the reasoning as you have done above.) I'm no expert about the portability details, but I know what 'ticky' is for; ticky counters are simply very low-level counters of RTS events, used for performance debugging. So having them all be word-sized would be fine I think. I suppose that they might overflow on 32-bit machines, so it would be even more ideal to make them always 64-bit; but if that was a pain we could probably live with the overflow possibility. Simon -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7940#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7940: Building GHC 7.7.20130526 (perf) for Windows x86_64 fails with Cmm lint
error
-------------------------------+--------------------------------------------
Reporter: awson | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.7
Keywords: | Os: Windows
Architecture: x86_64 (amd64) | Failure: Building GHC failed
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
-------------------------------+--------------------------------------------
Comment(by ian@…):
commit aec9b2d7092fbf8b1ba1c844d884c2ca0f229ba5
{{{
Author: Ian Lynagh

#7940: Building GHC 7.7.20130526 (perf) for Windows x86_64 fails with Cmm lint error ----------------------------------+----------------------------------------- Reporter: awson | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.7 Resolution: fixed | Keywords: Os: Windows | Architecture: x86_64 (amd64) Failure: Building GHC failed | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ----------------------------------+----------------------------------------- Changes (by igloo): * status: new => closed * resolution: => fixed Comment: thoughtpolice, thanks for the diagnosis. Fixed by the above patch. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7940#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (2)
-
GHC
-
GHC