Skip to content
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

Windows stdio #20

Closed
mkitti opened this issue Jul 29, 2022 · 4 comments
Closed

Windows stdio #20

mkitti opened this issue Jul 29, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@mkitti
Copy link
Contributor

mkitti commented Jul 29, 2022

Currently , stdoutp() will fail on Windows.

FATAL ERROR: Symbol "stdout"not found
signal (22): SIGABRT
in expression starting at ~\.julia\dev\StaticTools\test\testllvmio.jl:3
crt_sig_handler at /cygdrive/c/buildbot/worker/package_win64/build/src\signals-win.c:92
raise at C:\WINDOWS\System32\msvcrt.dll (unknown line)
abort at C:\WINDOWS\System32\msvcrt.dll (unknown line)
addModule at /cygdrive/c/buildbot/worker/package_win64/build/src\jitlayers.cpp:763

To get C stdio on Windows, I think we need to implement the equivalent of these calls. __iob_func is defined in msvcrt.dll.

ccall(:__iob_func, Ptr{Nothing}, (Cuint,), 0) #stdin
ccall(:__iob_func, Ptr{Nothing}, (Cuint,), 1) #stdout
ccall(:__iob_func, Ptr{Nothing}, (Cuint,), 2) #stderr

Do you have a method for converting these to their llvmcall equivalents?

@brenhinkeller
Copy link
Owner

brenhinkeller commented Jul 29, 2022

Ah yeah, I currently haven't implemented any windows-specific options just because StaticCompiler.jl currently doesn't support Windows AFAIU (except I suppose via WSL). Of course, that's no reason we can't add them here in the meanwhile if we can figure out the right llvm IR!

Ah good question. My approach to figuring out the right LLVM IR to add has been looking at what gets generated either by (A) @code_llvm on equivalent Julia code or
(B) getting hold of a C program that does what I want and compiling it to LLVM IR with e.g. clang -emit-llvm -S foo.c -o foo.ll

@brenhinkeller
Copy link
Owner

brenhinkeller commented Jul 29, 2022

In principle (A) could work on those ccalls as long as you put them in a dummy function first so they can be compiled, but I think (A) also generally doesn't show you the variable and function definitions that come outside of the main function though so (B) is normally my go-to.

@brenhinkeller brenhinkeller added the enhancement New feature or request label Aug 4, 2022
@Thomas008
Copy link

Thomas008 commented Dec 5, 2023

Here is a link to further investigations to make StaticCompiler possible for Windows:
https://discourse.julialang.org/t/how-to-compile-to-stand-alone-executable-using-staticcompiler-in-windows/106767

@brenhinkeller
Copy link
Owner

Closed by #58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants