cheerp.js support

Bug #1399977 reported by Piranna
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cheerp
Opinion
Wishlist
Unassigned

Bug Description

I would like that cheerp could be used as a C/C++ compiler running on top of Node.js, so it could be used on NodeOS to compile native modules. This has some implications:

* cheerp itself compiled to Javascript
* command line Node.js executable
* C support
* generate native code (not only Javascript)
* detect when to generate native code. Node.js modules can be crafted for performance issues, but another usage is to access to low level libraries or system resources like syscalls. This last ones need native code to be generated with no other alternative

Disclaimer: I'm the lead developer of NodeOS ;-)

Revision history for this message
Alessandro Pignotti (a-pignotti) wrote :

Cheerp already supports some of the requirement you listed, namely:

* You can generate standalone JS files to be executed on Node.js. Indeed we use node.js to run the files compiled from our test suite. We don't have the required C++ header to access Node.js functionalities, but they can be crafted easily:

https://github.com/leaningtech/cheerp-wiki/wiki/Browser-side-programming-guide#accessing-the-dom-under-the-hood

* Cheerp can generate native code, it also has experimental support for generating native server side code which is transparently invoked using RPCs from code running on the client. At the moment you can use the [[server]] custom attribute on a function to have it compiled to native code, but it will also generate RPC boilerplate which is unnecessary for your use case. Something like [[native]] could be added to remove such boilerplate and only build the native code.

* C is fully supported when generating native code. When generating JavaScript there are limitations. Since C is less type safe than C++ there are idioms which works on native platforms but does not on Cheerp. I can give you some examples if you want. Moreover C code has no builtin way of accessing JS APIs as this functionality depends on C++ namespaces.

On the other hand, Cheerp can't yet be compiled in JavaScript as LLVM/clang which are the bases for Cheerp are not type safe enough. We have long term plans to make Cheerp self hosting but it's not something that it's available yet.

Revision history for this message
Piranna (piranna) wrote : Re: [Bug 1399977] Re: Node.js support

Thanks for the clarification, ver instructive :-)

In any case, I have been thinking about it and I think my requeriments are
simpler: Node.js compiled modules will run always on the server (no client
side), and if the author did it that way he has it reasons, being
performance or access to low-level libraries, so we should stick to that.
Said this, I've got to the conclussion what NodeOS needs to be able to
compile native mofules without needing a binary toolchain is:

* a C/C++ frontend build in Javascript, like clang.js
* a compiler that generates binary code for the current target also build
in Javascript, like llvm.js
* some binutils like a linker or an assembler, also build in Javascript
* all of them available as npm packages

I have searched and only found clang.js and llvm.js that were just
experiments and are abandoned, and in fact llvm.js targets to Javascript
instead of binary code. I've also found a hobby project that didn't
published the code, and Cheerp that I'm not sure if can fullfill this
requeriments list :-)
El 08/12/2014 15:15, "Alessandro Pignotti" <email address hidden>
escribió:

> Cheerp already supports some of the requirement you listed, namely:
>
> * You can generate standalone JS files to be executed on Node.js. Indeed
> we use node.js to run the files compiled from our test suite. We don't
> have the required C++ header to access Node.js functionalities, but they
> can be crafted easily:
>
> https://github.com/leaningtech/cheerp-wiki/wiki/Browser-side-
> programming-guide#accessing-the-dom-under-the-hood
>
> * Cheerp can generate native code, it also has experimental support for
> generating native server side code which is transparently invoked using
> RPCs from code running on the client. At the moment you can use the
> [[server]] custom attribute on a function to have it compiled to native
> code, but it will also generate RPC boilerplate which is unnecessary for
> your use case. Something like [[native]] could be added to remove such
> boilerplate and only build the native code.
>
> * C is fully supported when generating native code. When generating
> JavaScript there are limitations. Since C is less type safe than C++
> there are idioms which works on native platforms but does not on Cheerp.
> I can give you some examples if you want. Moreover C code has no builtin
> way of accessing JS APIs as this functionality depends on C++
> namespaces.
>
> On the other hand, Cheerp can't yet be compiled in JavaScript as
> LLVM/clang which are the bases for Cheerp are not type safe enough. We
> have long term plans to make Cheerp self hosting but it's not something
> that it's available yet.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1399977
>
> Title:
> Node.js support
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/cheerp/+bug/1399977/+subscriptions
>

Changed in cheerp:
status: New → Invalid
Revision history for this message
Piranna (piranna) wrote :

Why has been this bug set as invalid?

2015-11-07 23:24 GMT+01:00 Alessandro Pignotti <email address hidden>:
> ** Changed in: cheerp
> Status: New => Invalid
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1399977
>
> Title:
> Node.js support
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/cheerp/+bug/1399977/+subscriptions

--
"Si quieres viajar alrededor del mundo y ser invitado a hablar en un
monton de sitios diferentes, simplemente escribe un sistema operativo
Unix."
– Linus Tordvals, creador del sistema operativo Linux

Revision history for this message
Alessandro Pignotti (a-pignotti) wrote :

I made a mistake in categorizing this as invalid. Sorry about that. I think that what you are looking for is a Cheerp build that runs in JavaScript, which is not something we plan to do in the short term. I've updated the bug description accordingly and set the category of the bug to wishlist.

summary: - Node.js support
+ cheerp.js support
Changed in cheerp:
status: Invalid → Opinion
importance: Undecided → Wishlist
Revision history for this message
Piranna (piranna) wrote : Re: [Bug 1399977] Re: cheerp.js support

Ok, thank you. Yes, to describe my problem in a single sentence, what
I'm looking for is a C/C++ compiler written in Javascript that can
generate Linux .so files, that's just enough. An alternative is to use
LLVM.js that's LLVM compiled itself using Emscripten, but it's
abandoned :-(

2015-11-08 12:48 GMT+01:00 Alessandro Pignotti <email address hidden>:
> I made a mistake in categorizing this as invalid. Sorry about that. I
> think that what you are looking for is a Cheerp build that runs in
> JavaScript, which is not something we plan to do in the short term. I've
> updated the bug description accordingly and set the category of the bug
> to wishlist.
>
> ** Summary changed:
>
> - Node.js support
> + cheerp.js support
>
> ** Changed in: cheerp
> Status: Invalid => Opinion
>
> ** Changed in: cheerp
> Importance: Undecided => Wishlist
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1399977
>
> Title:
> cheerp.js support
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/cheerp/+bug/1399977/+subscriptions

--
"Si quieres viajar alrededor del mundo y ser invitado a hablar en un
monton de sitios diferentes, simplemente escribe un sistema operativo
Unix."
– Linus Tordvals, creador del sistema operativo Linux

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.