-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[WIP] Windows #3582
[WIP] Windows #3582
Conversation
(almost all stdlib doesn't work right now)
Nice! I think we should try, for one release, to push this forward until we have at least a bootstrappable compiler to work with. Then things should be much easier. I noticed some files are completely hidden behind a Another thing probably worth doing (on my side) is to mark a whole lib with a CallConvention, so all funs inside it will inherit that call convention. It looks like all windows functions use the X86_StdCall convention, right? |
This is similar to what Go does, right? Some files will probably need a full rewrite, like Some compiler support would help here, as it wouldn't be possible anymore to require
That would be awesome! (That's correct, all WinAPI follows this convention) |
Oh, the thing about |
How about being able to mark a file as ignored or not at the top of a file, similar to surrounding the whole file in a macro |
@RX14 That's a good idea. When I read the # file_windows.cr
{% return unless flag?(:windows) %}
# ... So code below the |
@asterite Honestly I wouldn't use |
src/fiber.cr
Outdated
sleep(0) | ||
{% else %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stray else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, messed up selecting which lines to commit. Fixed.
Eventually, maybe not fully duplicate implementations, but extract the OS specific calls, and limit full extracts for cases where POSIX and Windows have strictly nothing in common. Some methods may require a specific implementation, but Same for Scheduler: the overall implementation remains identical, only some helpers are POSIX specific, and some others will be Windows specific. |
I know this isn't a useful comment, but I just want to chip in and say this is wonderful stuff guys. Windows support=closer to world domination. mwahaha |
You may be familiar with libuv. I do not know why, but crystal uses different library. Maybe you can use libuv in windows port? |
What I'm doing for the Windows port is writing all the primitives from scratch using WinAPI. It's quite simple to use and I think not using abstractions here good. libevent (the one crystal uses) has poor support for IOCP, that's why I have chosen not to use it here.
One surprising fact is that Windows' async IOs are much more powerful than posix's. The first big difference is that IO on regular disk files can be asynchronous, while on Linux this is always blocking (looks like glibc does some work under the cover to simulate nonblockingness using a thread pool). Maybe we should implement a specialised solution for each platform here, to take the best each one can do.
Another technical difference: On Posix you try to do an IO operation and it fails with EWOULDBLOCK. You then wait for the IO to be readable/writeable and repeat the original operation. On Windows you start an async IO operation and then wait for the result in a event queue. The event will contain the operation results. Any library that tries to abstract all this difference in a portable interface has to lose something.
…---- On Sun, 04 Dec 2016 15:16:33 -0300 [email protected] wrote ----
You may be familiar with libuv. I do not know why, but crystal uses different library. Maybe you can use libuv in windows port?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Novice Coder and wanted some feedback. Since this thread is about Windows and there is a 1% chance I could benefit the effort I wanted to share my attempt at porting code for starting a new process from kernel32/Windows library.(linux fork?) No idea what I'm actually doing but hey, fake it till ya make it... Is this close too accurate? Would additional ports of other functions be beneficial? Or just annoying background noise, ya won't hurt my feelings. :)
|
Conflicts: src/fiber.cr src/io/file_descriptor.cr
@lbguilherme which version of wine are you using here? Sorry about that push I messed with the remote name (I didn't expect github will allow me to push on you fork :-S). I wanted to bring the to the latest crystal version and see if there is anything I can contribute with. |
The branch doesn't contain the latest changes from crystal repository, so this is why there is no failures |
@txe How hard would it be to rebase it ? |
Even if it's hard, I'm ready to rebase it and add Crystal::System. I just want to know if it will be enough to merge it finally, |
Yes. If it doesn't break tests for already supported platforms we can make it a priority to merge this, aiming at having it in 0.24. |
Good, then I will try to prepare the branch this week. |
My concern is that if nobody is willing to port this work over to It also invalidates a lot of the open PRs by renaming the posix-supporting files. Even if this PR doesn't break anything visibly outside the standard library, it does break the flow for everyone already working on crystal by renaming everything platform specific. Please, let's be patient and do windows support properly. |
Will CI allowed for Windows builds? |
@RX14, sure. Making this a priority means we should prioritize everything that stands on the way to it as well :). Maybe I rushed a bit to say it was for 0.24, but I don't see it that far. @akzhan we can start with experimental support (which is to say no-CI). I wouldn't tie this to having a CI on Windows. Otherwise we'll deadlock progress on both. |
@bararchy I was more responding to @oprypin's suggestion to merge this essentially as-is. Rebasing this to use Crystal::System is a lot of hard work and design decisions which affect linux as well (but I think it's well worth it). Plus rebasing to use AFAIK we still have the exception handling issue on windows as well, is that still an issue? That's a compiler change that can be PRed seperately right? |
As I see, @RX14 is going to create a Crystal::System version of IO::FileDescriptor, so I can wait for it and then use it as an example of Crystal::System to do PR for: process.cr, scheduler.cr, file.cr, file\stat.cr, thread.cr, dir.cr. |
Any news on this? |
@Qwerp-Derp The next step is to get #4707 merged. |
What's holding #4707 back ? |
Let's rock now that #4707 is merged 👍 |
Update #4832 is also merged 👍 |
Is there any news on this? I've been checking here every few weeks to see progress. |
There is AppVeyor for CI testing on Windows |
Just a heads up, interesting discussion from Nanobox guys with some interest in using Crystal instead of Go (see #crystal) if there was native Windows support. While Windows doesn't personally mean much to me, as a platform and for growing the exposure, Crystal could have some really great wins publicly if this were gnawed on to completion. |
Congratulations on one year anniversary of this pull request! |
If we get #5333 merged, there's a relatively tiny patch (that already works) to getting hello world working on windows. I think that hello world is working as long as it isn't ifdef hell. And after that we can finally get to merging in @txe and @lbguilherme's work. It's been a year but I think we can do it this time. |
That patch has now become #5339. I'll probably close this issue once it's merged. Although full or even basic windows support won't have been added by that PR, it'll be a slow slog of dissecting this current PR and putting it's bits in |
Thanks @RX14. I know the Nanobox guys were thrilled to hear the progress and many are excited to be able to have this opportunity to start using Crystal broadly. |
Fixes #26
Roadmap:
{% if flag?(:windows) %}
all over the core library and make the prelude portablewine clang.exe
hackcrystal.exe
and self-host itHow to use it: (from Linux)
Get the branch
win
from this fork:Install Wine: https://www.winehq.org/
Download Clang 3.8.1 for Windows x64. Install it somewhere with Wine. Make sure this works:
Install MXE from my fork (I'll get this patch upstream at some point Update gc to 7.6.0 (and add libatomic_ops because of it) mxe/mxe#1539)
Build the crystal compiler having at least LLVM 3.8 in your system. Or maybe download some older clang.exe, compactible with the LLVM in your Crystal. If needed, build it:
make
Write some simple Crystal:
And finally: Build code!
And run:
$ wine foo.exe
Hello Windows!
FAQ
When will it be ready? I'm doing it in my free time, so I really have no idea.
Why not use CYGWIN? I really believe Windows should be a first-class target and that this is fundamental for Crystal's future as a language. The more native the better. I would ditch even glibc if it were possible (at some point it will be).
How can I help? Pick a very small Crystal code. Try to compile it. See a lot of errors and crashes. Do whatever it takes to make them go away. Send a patch with your changes.