{"action":"created","issue":{"url":"https://api.github.com/repos/NodeOS/NodeOS/issues/89","labels_url":"https://api.github.com/repos/NodeOS/NodeOS/issues/89/labels{/name}","comments_url":"https://api.github.com/repos/NodeOS/NodeOS/issues/89/comments","events_url":"https://api.github.com/repos/NodeOS/NodeOS/issues/89/events","html_url":"https://github.com/NodeOS/NodeOS/pull/89","id":52872528,"number":89,"title":"Cross compiler musl","user":{"login":"piranna","id":532414,"avatar_url":"https://avatars.githubusercontent.com/u/532414?v=3","gravatar_id":"","url":"https://api.github.com/users/piranna","html_url":"https://github.com/piranna","followers_url":"https://api.github.com/users/piranna/followers","following_url":"https://api.github.com/users/piranna/following{/other_user}","gists_url":"https://api.github.com/users/piranna/gists{/gist_id}","starred_url":"https://api.github.com/users/piranna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piranna/subscriptions","organizations_url":"https://api.github.com/users/piranna/orgs","repos_url":"https://api.github.com/users/piranna/repos","events_url":"https://api.github.com/users/piranna/events{/privacy}","received_events_url":"https://api.github.com/users/piranna/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":54,"created_at":"2014-12-25T21:15:53Z","updated_at":"2015-01-01T18:40:23Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/NodeOS/NodeOS/pulls/89","html_url":"https://github.com/NodeOS/NodeOS/pull/89","diff_url":"https://github.com/NodeOS/NodeOS/pull/89.diff","patch_url":"https://github.com/NodeOS/NodeOS/pull/89.patch"},"body":"This is a work-in-progress pull-request just so we can comment on it.\r\n\r\nFinally I've managed to create a cross-toolchain and use it to compile a runnable NodeOS instance (i386-glibc -> i686-musl, I need to test x86_64 -> i386). After some tries, I got it to work using as basis [Cross Linux From Scratch - Embedded](http://clfs.org/view/clfs-embedded), that uses [musl](http://www.musl-libc.org/) as C lib instead of standard glibc. I wanted to use a glibc based system, but this is the only one I've managed to make it to work, since using the plain [Linux From Scratch](http://www.linuxfromscratch.org/) or also the standard [Compressed Linux From Scratch](http://www.clfs.org/view/CLFS-3.0.0-SYSVINIT/) (both based on glibc) was fairly overcomplicated and gave a lot of compilation problems.\r\n\r\nThis has some drawbacks that needs improvement (or not :-) ):\r\n\r\n* it's a musl based system, so compiled modules that use non-standard extensions of GNU glibc will not compile. It's a fail of the developers, so this could help to improve their code to be C standard compliant (win-win for all :-) ).\r\n* OpenSSL doesn't work well with musl (due to the use of that non-standard extensions...) and needs to be patched since [nobody](https://rt.openssl.org/Ticket/Display.html?id=2823&user=guest&pass=guest) [fix](https://rt.openssl.org/Ticket/Display.html?id=3526&user=guest&pass=guest) [it](https://rt.openssl.org/Ticket/Display.html?id=3123) :-( Luckily [it's an easy one](https://raw.githubusercontent.com/maximeh/buildroot/master/package/openssl/openssl-004-musl-termios.patch)...\r\n* GCC is not aware of musl so [it needs to be patched](http://patches.clfs.org/embedded-dev/gcc-4.7.3-musl-1.patch), too. This leads us to use a fixed GCC version, but since it's somewhat new (April 2014) and probably we'll move to [llvm](http://llvm.org/) when [Linux could be compiled with it](http://llvm.linuxfoundation.org/) so we can use one of the llvm [Javascript](http://badassjs.com/post/39573969361/llvm-js-llvm-itself-compiled-to-javascript-via) [flavours](http://leaningtech.com/cheerp/) on the userspace, then it's a fair trade by this moment.\r\n* I was not be able to use a dynamically linked Node.js executable, so I'm using a [fully-statically linked](https://github.com/joyent/node/pull/8274) one. This should be fixed in the future for loading of compiled modules and specially to exec binaries, but if we don't allow binaries at all and since now ```require()``` of modules works because musl now include the required ```dl_``` functions (at least native ones does while it was not working before, I need to test external ones), this could help to enforce a pure-Javascript environment :-) On the other hand, this also has the advantage that the memory foot-print is smaller since now the only required files on the initramfs are the console device and the Node.js executable (impossible to make it simpler!!! :-D )\r\n\r\nIt's still unstable and needs some more work and testing (please test it! :-D ), but when it's finished, NodeOS build system will be self-contained and will be easier to port it to other platforms just by updating the cross-compiler :-) Also I've been developing it as a NPM package, so when it's ready in the future we could be able to move it to be an independent project (I would love to see NodeOS self-hosted... :-D )."},"comment":{"url":"https://api.github.com/repos/NodeOS/NodeOS/issues/comments/68494264","html_url":"https://github.com/NodeOS/NodeOS/pull/89#issuecomment-68494264","issue_url":"https://api.github.com/repos/NodeOS/NodeOS/issues/89","id":68494264,"user":{"login":"netlovers","id":1451148,"avatar_url":"https://avatars.githubusercontent.com/u/1451148?v=3","gravatar_id":"","url":"https://api.github.com/users/netlovers","html_url":"https://github.com/netlovers","followers_url":"https://api.github.com/users/netlovers/followers","following_url":"https://api.github.com/users/netlovers/following{/other_user}","gists_url":"https://api.github.com/users/netlovers/gists{/gist_id}","starred_url":"https://api.github.com/users/netlovers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netlovers/subscriptions","organizations_url":"https://api.github.com/users/netlovers/orgs","repos_url":"https://api.github.com/users/netlovers/repos","events_url":"https://api.github.com/users/netlovers/events{/privacy}","received_events_url":"https://api.github.com/users/netlovers/received_events","type":"User","site_admin":false},"created_at":"2015-01-01T18:40:23Z","updated_at":"2015-01-01T18:40:23Z","body":"Yay, the rootfs seems to be working. My prompt says `NodeOS-mount-rootfs>`. You can use this patch to try it out, and work on it more: https://gist.github.com/netlovers/2d8d68ccf781f11520ae"}}