ghcjs / ghcjs

Haskell to JavaScript compiler, based on GHC
MIT License
2.6k stars 187 forks source link

GHC 8 #487

Open avieth opened 8 years ago

avieth commented 8 years ago

I've been trying to get GHCJS to build with GHC HEAD. There's been a bunch of breaking changes since 7.10.2, some of them described here. At least one GHC patch must be reverted. There's also been some cleanup of compile paths which looks like it can be easily dealt-with (basically copy the new GHC code?).

Code generation changes like this one have me stuck. Apparently LiveInfo and SRT were unused in GHC, and so have been removed. As far as I can tell, GHCJS does indeed use these, in Gen2/Generator.hs. Seeking advice about how to adapt to these changes.

mgsloan commented 8 years ago

I hear that luite is working on it - https://www.reddit.com/r/haskell/comments/4k1z7w/depending_on_ghcjs_risky/d3c3rif

luite commented 8 years ago

Yeah some things have changed in 8.0.1 vs the older version I was testing it on, so I'm still looking into some linker problems, but other than that it's basically done, but I want to be able to run the testsuite again on the final before I push. Sorry for the delay.

I have to admit that I forgot how I solved this thing (like many changes, this went in well after the freeze), I hope I actually did solve it :) I'll leave this open in case the SRT/LiveInfo issue needs more attention, thanks for bringing it up.

tolysz commented 8 years ago

@luite Is there a repo where people could cheer your 8.0 development? Or it is only here but we have to wait till is pretty and polish?

bgamari commented 8 years ago

Indeed it would be great if the GHC 8 work could be pushed to a branch where others might be able to use it (and perhaps even help).

spl commented 8 years ago

Just noticed the ghc-8.0 branch with a major commit: https://github.com/ghcjs/ghcjs/commit/35a438302dafe7af9fb0e5956855f5578db0be10.

luite commented 8 years ago

oops I should've mentioned that here. It doesn't build yet on Windows and GHCJSi support is still missing, since that requires some updates to use the new external interpreter infrastructure.

If that doesn't bother you, then please test. use ghcjs-boot --dev --ghcjs-boot-dev-branch ghc-8.0 --shims-dev-branch ghc-8.0 to boot.

luite commented 8 years ago

If anyone is interested in helping out with Windows support: the problem at the moment is the process package which either uses unix or Win32 depending on the build operating system.

In ghcjs-boot I kept the build operating system specific things, to be able to fix native-too support: building native and JS code at the same time. For the time being, I think native-too is not a high priority, so perhaps a reasonable fix would be to get rid of Win32 in a standard boot and always build the unix package (or some restricted derivative for the subset that we can support on node.js or similar platforms)

geraldus commented 8 years ago

Having troubles with installation on OS X 10.11. I tried to run

ghcjs-boot --dev --ghcjs-boot-dev-branch ghc-8.0 --shims-dev-branch ghc-8.0

But it complained that it requires version 7.10.3 of GHC however version 8.0.1 was found. So, I supposed that I have to rebuild ghcjs package with freshly installed GHC 8.0.1. I've pulled recent changes from hub, checked out ghc-8 branch, and run cabal install . from ghcjs folder. However it fails with error:

Configuring ghcjs-0.2.0...
Building ghcjs-0.2.0...
Failed to install ghcjs-0.2.0
Build log ( /Users/arthurfayzrakhmanov/.cabal/logs/ghcjs-0.2.0.log ):
cabal: Entering directory '.'
Configuring ghcjs-0.2.0...
Building ghcjs-0.2.0...
Preprocessing library ghcjs-0.2.0...

on the commandline: warning:
    -this-package-key is deprecated: Use -this-unit-id instead

src/Compiler/JMacro/Base.hs:1:55: warning:
    -XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS

src/Compiler/JMacro/QQ.hs:1:55: warning:
    -XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS

on the commandline: warning:
    -this-package-key is deprecated: Use -this-unit-id instead
In-place registering ghcjs-0.2.0...
setup: '/usr/local/bin/ghc-pkg' exited with an error:
ghcjs-0.2.0: Warning: haddock-interfaces:
/Users/arthurfayzrakhmanov/GitHub/ghcjs/dist/doc/html/ghcjs/ghcjs.haddock
doesn't exist or isn't a file
ghcjs-0.2.0: Warning: haddock-html:
/Users/arthurfayzrakhmanov/GitHub/ghcjs/dist/doc/html/ghcjs doesn't exist or
isn't a directory
ghcjs-0.2.0: installed package info from too old version of Cabal (key field
does not match id field)
cabal: Leaving directory '.'
cabal: Error: some packages failed to install:
ghcjs-0.2.0 failed during the building phase. The exception was:
ExitFailure 1
hellerve commented 8 years ago

I had the same problem. See this conversation.

geraldus commented 8 years ago

@hellerve oh, I have already read it. Now I'm confused too. My error message looks different from yours. How you installed ghcjs at the end?

tolysz commented 8 years ago

@geraldus From the above, I see that Cabal is not at version 1.24.0.0. I've been successful* with stack nightly as it has the right cabal and ghc versions, and the compiler compiles just fine. To summarize: cabal install cabal-install :) or how you upgrade your cabal these days; then your steps.

geraldus commented 8 years ago

@tolysz hi! I had Cabal 1.24.00 installed already (but I rebuilt it anyway). Thanks to Luite I resolved my issue, it was very simple indeed. First I tried to run cabal configure in ghcjs folder but this did not helped. Finally cabal clean make it possible to build ghcjs package and boot GHCJS.

Thank you for your participation (:

geraldus commented 8 years ago

Ok, now I see a lot of similar errors:

--  While building package base64-bytestring-1.0.0.1 using:
      <home-dir>/.stack/setup-exe-cache/x86_64-osx/setup-Simple-Cabal-1.24.0.0-ghcjs-0.2.0_ghc-8.0.1 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.24.0.0_ghcjs build --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
    Logs have been written to: <home-dir>/Haskell/sites/ecommerce-transient/.stack-work/logs/base64-bytestring-1.0.0.1.log

    uncaught exception in Haskell main thread: ReferenceError: h$runInteractiveProcess is not defined
    ReferenceError: h$runInteractiveProcess is not defined
        at h$$l0Z (<home-dir>/.stack/setup-exe-cache/x86_64-osx/setup-Simple-Cabal-1.24.0.0-ghcjs-0.2.0_ghc-8.0.1:558679:11)
        at h$runThreadSlice (<home-dir>/.stack/setup-exe-cache/x86_64-osx/setup-Simple-Cabal-1.24.0.0-ghcjs-0.2.0_ghc-8.0.1:9532:11)
        at h$runThreadSliceCatch (<home-dir>/.stack/setup-exe-cache/x86_64-osx/setup-Simple-Cabal-1.24.0.0-ghcjs-0.2.0_ghc-8.0.1:9487:12)
        at h$mainLoop (<home-dir>/.stack/setup-exe-cache/x86_64-osx/setup-Simple-Cabal-1.24.0.0-ghcjs-0.2.0_ghc-8.0.1:9480:9)
        at <home-dir>/.stack/setup-exe-cache/x86_64-osx/setup-Simple-Cabal-1.24.0.0-ghcjs-0.2.0_ghc-8.0.1:10131:13
        at <home-dir>/.stack/setup-exe-cache/x86_64-osx/setup-Simple-Cabal-1.24.0.0-ghcjs-0.2.0_ghc-8.0.1:24319:17
        at FSReqWrap.oncomplete (fs.js:82:15)
    Run the 'configure' command first.

I build one of my packages, it builds fine with GHC 8.0.1.

tolysz commented 8 years ago

h$runInteractiveProcess Is where I stuck as well.

luite commented 8 years ago

Sorry about that, the fix is now in the shims repo.

tolysz commented 8 years ago

Does anyone still have trouble to build/install/use ghcjs80 (ideally via stack)? -> https://www.reddit.com/r/haskell/comments/4zrld4/nightly20160826_ghcjs80/

geraldus commented 8 years ago

Hey @tolysz ! I can give a try stack setup tomorrow!

tolysz commented 8 years ago

The very latest...

resolver: nightly-2016-09-04
compiler: ghcjs-0.2.0.820160904_ghc-8.0.1
compiler-check: match-exact
setup-info:
  ghcjs:
    source:
      ghcjs-0.2.0.820160904_ghc-8.0.1:
         url: "http://tolysz.org/ghcjs/ghc-8.0-2016-09-05-nightly-2016-09-04-820160904.tar.gz"
         sha1: "cf4383b77f9d712133bdf54e6389c4361c57b484"
allow-newer: true

Please note the above boot uses exactly the versions from nightly... Ideally, I need to be able to specify which packages ghcjs-boot should use, g-b should patch ones it needs and install.

alios commented 8 years ago

fyi: Compiled most recent ghc-8 branch on linux x86_64 (arch linux) with ghc-8.0.1 in cabal sanbox without any issues. The ghcjs-boot --dev --ghcjs-boot-dev-branch ghc-8.0 --shims-dev-branch ghc-8.0 also completed without any issues.

tolysz commented 8 years ago

I was wondering if we should have 2 new branches one for nightly(ghc-8.0) and one for lts(master) snapshots, and just tag consecutive releases? Right now most of the packages from boot do not need to be patched... but having everything in one repo will help consolidate efforts.

Branches as in: ghcjs-boot --dev --ghcjs-boot-dev-branch ghc-8.0 --shims-dev-branch ghc-8.0

geraldus commented 8 years ago

@tolysz please excuse me so long delay. I didn't test it locally, but I've specified your compiler version in one of my projects and Travis build was green!

daig commented 7 years ago

Bump since it's been nearly a year - I see GHC8 related tickets but it'd be nice to have a cohesive picture. Is the ghc-8.0 branch basically standard now?

Also, now that ghc-8.2.1 is out, is there a timeline on including that? Will it proceed in the 8.0 branch or should it be its own branch?

ddssff commented 7 years ago

I have not yet been able to switch to version 0.2.1 due to errors like this on the browser console:

lib.js:13651 ReportIndex (UserId {_unUserId = 14}) lib.js:13651 "loadReportIndex" lib.js:13651 "reportIndexTable foobar" rts.js:7220 uncaught exception in Haskell main thread: TypeError: Cannot read property 'd1' of null