Ticket #5357 (closed bug: fixed)

Opened 22 months ago

Last modified 17 months ago

ghc-7.2.1-rc1 broke unregisterised build

Reported by: slyfox Owned by: simonmar
Priority: highest Milestone: 7.4.1
Component: Compiler Version:
Keywords: Cc: batterseapower@…, dterei
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Building GHC failed Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Tried to build unregisterised ghc:

"inplace/bin/ghc-stage1" -keep-tmp-files  -H32m -O -optc-mieee -opta-mieee -optc-mcpu=ev4 -opta-mcpu=ev4 -w    -package-name integer-gmp-0.3.0.0 -hide-all-packages -i -ilibraries/integer-gmp/. -ilibraries/integer-gmp/dist-install/build -ilibraries/integer-gmp/dist-install/build/autogen -Ilibraries/integer-gmp/dist-install/build -Ilibraries/integer-gmp/dist-install/build/autogen -Ilibraries/integer-gmp/.    -optP-include -optPlibraries/integer-gmp/dist-install/build/autogen/cabal_macros.h -package ghc-prim-0.2.0.0  -package-name integer-gmp -XHaskell98 -XCPP -XMagicHash -XUnboxedTuples -XNoImplicitPrelude -XForeignFunctionInterface -XUnliftedFFITypes -O2 -no-user-package-conf -rtsopts     -odir libraries/integer-gmp/dist-install/build -hidir libraries/integer-gmp/dist-install/build -stubdir libraries/integer-gmp/dist-install/build -hisuf hi -osuf  o -hcsuf hc -c libraries/integer-gmp/./GHC/Integer/Type.hs -o libraries/integer-gmp/dist-install/build/GHC/Integer/Type.o

/var/tmp/portage/dev-lang/ghc-7.2.0.20110728/temp/ghc11901_0/ghc11901_0.hc:33:0:
     error: static declaration of ‘integerzmgmp_GHCziIntegerziType_Szh_info’ follows non-static declaration

/var/tmp/portage/dev-lang/ghc-7.2.0.20110728/temp/ghc11901_0/ghc11901_0.hc:6:0:
     error: previous declaration of ‘integerzmgmp_GHCziIntegerziType_Szh_info’ was here

/var/tmp/portage/dev-lang/ghc-7.2.0.20110728/temp/ghc11901_0/ghc11901_0.hc:64:0:
     error: static declaration of ‘integerzmgmp_GHCziIntegerziType_Jzh_info’ follows non-static declaration

/var/tmp/portage/dev-lang/ghc-7.2.0.20110728/temp/ghc11901_0/ghc11901_0.hc:36:0:
     error: previous declaration of ‘integerzmgmp_GHCziIntegerziType_Jzh_info’ was here
make[1]: *** [libraries/integer-gmp/dist-install/build/GHC/Integer/Type.o] Error 1

And yes, the .hs file contains incoherent declarations:

EI_(integerzmgmp_GHCziIntegerziType_Szh_info);
StgWord integerzmgmp_GHCziIntegerziType_Szh_closure[] = {
(W_)&integerzmgmp_GHCziIntegerziType_Szh_info
};
...
static StgWord integerzmgmp_GHCziIntegerziType_Szh_info[] = {
(W_)&integerzmgmp_GHCziIntegerziType_Szh_entry, 0x0, 0xfUL, 0x100000004UL
};

The architecture is alpha-linux, but I think it's a generic problem. Looks like it's occured after Max's (CCed) _info export change:

commit dd391759500ab2b6abd23d502ade7ff8946c780f
Author: Max Bolingbroke <batterseapower@hotmail.com>
Date:   Wed Jul 6 18:01:02 2011 +0100

    Don't export the _info symbol for the data constructor worker bindings

    This is safe because GHC never generates a fast call to a data constructor
    worker: if the call is seen statically it will be eta-expanded and the
    allocation of the data will be inlined. We still need to export the _closure
    in case the constructor is used in an unapplied fashion.

Thanks!

Change History

Changed 22 months ago by igloo

  • priority changed from normal to highest
  • milestone set to 7.2.1

Thanks for the report

Changed 22 months ago by batterseapower

  • status changed from new to merge

I couldn't reproduce this with HEAD, but I *could* reproduce with 834dbd9ac41f8e40b31d9d2045765d03fc210d50. I think that my recent series of "refactoring" patches inadvertently fixed this problem:

81c6183dca435a0f03ec3342f8c116d5f9de2ea6..06dc1813f5cfc42010925ad7d36dff1791d846ae

If you cherry-pick these onto stable it should fix the problem.

Changed 22 months ago by igloo

These patches don't merge cleanly. Do you know exactly which change fixed it?

Changed 22 months ago by batterseapower

I don't know which one fixed it, and I wouldn't like to try to guess since the patches are interdependent. Instead I've merged them onto ghc-7.2 myself (fixing the single conflict) - is that OK?

Changed 22 months ago by igloo

  • status changed from merge to closed
  • resolution set to fixed

OK, thanks!

Changed 18 months ago by dterei

  • status changed from closed to new
  • resolution fixed deleted

Reopening as the unregisterised build is pretty broken in HEAD.

First error I get is:

/tmp/ghc30253_0/ghc30253_0.hc:1004:2:
     error: ‘free’ redeclared as different kind of symbol

/tmp/ghc30253_0/ghc30253_0.hc:473:1:
     note: previous declaration of ‘free’ was here

C code in question is:

EI_(free);
StgWord base_ForeignziMarshalziAlloc_finalizzerFree_closure[] = {
(W_)&base_GHCziPtr_FunPtr_static_info,
(W_)&free
};

// [ ... snip ...]

FN_(base_ForeignziMarshalziAlloc_zdwccall_entry) {                                                                                                                                                            
W_ _c1O6;
FB_
_c1O6 = *Sp;
Sp=Sp+1;
;EF_(free);
{void (*ghcFunPtr)(void *);
ghcFunPtr = ((void (*)(void *))(W_)&free);
ghcFunPtr((void *)_c1O6);;}
JMP_(*((P_)(*Sp)));
FE_
}

This error seems to be caused by the fact that free is imported twice in Foreign/Marshall/Alloc

foreign import ccall unsafe "stdlib.h free"    _free    :: Ptr a -> IO ()

-- | A pointer to a foreign function equivalent to 'free', which may be
-- used as a finalizer (cf 'Foreign.ForeignPtr.ForeignPtr') for storage
-- allocated with 'malloc', 'mallocBytes', 'realloc' or 'reallocBytes'.
foreign import ccall unsafe "stdlib.h &free" finalizerFree :: FinalizerPtr a 

After coming up with a hacky way to fix that error I get this second error:

/tmp/ghc9007_0/ghc9007_0.hc:16360:1:
     error: static declaration of ‘bytestringzm0zi9zi2zi0_DataziByteStringziChar8_zdwlines_entry’ follows non-static declaration

/tmp/ghc9007_0/ghc9007_0.hc:16314:1:
     note: previous declaration of ‘bytestringzm0zi9zi2zi0_DataziByteStringziChar8_zdwlines_entry’ was here

C code in question for that error is:

IF_(bytestringzm0zi9zi2zi0_DataziByteStringziChar8_zdwlines_entry); 
FN_(bytestringzm0zi9zi2zi0_DataziByteStringziChar8_zdwlines_slow) {
FB_Sp=Sp+0;
JMP_((W_)&bytestringzm0zi9zi2zi0_DataziByteStringziChar8_zdwlines_entry);
FE_
}

// [... snip ...]

FN_(bytestringzm0zi9zi2zi0_DataziByteStringziChar8_zdwlines_entry) {W_ _c6uU;W_ _c6uV;                                                                                                                                                                                                     W_ _s4XO;

As well as getting this bug fixed is it possible Ian to get an unregisterized build bot running? Every time I try using the unregisterized build it seems to have bitrotted since no one really monitors it.

Changed 18 months ago by dterei

  • os changed from Linux to Unknown/Multiple
  • architecture changed from alpha to Unknown/Multiple

Changed 18 months ago by simonmar

  • milestone changed from 7.2.1 to 7.4.1

Changed 18 months ago by dterei

Building GHC in unregisterised with the LLVM backend still works fine at least.

Changed 18 months ago by dterei

  • cc dterei added

Changed 18 months ago by igloo

  • owner set to igloo

Changed 17 months ago by simonmar

  • owner changed from igloo to simonmar
  • difficulty set to Unknown

I have a fix for the errors about free, validating now. I'm also running an unreg build so I'll see if anything else pops up.

Changed 17 months ago by simonmar

commit 0545b5500c19b7266046447c1352e936a9ee7c99

Author: Simon Marlow <marlowsd@gmail.com>
Date:   Wed Jan 4 13:29:14 2012 +0000

    dsCImport (CLabel): drop foralls when checking for FunPtr
    
    We were mislabelling some foreign imports as IsData rather than
    IsFunction, because the type was forall a. FunPtr (... a ...).
    
    Eventually this gave rise to these obscure error when compiling
    unregisterised:
    
    libraries/base/Foreign/Marshal/Alloc.hc:473:0:
         warning: built-in function ‘free’ declared as non-function
    
    libraries/base/Foreign/Marshal/Alloc.hc:1004:0:
         error: ‘free’ redeclared as different kind of symbol

Changed 17 months ago by marlowsd@…

commit 4464c92badaedc45ce53d6349f6790f6d2298103

Author: Simon Marlow <marlowsd@gmail.com>
Date:   Wed Jan 4 13:59:06 2012 +0000

    mkSlowEntryCode: enterLocalIdLabel should be enterIdLabel (#5357)

 compiler/codeGen/CgClosure.lhs |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Changed 17 months ago by marlowsd@…

commit 974f45103b930ed4310f9ec67b20399e3f289adf

Author: Simon Marlow <marlowsd@gmail.com>
Date:   Wed Jan 4 15:40:41 2012 +0000

    Fixup to 4464c92badaedc45ce53d6349f6790f6d2298103
    
    Instead of enterLocalIdLabel we should get the label from the
    ClosureInfo, because that knows better whether the label should be
    local or not.
    
    Needed by #5357

 compiler/codeGen/CgClosure.lhs   |    2 +-
 compiler/codeGen/ClosureInfo.lhs |    5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

Changed 17 months ago by marlowsd@…

commit dc179f54d895dc560be857a89c991bd11cac100f

Author: Simon Marlow <marlowsd@gmail.com>
Date:   Wed Jan 4 15:23:27 2012 +0000

    Give the correct type to CCCS
    
    Needed by #5357

 includes/stg/Regs.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Changed 17 months ago by marlowsd@…

commit 53fad2ab6cd5cd39717e74231d49444f1759fcd1

Author: Simon Marlow <marlowsd@gmail.com>
Date:   Wed Jan 4 15:23:15 2012 +0000

    Rename struct _CostCentreStack to struct CostCentreStack_ for consistency
    
    Needed by #5357

 includes/rts/prof/CCS.h |   16 ++++++++--------
 includes/stg/Regs.h     |    2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

Changed 17 months ago by marlowsd@…

commit e04da8a48ea5e8823b09f536330d6c7d796a93b5

Author: Simon Marlow <marlowsd@gmail.com>
Date:   Wed Jan 4 15:14:31 2012 +0000

    Fix for unregisterised compilation: we want registers when defined(USE_MINIINTERPRETER)
    
    Needed by #5357

 rts/StgCRun.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Changed 17 months ago by simonmar

commit 3478213ac422912df85308029e16c3f31b5a91d2

Author: Simon Marlow <marlowsd@gmail.com>
Date:   Wed Jan 4 15:13:23 2012 +0000

    Rename the CCCS field of StgTSO so as not to conflict with the CCCS pseudo-register
    
    Needed by #5357

Changed 17 months ago by simonmar

commit 2d91e04b9cedac7bdb772defc7bd23a114c4dbdb

Author: Simon Marlow <marlowsd@gmail.com>
Date:   Wed Jan 4 15:13:56 2012 +0000

    Fix for unregisterised compilation: isStrangeTypeGlobal CCCS = True
    
    Needed by #5357

Changed 17 months ago by simonmar

  • status changed from new to merge

I think I'm done here. Let's see if the overnight unregisterised build works before closing the ticket though. In the meantime all these patches need to be merged.

Changed 17 months ago by simonmar

Looks like the overnight build worked, modulo a few test failures of which I've fixed the serious ones.

Changed 17 months ago by igloo

  • status changed from merge to closed
  • resolution set to fixed

Merged as 5cbd9a2f9727017929eef1b7ade1253e1566e6dd, 3a6fe38c9a986c03a7946647dc52f5f87bec9921, ff8eaac6f7e18aae257efcf70ecb324fd00ce308, cf207c538527b69e6dab6ad3111e085e2476da1a, edbeeeadf3ab44c4190797512ab2f60650f2accf, 8a9d80eb2816b460c8d1cffd1d36e978e9d14d7c, 647f8a20e66fc3d11d7bdd8e1eaa3a9c25ab31d9, 0ea1e77a8d404ac09fea740a43da9ae880ab8187 respectively.

Note: See TracTickets for help on using tickets.