#8748 closed bug (fixed)

ghc-7.8-rc1/HEAD: --enable-unregisterised fails to build and run with threaded RTS, profiling mode

Reported by: slyfox Owned by:
Priority: high Milestone: 7.8.1
Component: Compiler Version: 7.8.1-rc1
Keywords: Cc: ptrommler@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: 8301 Differential Revisions:

Description

Steps to reproduce:

0. Pick any platform. I've performed it on amd64, but seen real failures on unreg arches: ia64, ppc64
1. pull sources
2. ./boot
3. ./configure --enable-unregisterised
# right, no build.mk
4. make

Here we see 2 kinds of bugs at once:

  1. threaded RTS misses -DNOSMP define. Looks like ghc always needs to carry that define (what is the mechanism for it BTW?), it doesn't:
      HC [stage 1] compiler/stage2/build/ExtsCompat46.o
    
    In file included from /home/slyfox/dev/git/ghc/includes/Stg.h:232:0:
        0,
                         from /tmp/ghc6527_0/ghc6527_2.hc:3:
    
    /home/slyfox/dev/git/ghc/includes/stg/Regs.h:443:2:
         error: #error BaseReg must be in a register for THREADED_RTS
         #error BaseReg must be in a register for THREADED_RTS
          ^
    

The implicit declarations are scary as well:

/tmp/ghc1420_0/ghc1420_2.hc: In function 'c7WZ_entry':

/tmp/ghc1420_0/ghc1420_2.hc:43:1:
     warning: implicit declaration of function 'hs_bswap64' [-Wimplicit-function-declaration]
     _c7X5 = hs_bswap64(*((P_)(R1.w+7)));
     ^

I naively tried naive approach:

mk/config.mk.in:

+# Unregisterised build calls c compiler for every
+# .hs file. thus pass it everywhere.
+ifneq "$(GhcWithSMP)" "YES"
+SRC_HC_OPTS += -optc-DNOSMP
+endif

but got stage2, which always SIGSEGVs.
Thus it's either incorrect fix or UNREG is broken.

  1. profiling builds (all files with -prof) miss enterFunCCS declaration:
    /tmp/ghc7183_0/ghc7183_1.p_hc: In function 's6Y_entry':
    
    /tmp/ghc7183_0/ghc7183_1.p_hc:79:40:
         error: 'enterFunCCS' undeclared (first use in this function)
         ghcFunPtr = ((void (*)(void *, void *))enterFunCCS);
                                                ^
    

Attachments (6)

ghc-HEAD-NOSMP-for-hc.patch (1007 bytes) - added by slyfox 16 months ago.
ghc-HEAD-NOSMP-for-hc.patch - add -DNOSMP for .hs compiler
ghc-HEAD-rts_prof.patch (857 bytes) - added by slyfox 16 months ago.
ghc-HEAD-rts_prof.patch - export used RTS prof bits to STG
ghc-7.8.1_rc1-fix-UNREG-threaded.patch (1.9 KB) - added by slyfox 16 months ago.
ghc-7.8.1_rc1-fix-UNREG-threaded.patch - finally fix -threaded RTS in unreg mode
ghc-7.8.1_rc1-fix-UNREG-prof.patch (2.2 KB) - added by slyfox 16 months ago.
ghc-7.8.1_rc1-fix-UNREG-prof.patch
ghc-7.8.1_rc1-fix-UNREG-system-ffi.patch (881 bytes) - added by slyfox 16 months ago.
ghc-7.8.1_rc1-fix-UNREG-system-ffi.patch
ghc-7.8.1_rc1-UNREG-deopt.patch (1.2 KB) - added by slyfox 16 months ago.
ghc-7.8.1_rc1-UNREG-deopt.patch

Download all attachments as: .zip

Change History (25)

comment:1 Changed 16 months ago by slyfox

In addition to NOSMP includes/stg/SMP.h
also contains references to WITHSMP

#elif !defined(WITHSMP)

Are they the same thing? Looks like WITHSMP is not set anywhere.

Changed 16 months ago by slyfox

ghc-HEAD-NOSMP-for-hc.patch - add -DNOSMP for .hs compiler

Changed 16 months ago by slyfox

ghc-HEAD-rts_prof.patch - export used RTS prof bits to STG

comment:2 Changed 16 months ago by slyfox

  • Status changed from new to patch

Changed 16 months ago by slyfox

ghc-7.8.1_rc1-fix-UNREG-threaded.patch - finally fix -threaded RTS in unreg mode

comment:3 Changed 16 months ago by slyfox

  • Summary changed from ghc-7.8-rc1/HEAD: --enable-unregisterised fails to build: threaded RTS, profiling mode to ghc-7.8-rc1/HEAD: --enable-unregisterised fails to build and run with threaded RTS, profiling mode

comment:4 Changed 16 months ago by slyfox

With those 3 patches I've managed to get ghci running in --enable-unregisterised mode on amd64.
Now ia64 build runs to see if it helps there (it should).

Changed 16 months ago by slyfox

ghc-7.8.1_rc1-fix-UNREG-prof.patch

comment:5 Changed 16 months ago by slyfox

Last patch adds missing declarations for hs_popcnt64.
It fixes only a warning, but very scary one,
as implicit declaration would mean

    int hs_popcnt64 (int);

Thanks!

comment:6 Changed 16 months ago by slyfox

  • Version changed from 7.6.3 to 7.8.1-rc1

comment:7 Changed 16 months ago by trommler

comment:8 Changed 16 months ago by trommler

  • Cc ptrommler@… added

Changed 16 months ago by slyfox

ghc-7.8.1_rc1-fix-UNREG-system-ffi.patch

comment:9 Changed 16 months ago by slyfox

ghc-7.8.1_rc1-fix-UNREG-system-ffi.patch fixes failure to build working
UNREG compiler when you use non-default path to libffi.

libdir was already encoded there, but not include dir.
Gentoo installs libffi to:

/usr/lib64/libffi-3.0.13/
/usr/lib64/libffi-3.0.13/include/

comment:10 Changed 16 months ago by slyfox

With minor tweaks I've got ghci on ppc64 running:

timberdoodle ghc-7.8.20140130 # inplace/bin/ghc-stage2 --info
 [("Project name","The Glorious Glasgow Haskell Compilation System")
 ,("GCC extra via C opts"," -fwrapv")
 ,("C compiler command","powerpc64-unknown-linux-gnu-gcc")
 ,("C compiler flags"," -fno-stack-protector")
 ,("C compiler link flags","")
 ,("ld command","/usr/bin/powerpc64-unknown-linux-gnu-ld")
 ,("ld flags","")
 ,("ld supports compact unwind","YES")
 ,("ld supports build-id","YES")
 ,("ld supports filelist","NO")
 ,("ld is GNU ld","YES")
 ,("ar command","/usr/bin/ar")
 ,("ar flags","q")
 ,("ar supports at file","YES")
 ,("touch command","touch")
 ,("dllwrap command","/bin/false")
 ,("windres command","/bin/false")
 ,("libtool command","libtool")
 ,("perl command","/usr/bin/perl")
 ,("target os","OSLinux")
 ,("target arch","ArchPPC_64")
 ,("target word size","8")
 ,("target has GNU nonexec stack","True")
 ,("target has .ident directive","True")
 ,("target has subsections via symbols","False")
 ,("Unregisterised","YES")
 ,("LLVM llc command","llc")
 ,("LLVM opt command","opt")
 ,("Project version","7.8.20140130")
 ,("Booter version","7.4.2")
 ,("Stage","2")
 ,("Build platform","powerpc64-unknown-linux")
 ,("Host platform","powerpc64-unknown-linux")
 ,("Target platform","powerpc64-unknown-linux")
 ,("Have interpreter","YES")
 ,("Object splitting supported","NO")
 ,("Have native code generator","NO")
 ,("Support SMP","NO")
 ,("Tables next to code","NO")
 ,("RTS ways","l debug thr thr_debug thr_l thr_p dyn debug_dyn thr_dyn thr_debug_dyn l_dyn thr_l_dyn")
 ,("Support dynamic-too","YES")
 ,("Support parallel --make","YES")
 ,("Dynamic by default","NO")
 ,("GHC Dynamic","YES")
 ,("Leading underscore","NO")
 ,("Debug on","False")
 ,("LibDir","/var/tmp/portage/dev-lang/ghc-7.8.1_rc1/work/ghc-7.8.20140130/inplace/lib")
 ,("Global Package DB","/var/tmp/portage/dev-lang/ghc-7.8.1_rc1/work/ghc-7.8.20140130/inplace/lib/package.conf.d")
 ]

timberdoodle ghc-7.8.20140130 # inplace/bin/ghc-stage2 --interactive
GHCi, version 7.8.20140130: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> 2^128
340282366920938463463374607431768211456
Prelude> 

The tweak is to build compiler/HsExpr.lhs as ghc --make -O
instead of ghc --make -O2. That makes C compiler happy.

I think it makes sense to downgrade down to -O on all UNREG arches,
as C cources are already too big to produce code of sane size.

Changed 16 months ago by slyfox

ghc-7.8.1_rc1-UNREG-deopt.patch

comment:11 Changed 16 months ago by slyfox

Setting compiler option down to -O fixe building of complete dunamic ghc/ghci on powerpc64.

comment:12 Changed 15 months ago by Austin Seipp <austin@…>

In 68f0a6a6cd5bf3374fbc4a4fb09df4cbda97b61c/ghc:

Fix --enable-unregistered by passing NOSMP to .hc compiler (#8748)

Signed-off-by: Austin Seipp <[email protected]>

comment:13 Changed 15 months ago by Austin Seipp <austin@…>

In 4bb50ed0c6246e2d45e22e79f5658db1fa8a58b3/ghc:

Fix --enable-unregistered by declaring missing RTS functions (#8748)

Signed-off-by: Austin Seipp <[email protected]>

comment:14 Changed 15 months ago by Austin Seipp <austin@…>

In ebace6969f0ec85b1caa0fea265a5f9990a23b2e/ghc:

rts/Capability.c: fix crash in -threaded mode on UNREG build

UNREG mode has quite nasty invariant to maintain:
    capabilities[0] == &MainCapability

and it's a non-heap memory, while other
capabilities are dynamically allocated.

Issue #8748

Signed-off-by: Sergei Trofimovich <[email protected]>
Signed-off-by: Austin Seipp <[email protected]>

comment:15 Changed 15 months ago by Austin Seipp <austin@…>

In 858a807d5522145e8ede9148a15bb65a0d851c00/ghc:

includes/Stg.h: add declarations for hs_popcnt and frinds

This fixes most of implicit function declarations emitted
C codegen in UNREG mode. Found by adding the following to
mk/build.mk:

    SRC_CC_OPTS += -Werror=implicit-function-declaration
    SRC_HC_OPTS += -optc-Werror=implicit-function-declaration

Issue #8748

Signed-off-by: Sergei Trofimovich <[email protected]>
Signed-off-by: Austin Seipp <[email protected]>

comment:16 Changed 15 months ago by Austin Seipp <austin@…>

In 2d0fa9aee78e5bfffb9a4580954825025a651be5/ghc:

rts/package.conf.in: fix UNREG on --with-system-libffi when include-dir is passed explicitely

Issue #8748

Signed-off-by: Sergei Trofimovich <[email protected]>
Signed-off-by: Austin Seipp <[email protected]>

comment:17 Changed 15 months ago by Austin Seipp <austin@…>

In 2d5372cfdc2236a77ec49df249f3379b93224e06/ghc:

mk/config.mk.in: lower -O2 optimization down to -O1 on UNREG

Disable -O2 optimization. Otherwise amount of generated C code makes
things very slow to compile (~5 minutes on core-i7 for 'compiler/hsSyn/HsExpr.lhs')

And sometimes not compile at all (powerpc64 overflows something
on 'compiler/hsSyn/HsExpr.lhs').

Issue #8748

Signed-off-by: Sergei Trofimovich <[email protected]>
Signed-off-by: Austin Seipp <[email protected]>

comment:18 Changed 15 months ago by thoughtpolice

  • Status changed from patch to merge

comment:19 Changed 15 months ago by thoughtpolice

  • Resolution set to fixed
  • Status changed from merge to closed

Merged in 7.8.

Note: See TracTickets for help on using tickets.