-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Cosmopolitan libc (APE) #84
Comments
It blows my mind that Cosmopolitan can be that portable. Wow. As far as windows support, it's just buggy, and tests fail. It's likely problems with tooling (but I'm not sure). There's more info in #52. No one has spent much time getting it to work on windows. You can use WSL under windows. |
That looks very cool! Can one compile an executable using that on linux and then have it run on Windows? And/or can it be applied to LLVM IR or bitcode? If so then we might be able to get that to work. |
Yes, that's the point, and not just Windows. It doesn't work with LLVM IR/bitcode, just x86-64 instructions. Those work "every Linux distro in addition to Mac OS X, Windows NT, FreeBSD, OpenBSD, and NetBSD too". Apple's future is ARM, but it works, as I understand (still) emulated, because that's what you already have on the Mac (until apple drops it, possibly, I guess, far into the future). [Working an all Linux distros is actually problematic already, until Cosmopolitan, some do not have GNU libc (and it has sometimes broken because of updates, e.g. where I work, with our in-house language, it supported older Ubuntu, then not automatically later, until fixed); some might have e.g. musl, libc on Alpine. There's also apt vs rpm, and snap vs flatpak.] I think doing this in this project might be easy and a good proof-of-concept for Julia. Later you could do it for Julia runtime itself, then it will be portable (maybe just excluding threads, should be fixable), and Julia would take care of LLVM so source code, or LLVM IR in some form, should work too. You do not want to ship an emulator with your binary, then it's going to be that much larger, so I'm unclear on how web browsers are supported too. I'm not on Windows, so I don't know how easy WSL2 is, do you have to enable it somehow, I think it's mostly for developers who know Linux, and you have to go into that shell (and then use the Linux kernel API, no longer Windows), but Cosmopolitan will use the Windows API. It will not hide all the differences between operating systems, only for text work (and e.g. web [server]), i.e. what a libc is supposed to do (so GUI stuff still about as problematic as without this). libuv hides some, but I believe you don't use that. |
I'm trying to use both your packages, with docs as is, and I can't (docs here work, not at other package, but error here), get pipeline_error for this line:
Does something need to be preinstalled (I added clang, maybe more recent than clang-13 needed, then which and how?)?
I like the example to work before a go further, but then any pointers where I would patch this code (I think I know though...)? |
The key thing here is probably the line
```
text:(.text+0x11): undefined reference to `__stack_chk_guard’
```
In general, anything beginning with "undefined reference to” means that a function name has made it into your llvm ir that is not actually defined in the same ir module. This generally happens when you’re trying to use a Julia feature or function that requires the Julia stdlib and thus isn’t supported here.
|
Thanks, but I was just using the example from the docs, so maybe it could be changed, only have working example? Also I understand ccall can't be used, and it would be good to document that, even better point to an llvm workaround, or exactly how. Or is ccall likely to be supported soon? |
Which example from the docs? |
Sory if it wasn't clear, I meant the example there ending with:
|
Ah, well that one we certainly do want to work! What's your OS and Julia version? |
I get
and it's in the integration test suite for both StaticTools and StaticCompiler, but maybe we need to add more platforms |
I'm on Linux Mint 21 ("based on Ubuntu 22.04 LTS", both based on Debian) in case it matters. I don't think it should. Only major difference I've seen with Mint (besides windows manager), is snap isn't installed by default and prevented for use (but I got around that with instructions), and that's very unlikely to be related to this. |
Hmm, odd. Are you on the official Julia binary? And x86 or other architecture?
|
No, 64-bit. I do also have with Juliaup "1.8.1+0.x86" but I'm pretty sure I didn't use it, so I tried again just in case, and even downloaded 1.8.2 (both with juliaup and even tried bypassing it ~/.julia/juliaup/julia-1.8.2+0.x64/bin/julia and (seemingly) always get same error):
|
Just an update:
|
The smallest executable you can make right now is 17 (or was it 16?) KB for hello world. I'm curious what the current lower limit is, even for (a dummy no-op), and what you think might be the actual lower limit (with or without Cosmopolitan, or even if any libc can be skipped). Or possibly one just returning a non-default (or maybe rnd() ?) error code. What's currently the largest single component of the executable? FYI: https://github.com/niklas-heer/speed-comparison Julia is awesome there, it would be nice if tiny bit faster (and/or smaller, not sure that's what needed), to make top spot. Note also, intriguing to me, accuracy higher for Julia than C/C++, while lower tan for Fortran, and it's unclear what it means to me, or why. |
Currently executable size depends on platform... the smallest hello world I can get without Cosmopolitan on most x86 systems is ~8.4 kb, but on my M1 mac it's 33 kb; there are probably other platforms that are in between. Currently for me the same hello world with cosmopolitan is about 70kb, but there's also "cosmopolitan-tiny", which I haven't tried yet. |
Hi,
See https://justine.lol/cosmopolitan/ and APE
It may not be a priority for you to be "actually portable", but curious, why is Windows not supported? Is it simply because you've not gotten around to it or don't have access to it?
It's no huge concern of mine (nor macOS), I run Linux, I just thought with Cosmopolitan/APE would be helpful to you (and you could boot to Julia code?!).
I've opened similar issues elsewhere, e.g. at julialang, but they've been closed. It's supposedly a one line to compile with GCC, but I've not gotten around to it. I also foresee at least one problem, since it doesn't support threads, but neither do you, so might be ok for you.
See also:
https://discourse.julialang.org/t/now-that-julia-w-o-llvm-is-a-thing-how-long-before-i-can-run-julia-on-rpi-pico/87676/6
The text was updated successfully, but these errors were encountered: