Truthfully, I think it would be much nicer to just have urweb itself emit a standalone C file, including the entire runtime system with it (literally, copying its source into the output .c file). Then 'building it' is as trivial as either copying and compiling, or running arm-linux-gnueabihf-gcc on your host machine, and copying the result of that.
This sounds like an unusual strategy, but was part of the design of JHC, an optimizing Haskell compiler. I think it was quite nice in practice: the single C file it spit out was perfectly portable ISO C99 and worked everywhere. Ur/Web doesn't even expose the size of native machine integers to the programmer, and the runtime weighs in at a few thousand lines, which is very manageable in terms of overhead and basic portability concerns, I think. (This is more complex with FFI libraries - but truthfully I'm not happy with them, either. I think it would be very nice if the Ur/Web compiler supported 'natively' compiling C files into a resulting Ur/Web binary, simply by taking a 'foo.c' file as input, running 'gcc', and linking it into the final link step. Perhaps that C filename could be put in the .urp file. Either way, this is a feature I like in GHC -- `ghc -O2 foo.c bar.hs` works -- and it makes it much easier to test libraries to foreign code, and I speculate 99% of everything I want to bind to does not need autoconf or any build system wrapper. This strategy can fit in fine with the whole-C-file approach, I think.) Adam, I'm not sure what your thoughts are about a strategy like this. I was actually thinking of it the other day, since I too want to deploy a small Ur/Web application on a cheap ARM machine (well, it could *probably* handle it with 2GB of RAM), and being able to just copy 'sqlite3.c' and 'urweb_output.c' and compiling that would be quite nice. But there would have to be quite a lot of 'shuffling' to support this I think, so it's a longer term goal, and I can understand if you don't care to review something like that at this time. On Tue, Feb 23, 2016 at 10:23 AM, Karen Sargsyan <[email protected]> wrote: > I came to the same conclusion, so I'm more after an easy setup for making > RPi web applications via > C code produced by Ur/Web compiler hosted on a different machine. > I'll share my setup, as soon as I figure out procedure, make script and test > on several applications. > > Karen > > > On 2/24/16 12:02 AM, Adam Chlipala wrote: >> >> Yes, let me reaffirm a general point here, which might dissuade you from >> this quest: while the Ur/Web compiler produces unusually compact >> executables, the compiler itself requires unusually much time and memory to >> execute. It's a whole-program optimizing compiler. >> >> On 02/23/2016 10:37 AM, Adrian Thompson wrote: >>> >>> Hello, >>> >>> I compiled Ur on the Beaglebone Black a long time ago. There was some >>> ARM >>> issues when compiling - I can't remember what they were. But the major >>> issue you will find is that compiling Ur requires more RAM than you would >>> expect. Add 2GB of swap (swap file) and then compile for a long time >>> lol. >>> >>> Adrian >>> >>> >>> -----Original Message----- >>> From: Ur [mailto:[email protected]] On Behalf Of karsar >>> Sent: February 23, 2016 2:11 AM >>> To: Sergey Mironov >>> Cc: The Ur programming language >>> Subject: Re: [Ur] Ur/Web on Raspbian >>> >>> I wanted to run Ur/Web compiler. I still want to try make it work on RPi, >>> but your idea to produce C code instead is probably what I need, as my >>> goal >>> is to get a working application. I'll share my results in this thread >>> later. >>> >>> With best regards, >>> Karen >>> >>> >>> -----Original message----- >>> From:Sergey Mironov <[email protected]> >>> To:karsar <[email protected]>,The Ur programming language >>> <[email protected]> Date:Tue, 23 Feb 2016 15:45:55 >>> Subject:Re: [Ur] Ur/Web on Raspbian >>> >>> Hi. Do you want to run Ur/Web the compiler on ARM or just Ur/Web >>> application? If the latter is a case, then you may think about asking >>> Ur/Web >>> to produce C-code instead of binary and then compile it with ARM GCC. You >>> will need database library to link with, but it is not a problem. AFAIK, >>> Ur/Web produces C code in any case (check out -debug flag creating >>> /tmp/webapp.c) and then compiles it with GCC. >>> >>> Regards, >>> Sergey >>> >>> PS I remember someone started similar topic on this list >>> >>> 2016-02-23 10:01 GMT+03:00 karsar <[email protected]>: >>>> >>>> Hi, >>>> >>>> As Ur/Web is after not only secure, but fast web applications, I'm >>>> interested in checking how well those will run on a system with low >>>> resources. I have several RPis (Raspberry Pi) of different >>>> generations, therefore running Ur/Web application on them (Raspiban OS) >>> >>> seems to be a way to go. Ur/Web requires MLlton (there is no MLton >>> package >>> in Raspbian, as I know) and MLton may ask more memory than RPi has. >>>> >>>> Looks like cross-compilation is the only option. Did anyone try to get >>>> Ur/Web working on RPi or other ARM based machine with low resources? If >>> >>> yes, could you provide details on the required steps? >>>> >>>> With best regards, >>>> Karen Sargsyan >>>> >>>> _______________________________________________ >>>> Ur mailing list >>>> [email protected] >>>> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur >>> >>> _______________________________________________ >>> Ur mailing list >>> [email protected] >>> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur >>> >>> >>> _______________________________________________ >>> Ur mailing list >>> [email protected] >>> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur >> >> >> >> _______________________________________________ >> Ur mailing list >> [email protected] >> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur >> > > > _______________________________________________ > Ur mailing list > [email protected] > http://www.impredicative.com/cgi-bin/mailman/listinfo/ur -- Regards, Austin - PGP: 4096R/0x91384671 _______________________________________________ Ur mailing list [email protected] http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
