ghc-iphone and TemplateHaskell
hi, i'm trying to compile a project with ghc-iphone (ghc-iphone-binary-1.6-sdk-4.2), but some libraries (e.g. data-accessor-template) fail with an error like this: Template Haskell bracket illegal in a stage-1 compiler any ideas how to solve this problem? many thanks, <sk>
Is this a cydia app or an official app? I've had no problems with db's before on app developments on the official sdk.
Sent from my iPhone 3Gs
On 20 Ja 2011, at 08:22, Stefan Kersten
hi,
i'm trying to compile a project with ghc-iphone (ghc-iphone-binary-1.6-sdk-4.2), but some libraries (e.g. data-accessor-template) fail with an error like this:
Template Haskell bracket illegal in a stage-1 compiler
any ideas how to solve this problem?
many thanks, <sk>
_______________________________________________ iPhone mailing list iPhone@haskell.org http://www.haskell.org/mailman/listinfo/iphone
On 20.01.11 02:56, Benjamin Bin Baniyamin wrote:
Is this a cydia app or an official app?
i'm trying to compile for the simulator with iphone-simulator-ghc.
I've had no problems with db's before on app developments on the official sdk.
sorry if i'm being dense, but could you elaborate on that? have you succeeded in compiling libraries that use template haskell with iphone-ghc? the ones that fail for me in particular are data-accessor-template, hamlet and web-routes-quasi. thanks, <sk>
Stefan, The reason why Template Haskell doesn't work on the current GHC-iPhone compiler is because when I tweaked the build to cross compile, I just took the Stage 1 compiler as the cross compiler. And, by default, the stage 1 compiler doesn't support TH. It is most likely just a matter of throwing a switch in the build somewhere. I believe the TH code is interpreted, so the ARM back end should not be an issue. Unfortunately, fixing this is nowhere near my priority list at the moment. If you want to attempt it, I've given detailed instructions on how to build the compiler, so you should have no trouble. It builds well on Snow Leopard, and takes about an hour or so. I'll help with answering questions as much as I can. Steve On 20/01/11 13:22, Stefan Kersten wrote:
hi,
i'm trying to compile a project with ghc-iphone (ghc-iphone-binary-1.6-sdk-4.2), but some libraries (e.g. data-accessor-template) fail with an error like this:
Template Haskell bracket illegal in a stage-1 compiler
any ideas how to solve this problem?
many thanks, <sk>
_______________________________________________ iPhone mailing list iPhone@haskell.org http://www.haskell.org/mailman/listinfo/iphone
hi steve, On 20.01.11 22:16, Stephen Blackheath [to GHC-iPhone] wrote:
The reason why Template Haskell doesn't work on the current GHC-iPhone compiler is because when I tweaked the build to cross compile, I just took the Stage 1 compiler as the cross compiler. And, by default, the stage 1 compiler doesn't support TH.
ah, ok, that explains it! ;)
It is most likely just a matter of throwing a switch in the build somewhere. I believe the TH code is interpreted, so the ARM back end should not be an issue. Unfortunately, fixing this is nowhere near my priority list at the moment.
ok, no problem.
If you want to attempt it, I've given detailed instructions on how to build the compiler, so you should have no trouble. It builds well on Snow Leopard, and takes about an hour or so. I'll help with answering questions as much as I can.
i've built the iphone-simulator compiler by patching ghc-6.10.4 and also using 6.10.4 for compilation; thanks for the detailed build instructions! the build succeeded, but now i'll need your help; the very last output is (probably as expected): # Cross compile: We don't actually build the compiler in stage 2. #make -C compiler stage=2 # Cross compile: We only need a selection of the utils in 'utils' built for the target #make -C utils with-stage-2 # Build ghc-pkg in stage 2 because it needs different default directories # to the one we built in stage 1. (The makefile forces it to be built for the build host.) make -C utils/ghc-pkg with-stage-2 make[2]: Nothing to be done for `with-stage-2'. i've built the stage2 compiler with make -C compiler stage=2, but i'm not sure how to modify the build script to actually install that compiler. any ideas? thanks, <sk>
Stefan, If you build the stage 2 compiler using the stage 1 compiler, then the stage 2 compiler will only be able to run on the iPhone! What you need to do is change the options used in building the stage 1 compiler. Steve On 27/01/11 03:57, Stefan Kersten wrote:
hi steve,
On 20.01.11 22:16, Stephen Blackheath [to GHC-iPhone] wrote:
The reason why Template Haskell doesn't work on the current GHC-iPhone compiler is because when I tweaked the build to cross compile, I just took the Stage 1 compiler as the cross compiler. And, by default, the stage 1 compiler doesn't support TH.
ah, ok, that explains it! ;)
It is most likely just a matter of throwing a switch in the build somewhere. I believe the TH code is interpreted, so the ARM back end should not be an issue. Unfortunately, fixing this is nowhere near my priority list at the moment.
ok, no problem.
If you want to attempt it, I've given detailed instructions on how to build the compiler, so you should have no trouble. It builds well on Snow Leopard, and takes about an hour or so. I'll help with answering questions as much as I can.
i've built the iphone-simulator compiler by patching ghc-6.10.4 and also using 6.10.4 for compilation; thanks for the detailed build instructions! the build succeeded, but now i'll need your help; the very last output is (probably as expected):
# Cross compile: We don't actually build the compiler in stage 2. #make -C compiler stage=2 # Cross compile: We only need a selection of the utils in 'utils' built for the target #make -C utils with-stage-2 # Build ghc-pkg in stage 2 because it needs different default directories # to the one we built in stage 1. (The makefile forces it to be built for the build host.) make -C utils/ghc-pkg with-stage-2 make[2]: Nothing to be done for `with-stage-2'.
i've built the stage2 compiler with make -C compiler stage=2, but i'm not sure how to modify the build script to actually install that compiler. any ideas?
thanks, <sk>
On Thu, 27 Jan 2011 08:21:43 +1300, Stephen Blackheath [to GHC-iPhone] wrote:
If you build the stage 2 compiler using the stage 1 compiler, then the stage 2 compiler will only be able to run on the iPhone!
What you need to do is change the options used in building the stage 1 compiler.
ah, of course, good point. i'll see how far i get figuring out the options ... thanks, <sk>
On Wed, 26 Jan 2011 20:51:24 +0100, Stefan Kersten wrote:
On Thu, 27 Jan 2011 08:21:43 +1300, Stephen Blackheath [to GHC-iPhone] wrote:
If you build the stage 2 compiler using the stage 1 compiler, then the stage 2 compiler will only be able to run on the iPhone!
What you need to do is change the options used in building the stage 1 compiler.
ah, of course, good point. i'll see how far i get figuring out the options ...
and this excerpt from [1] indicates that TH is not possible in a stage-1 cross compiler: "If you are building GHC from source, you need at least a stage-2 bootstrap compiler to run Template Haskell. A stage-1 compiler will reject the TH constructs. Reason: TH compiles and runs a program, and then looks at the result. So it's important that the program it compiles produces results whose representations are identical to those of the compiler itself." hmm ... <sk> [1] http://www.haskell.org/ghc/docs/7.0.1/html/users_guide/template-haskell.html
Stefan, It could be that it won't work. If it compiles to core then interprets the core (like ghci does), then it would work, but it would have to get dependent libraries from somewhere, and the iPhone ones won't run. Perhaps it can be done by using the simulator compiler. Those programs actually will run natively, and at least it is possible for the dependent libraries to be close enough to being the same that it should work. Steve On 27/01/11 11:49, Stefan Kersten wrote:
On Wed, 26 Jan 2011 20:51:24 +0100, Stefan Kersten wrote:
On Thu, 27 Jan 2011 08:21:43 +1300, Stephen Blackheath [to GHC-iPhone] wrote:
If you build the stage 2 compiler using the stage 1 compiler, then the stage 2 compiler will only be able to run on the iPhone!
What you need to do is change the options used in building the stage 1 compiler.
ah, of course, good point. i'll see how far i get figuring out the options ...
and this excerpt from [1] indicates that TH is not possible in a stage-1 cross compiler:
"If you are building GHC from source, you need at least a stage-2 bootstrap compiler to run Template Haskell. A stage-1 compiler will reject the TH constructs. Reason: TH compiles and runs a program, and then looks at the result. So it's important that the program it compiles produces results whose representations are identical to those of the compiler itself."
hmm ...
<sk>
[1] http://www.haskell.org/ghc/docs/7.0.1/html/users_guide/template-haskell.html
_______________________________________________ iPhone mailing list iPhone@haskell.org http://www.haskell.org/mailman/listinfo/iphone
hi steve, On 27.01.11 00:09, Stephen Blackheath [to GHC-iPhone] wrote:
It could be that it won't work. If it compiles to core then interprets the core (like ghci does), then it would work, but it would have to get dependent libraries from somewhere, and the iPhone ones won't run. Perhaps it can be done by using the simulator compiler. Those programs actually will run natively, and at least it is possible for the dependent libraries to be close enough to being the same that it should work.
that doesn't sound impossible, but at the moment i have no idea how to approach it ;) i think for the time being i'll try to get rid of the TH dependencies in my program ... <sk>
participants (3)
-
Benjamin Bin Baniyamin -
Stefan Kersten -
Stephen Blackheath [to GHC-iPhone]