valderman / haste-compiler

A GHC-based Haskell to JavaScript compiler
http://haste-lang.org
BSD 3-Clause "New" or "Revised" License
1.45k stars 109 forks source link

Is Haste supposed/known to work on FreeBSD? #410

Open WolframKahl opened 7 years ago

WolframKahl commented 7 years ago

I am trying now, for the first time, to install Haste on my PC-BSD laptop; this is essentially a thin wrapper around FreeBSD 10.3-RELEASE-p5.

With haste-compiler, I am still using 8ac3ae991bb08b41c6a92d5e1eee831941fc800a .

Identical procedure (involving a custom installation of GHC-7.10.3) works on Linux.

On the PC-BSD box I get very low-level errors from haste-boot, so my first suspicion is that maybe Haste hasn't been tried on FreeBSD yet?

Downloading Google Closure compiler...
Reading package info from "libraries/rts.pkg" ... done.
Warning: Topdown solver is deprecated
Resolving dependencies...
Configuring ghc-prim-0.4.0.0...
Building ghc-prim-0.4.0.0...
Installed ghc-prim-0.4.0.0
Reading package info from "ghc-prim-0.4.0.0.conf" ... done.
Warning: Topdown solver is deprecated
Resolving dependencies...
Configuring integer-gmp-0.5.0.0...
Building integer-gmp-0.5.0.0...
Installed integer-gmp-0.5.0.0
cleaning...
Warning: Topdown solver is deprecated
Resolving dependencies...
Configuring base-4.8.0.0...
Building base-4.8.0.0...
Failed to install base-4.8.0.0
Build log ( /usr/home/kahl/.haste-cabal/logs/base-4.8.0.0.log ):
Configuring base-4.8.0.0...
Building base-4.8.0.0...
Preprocessing library base-4.8.0.0...
In file included from include/Rts.h:216:0,
                 from Flags.hsc:32:
include/rts/storage/Block.h: In function 'Bdescr':
include/rts/storage/Block.h:171:8: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     ((((W_)p &  MBLOCK_MASK & ~BLOCK_MASK) >> (BLOCK_SHIFT-BDESCR_SHIFT))
        ^
include/rts/storage/Block.h:172:9: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
      | ((W_)p & ~MBLOCK_MASK)
         ^
In file included from include/Rts.h:217:0,
                 from Flags.hsc:32:
include/rts/storage/ClosureMacros.h: In function 'GET_CLOSURE_TAG':
include/rts/storage/ClosureMacros.h:205:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     return (StgWord)p & TAG_MASK;
            ^
include/rts/storage/ClosureMacros.h: In function 'UNTAG_CLOSURE':
include/rts/storage/ClosureMacros.h:211:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     return (StgClosure*)((StgWord)p & ~TAG_MASK);
                          ^
include/rts/storage/ClosureMacros.h:211:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     return (StgClosure*)((StgWord)p & ~TAG_MASK);
            ^
include/rts/storage/ClosureMacros.h: In function 'TAG_CLOSURE':
include/rts/storage/ClosureMacros.h:217:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     return (StgClosure*)((StgWord)p | tag);
                          ^
include/rts/storage/ClosureMacros.h:217:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     return (StgClosure*)((StgWord)p | tag);
            ^
include/rts/storage/ClosureMacros.h: In function 'LOOKS_LIKE_INFO_PTR_NOT_NULL':
include/rts/storage/ClosureMacros.h:247:45: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     StgInfoTable *info = INFO_PTR_TO_STRUCT((StgInfoTable *)p);
                                             ^
include/rts/storage/ClosureMacros.h: In function 'LOOKS_LIKE_CLOSURE_PTR':
include/rts/storage/ClosureMacros.h:258:32: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     return LOOKS_LIKE_INFO_PTR((StgWord)(UNTAG_CLOSURE((StgClosure *)(p)))->header.info);
                                ^
In file included from include/Rts.h:209:0,
                 from Flags.hsc:32:
include/rts/storage/ClosureMacros.h: In function 'stack_frame_sizeW':
include/rts/storage/InfoTables.h:390:53: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
 #define GET_LARGE_BITMAP(info) ((StgLargeBitmap*) (((StgWord) ((info)+1)) \
                                                     ^
include/rts/storage/ClosureMacros.h:431:20: note: in expansion of macro 'GET_LARGE_BITMAP'
         return 1 + GET_LARGE_BITMAP(&info->i)->size;
                    ^
include/rts/storage/InfoTables.h:390:33: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
 #define GET_LARGE_BITMAP(info) ((StgLargeBitmap*) (((StgWord) ((info)+1)) \
                                 ^
include/rts/storage/ClosureMacros.h:431:20: note: in expansion of macro 'GET_LARGE_BITMAP'
         return 1 + GET_LARGE_BITMAP(&info->i)->size;
                    ^
In file included from include/Rts.h:210:0,
                 from Flags.hsc:32:
include/rts/storage/ClosureMacros.h:434:36: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         return 2 + BCO_BITMAP_SIZE((StgBCO *)((P_)frame)[1]);
                                    ^
include/rts/storage/Closures.h:254:61: note: in definition of macro 'BCO_BITMAP'
 #define BCO_BITMAP(bco)      ((StgLargeBitmap *)((StgBCO *)(bco))->bitmap)
                                                             ^
include/rts/storage/ClosureMacros.h:434:20: note: in expansion of macro 'BCO_BITMAP_SIZE'
         return 2 + BCO_BITMAP_SIZE((StgBCO *)((P_)frame)[1]);
                    ^
In file included from include/Rts.h:234:0,
                 from Flags.hsc:32:
include/rts/Threads.h: At top level:
include/rts/Threads.h:53:1: error: unknown type name 'pid_t'
 pid_t  forkProcess     (HsStablePtr *entry);
 ^
In file included from include/Rts.h:237:0,
                 from Flags.hsc:32:
include/rts/Stable.h: In function 'deRefStablePtr':
include/rts/Stable.h:40:29: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     return stable_ptr_table[(StgWord)sp].addr;
                             ^
compiling dist/build/GHC/RTS/Flags_hsc_make.c failed (exit code 1)
command was: /usr/local/bin/gcc -c dist/build/GHC/RTS/Flags_hsc_make.c -o dist/build/GHC/RTS/Flags_hsc_make.o -fno-stack-protector -D__GLASGOW_HASKELL__=710 -D__HASTE__=006 -Dfreebsd_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dfreebsd_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -Iinclude -Idist/build/autogen -include dist/build/autogen/cabal_macros.h -I/usr/home/kahl/.haste/x86_64-freebsd-haste-0.6.0.0-ghc-7.10.3/include -I/usr/local/packages/CalcCheck5/lib/ghc-7.10.3/include/
ExitFailure 1ExitFailure 1haste-cabal.bin: Error: some packages failed to install:
base-4.8.0.0 failed during the building phase. The exception was:
ExitFailure 1
haste-boot: Command `/usr/local/packages/CalcCheck5/bin/haste-cabal' failed with error code 1

$ uname -a
FreeBSD hermes 10.3-RELEASE-p5 FreeBSD 10.3-RELEASE-p5 #0: Thu Jun 30 03:52:15 UTC 2016     root@amd64-builder.pcbsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
valderman commented 7 years ago

It's never been tested on any BSD except for OSX, I'm afraid. The build is quite brittle at the moment, but I imagine that once the build is fixed everything should probably work. Unfortunately I don't have time to spare supporting BSD, but I'd gladly merge any related PRs.

WolframKahl commented 7 years ago

On OSX, are you using clang or gcc? Any pointers where to start on this, if I get to looking into it in detail?

valderman commented 7 years ago

It's the clang GCC wrapper, I'm afraid. The best place to start is probably the system includes (as well as the ones for base). The current set is essentially a pre-configured set of Linux GHC includes, beaten with a hammer just enough times to compile on OSX and Windows too. Properly generating these from autoconf (or just beating them with a hammer some more...) would likely go a long way towards fixing the problem.

WolframKahl commented 7 years ago

Thank you! --- That at least gives me an idea.

However, I am still wondering why haste-boot compiles any C to native code at all? I thought that the native code compilation is already done, and haste-boot prepares the JavaScript libraries?