tshort / StaticCompiler.jl

Compiles Julia code to a standalone library (experimental)
Other
487 stars 31 forks source link

Fix of the adaption to Windows #163

Open Thomas008 opened 2 weeks ago

Thomas008 commented 2 weeks ago

Thank you for incorporating the pull request. There is still one line that causes that StaticCompiler does not work in Windows:

in generate_executable():

The line `cmd \c clang ` is wrong.

It must be: `cmd /c clang `

(I tried to do a pull request with the fix But when forking the code in StaticCompiler.jl differed from the one in the curent package ?!)

brenhinkeller commented 2 weeks ago

I'm not sure what you mean about code differing, but I do note that the line cmd \c clang is not in the merged PR, instead it was changed to just clang prior to merging. If you want to change that, feel free to PR though.

brenhinkeller commented 2 weeks ago

Windows support remains unofficial, but happy to continue to merge PRs

Thomas008 commented 2 weeks ago

@brenhinkeller:

I'm not sure what you mean about code differing,

I wanted to do a pull request. I forked the current repository of StaticCompiler. I compared the file StaticCompiler.jl in the forked repository and the file StaticCompiler.jl from the current package. They should be the same, I thought. The bug fix I have planned with the /c instead \c is meanful in the file StaticCompiler.jl of the current package. But in the forked repository there is no line mentioning cmd. Here is one difference: In the file StaticCompiler.jl of the current package:

            cclang = if Sys.iswindows()
                `cmd \c clang` # Not clear if the `cmd \c` is necessary
            elseif Sys.isapple()
                `clang`
            else
                clang()
            end

In the forked repository:

cclang = if Sys.iswindows()
                exec_path *= ".exe"
                `clang`
            elseif Sys.isapple()
                `clang`
            else
                clang()
            end
Thomas008 commented 2 weeks ago

The only problem why StaticCompiler does still not work in Windows is, that the clang - provided in the artifact of the package Clang_jll (used by StaticCompiler)) - does not work in Windows. https://github.com/JuliaPackaging/Yggdrasil/issues/8015

There are versions of clang.exe that do work in Windows. One has to integrate or suggest such a clang-version into Clang_jll.

The cmd /c is only a workaround such that one can use a clang that is locally installed.

brenhinkeller commented 2 weeks ago

Ah, it looks like what you're referring to as the code in the "current package" is prior to pr #160 from @daizutabi that got CI running on Windows.

We can just make a new release then, and see if that solves the problem

As an aside, it's not clear to me that the cmd is necessary, regardless of whether it is followed by /c or \c-- since run should already start a new command prompt

Thomas008 commented 2 weeks ago

Yes, the cmd seems to be necessary: On my machine with an Windows os I got:

julia> compile_executable(f, (), "C:\\jul\\staticcompiler")
ERROR: IOError: could not spawn `/c clang -Wno-override-module 'C:\jul\staticcompiler\wrapper.c' 'C:\jul\staticcompiler\f.ll' -o 'C:\jul\staticcompiler\f'`: no such file or directory (ENOENT)
brenhinkeller commented 2 weeks ago

Interesting. The windows CI that @daizutabi addes seems to be passing without it, but you're welcome to PR it back in as long as that doesn't break CI.