-
-
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
"hello world" windows port #5339
Conversation
13013ca
to
4d20d19
Compare
I reduced the amount of stubbing-out i've done, and removed the |
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.
Good job!
src/crystal/system/win32/random.cr
Outdated
end | ||
|
||
def self.next_u : UInt8 | ||
# Chosen by fair dice roll, guaranteed to be random. |
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.
Let's not forget that 😄
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.
Haha yeah, was nearly tempted to merge it after @ysbaddaden reviewed it positive.
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.
Honestly that would be fine. Windows support is in flux. You can barely do anything with the corelib, neither IO, GC and I suspect the event loop.
This is a preliminary attempt. Fixes such as a proper random and time support could come in subsequent pull requests. I'll happily jump on implementing Random::Secure for example.
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.
Sure, but i'd still rather merge something that compiled but raised instead of returning 4
.
It compiles with gc support already (not managed to get it to run), and IO "works", there's just not really anywhere to get the file descriptors from (File
not implemented).
Regardless, #5333 needs to get reviewed and merged first!
@@ -93,8 +112,10 @@ class File | |||
io << ", rdev=0x" | |||
rdev.to_s(16, io) | |||
io << ", size=" << size | |||
io << ", blksize=" << blksize | |||
io << ", blocks=" << blocks | |||
{% unless flag?(:win32) %} |
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.
Maybe add a comment saying that it's ignored on windows because those getter are currently not implemented and would raise?
pp.comma | ||
pp.text "blocks=#{blocks}" | ||
pp.comma | ||
{% unless flag?(:win32) %} |
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.
ditto
Great work @RX14 on this! Definitely will take this weekend to review and send some comments! Skimming through the code quickly say the constant being used for the platform is
Would be possible for you to use Looking forward dig into this over the weekend. Once again, thank you for your continuous contributions to Crystal! |
@luislavena no, |
4d20d19
to
b4e847c
Compare
This is great! I was able to follow the steps and build a working windows program with Crystal =) However, it does not only print EDIT: I figured it is caused by |
Hello @RX14, thank you for your response, I don't disagree with @ysbaddaden comment, but it appears I missed when the changes to All good, once again thank you for your response. |
b4e847c
to
29c9b9e
Compare
Rebased onto master after merging #5333. Things left to do:
If anyone wants to review (remember to use |
Do you intend to include GC here? Can't it be left as is using GC none and approach proper GC bindings in a separate PR? |
@straight-shoota the GC is easy. It's just a matter of compiling libgc for windows then linking it as-is. It probably works right now I just need to test it. |
23ca0ee
to
98b3e17
Compare
98b3e17
to
7139789
Compare
I just renamed |
7139789
to
4e4d9f3
Compare
src/gc/none.cr
Outdated
|
||
# :nodoc: | ||
def self.pthread_join(thread : LibC::PthreadT) : Void* | ||
ret = LibC.pthread_join(thread, out value) |
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.
Indentation is off here.
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.
So it is, fixed.
Shame it's impossible to get the formatter to work for macrocode.
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.
Well, that looks good 👍
First real step to get win32 support. Now I'm eager for the follow up!
2b07a3d
to
eb60796
Compare
🎉 |
If anyone is going to start implementing more windows work (it's surprisingly easy), please leave a message in this thread before starting. |
Wouldn't it be better to have a separate issue for that? Maybe with a todo list to track progress? Anyway, I'm happy to take a look at the time implementation 👍 |
@straight-shoota you're right: let's use #26 to communicate about adding support instead. |
Hm, I explicitly suggested a new issue. #26 is already cluttered with irrelevant and outdated comments. |
Fiiine, go ahead and make a new one. |
Add very minimal windows support using
Crystal::System
. The diff is much better viewed by looking at each commit seperately, and with?w=1
appended to the URL, which makes github ignore whitespace for diffs.It builds on top of #5333 by adding
lib_c
bindings for windows, stubbing out the few remaining platform-specifics (reducing this is one of the main points of improvement), then implementingErrno
,Time
,Random
, andFileDescriptor
for windows. Currently theTime
andRandom
implementations are stubbed out (the other reason why this is WIP, I need to copy the implementation of these from @txe).I mainly PRed this to motivate merging #5333 by showing how it was used in my windows port.
You can try this by checking out this PR, then doing:
with
This will print out a valid
cl
linker command which you can use after installing msvc. You will also have to compilepcre.lib
using the instructions from #3582.cc @txe, because this is the base on which you can finally start merging your port.