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

Installing clang in Windows #8015

Open
Thomas008 opened this issue Jan 25, 2024 · 21 comments
Open

Installing clang in Windows #8015

Thomas008 opened this issue Jan 25, 2024 · 21 comments

Comments

@Thomas008
Copy link

I called clang with help of the following code:

using Clang_jll: clang
cc = clang()
run(`$cc`)

Then I get the following error:

ERROR: LoadError: failed process: Process(setenv(`'C:\Users\T460\.julia\artifacts\7d2877da43b3fef993c8488c267bb543f27414f8\tools\clang.exe'`,["WINDIR=C:\\Windows", "PATH=C:\\Julia-1.10.0\\bin;C:\\Julia-1.10.0\\bin\\..\\lib\\julia;C:\\Julia-1.10.0\\bin\\..\\lib;C:\\Julia-1.10.0\\bin;C:\\Users\\T460\\AppData\\Roaming\\Sublime Text 3\\Packages\\IJulia/windeps/;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\dotnet\\;C:\\Program Files\\Microsoft SQL Server\\150\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn\\;C:\\mingw-w64-v9.0.0\\mingw-w64-libraries;C:\\MinGW;C:\\Program Files\\CMake\\bin;C:\\mingw-w64_packagecompiler\\bin;C:\\Julia-1.10.0\\bin;C:\\Ruby27-x64\\bin;C:\\Users\\T460\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\T460\\.dotnet\\tools;C:\\Julia-1.10.0\\bin;C:\\mingw-w64_packagecompiler\\bin;C:\\llvm-mingw-20231031-ucrt-x86_64\\bin;", "ZES_ENABLE_SYSMAN=1", "USERDOMAIN_ROAMINGPROFILE=DESKTOP-0RMUE7S", "LOCALAPPDATA=C:\\Users\\T460\\AppData\\Local", "HOMEPATH=\\Users\\T460", "PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 78 Stepping 3, GenuineIntel", "NUMBER_OF_PROCESSORS=4", "PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.RB;.RBW", "SESSIONNAME=Console"  …  "DRIVERDATA=C:\\Windows\\System32\\Drivers\\DriverData", "PROCESSOR_LEVEL=6", "FPS_BROWSER_USER_PROFILE_STRING=Default", "SYSTEMDRIVE=C:", "FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer", "PROGRAMW6432=C:\\Program Files", "TEMP=C:\\Users\\T460\\AppData\\Local\\Temp", "PROCESSOR_ARCHITECTURE=AMD64", "OPENBLAS_MAIN_FREE=1", "HOMEDRIVE=C:"]), ProcessExited(3221225785)) [3221225785]

Stacktrace:
 [1] pipeline_error
   @ Base .\process.jl:565 [inlined]
 [2] run(::Cmd; wait::Bool)
   @ Base .\process.jl:480
 [3] run(::Cmd)
   @ Base .\process.jl:477
 [4] top-level scope
   @ C:\jul\staticcompiler\StaticCompiler.jl\test\stc_test.jl:7
in expression starting at C:\jul\staticcompiler\StaticCompiler.jl\test\stc_test.jl:7
[Finished in 7.8s]
@giordano
Copy link
Member

What do you expect to happen? On Linux, outside of our build of clang, I get

% clang
clang-16: error: no input files
% echo $?
1

If you don't pass any arguments you always get an error. Try at least to pass --version:

julia> run(`$(clang()) --version`);
clang version 15.0.7 (/cache/yggdrasil/downloads/clones/llvm-project.git-5a9787eb535c2edc5dea030cc221c1d60f38c9f42344f410e425ea2139e233aa 2593167b92dd2d27849e8bc331db2072a9b4bd7f)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/mose/.julia/artifacts/8de319bc5fbe2c53a9bee73fb86c43ad6a1b606a/tools

@Thomas008
Copy link
Author

Thomas008 commented Jan 26, 2024

Thank you for pointing this out.
Following your advice (and using julia 1.10, Windows 10), I get:

julia> using Clang_jll: clang

julia> run(`$(clang()) --version`);
ERROR: failed process: Process(setenv(`'C:\Users\T460\.julia\artifacts\7d2877da43b3fef993c8488c267bb543f27414f8\tools\clang.exe' --version`,["WINDIR=C:\\Windows", "PATH=C:\\Julia-1.10.0\\bin;C:\\Julia-1.10.0\\bin\\..\\lib\\julia;C:\\Julia-1.10.0\\bin\\..\\lib;C:\\Julia-1.10.0\\bin;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\dotnet\\;C:\\Program Files\\Microsoft SQL Server\\150\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn\\;C:\\mingw-w64-v9.0.0\\mingw-w64-libraries;C:\\MinGW;C:\\Program Files\\CMake\\bin;C:\\mingw-w64_packagecompiler\\bin;C:\\Julia-1.10.0\\bin;C:\\Ruby27-x64\\bin;C:\\Users\\T460\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\T460\\.dotnet\\tools;C:\\Julia-1.10.0\\bin;C:\\mingw-w64_packagecompiler\\bin;C:\\llvm-mingw-20231031-ucrt-x86_64\\bin;", "USERDOMAIN_ROAMINGPROFILE=DESKTOP-0RMUE7S", "ZES_ENABLE_SYSMAN=1", "LOCALAPPDATA=C:\\Users\\T460\\AppData\\Local", "HOMEPATH=\\Users\\T460", "PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 78 Stepping 3, GenuineIntel", "NUMBER_OF_PROCESSORS=4", "PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.RB;.RBW", "SESSIONNAME=Console"  …  "USERPROFILE=C:\\Users\\T460", "DRIVERDATA=C:\\Windows\\System32\\Drivers\\DriverData", "PROCESSOR_LEVEL=6", "SYSTEMDRIVE=C:", "=C:=C:\\Users\\T460", "PROGRAMW6432=C:\\Program Files", "TEMP=C:\\Users\\T460\\AppData\\Local\\Temp", "HOMEDRIVE=C:", "OPENBLAS_MAIN_FREE=1", "PROCESSOR_ARCHITECTURE=AMD64"]), ProcessExited(3221225785)) [3221225785]

Stacktrace:
 [1] pipeline_error
   @ Base .\process.jl:565 [inlined]
 [2] run(::Cmd; wait::Bool)
   @ Base .\process.jl:480
 [3] run(::Cmd)
   @ Base .\process.jl:477
 [4] top-level scope
   @ REPL[10]:1

@giordano
Copy link
Member

Ok, the error is the same, code is

julia> UInt32(3221225785)
0xc0000139

According to the Internet ™️ c0000139 is an "Entry Point Not Found" error. What does this mean in practice, I have no clue. I don't use Windows and I personally don't have the skills nor the motivation to debug this, so unless someone else motivated enough digs deeper into the issue, we won't do much about this.

Perhaps the question is: what do you want to do with clang?

@ViralBShah
Copy link
Member

Perhaps this needs to be filed with Clang.jl.

@rayegun
Copy link
Contributor

rayegun commented Jan 26, 2024

@ViralBShah I disagree. --version should work with just the jll, no wrapper.

I have need of direct calling Clang on Windows as well, although I haven't yet tested it

@Thomas008
Copy link
Author

Thomas008 commented Jan 26, 2024

What I want to do with clang is to compile.
I use clang in a forked repo of StaticCompiler.
StaticCompiler uses Clang_jll: clang.

My aim is to adapt StaticCompiler to Windows. What clang in this adaotion does is to generate an executable binary from a LLVM IR.
run(`cmd /c clang -Wno-override-module $wrapper_path $ir_path -o $exec_path`)
e.g. clang -Wno-override-module wrapper.c llvm_ir.ll -o executable.exe.
Using a local installation of clang, it works fine.
It would be great to use the clang in the artifact.

@giordano
Copy link
Member

Ok, that's great, but someone has to figure out what the problem is, and then how to fix it.

@giordano giordano reopened this Jan 26, 2024
@Thomas008
Copy link
Author

Well, yes, this is the reason why I posted it here: I hoped, someone would have a hint to find the problem and fix it.

@giordano
Copy link
Member

As a matter of fact very few people here around use Windows, so for debugging of Windows-related issues there's a high chance you're on your own.

I know people in the past have had some degrees of luck using tools like DependenciesGui.exe or procmon, but I'm not personally familiar with them, can't possibly help you.

@davidanthoff
Copy link
Contributor

Just running tools\clang.exe from a command line in the artifact folder shows this error:

image

If one clicks "OK" the same error message comes up again, just for different dlls, namely the following ones: libclang-cpp.dll and libLLVM-15jl.dll. This is all on Julia 1.10.3.

On Julia nightly I just get the same error about libclang-cpp.dll. But the root problem here is that clang.exe is linked to these dlls but they are not found.

@giordano
Copy link
Member

@Thomas008
Copy link
Author

@giordano I don't understand what you mean. Can you explain what exactly you are pointing to?

@giordano
Copy link
Member

If you're asking me about #8015 (comment), that was a reply to the immediately preceding message.

@Thomas008
Copy link
Author

I still don't know what exactly you want to tell by pointing to the description of ExecutableProduct. E.g. What do you think one should pay attention to, or, what is missing?

@giordano
Copy link
Member

I wasn't replying to you, I was telling David that the specific issue he was having was due to not calling the executable product correctly, which is something you were doing already.

@Zentrik
Copy link
Contributor

Zentrik commented Jun 30, 2024

I can get it working on Julia nightly with a little hack to the PATH, not sure why it's failing on earlier versions of Julia.
The tmp.env[2] *= ... is adding C:\Users\gag\.julia\artifacts\a49b93cab2267cf26cc941887b119c308d7f71e3\bin to the PATH as that's where libclang-cpp.dll is stored.

julia> using Clang_jll;

julia> tmp = `$(clang()) --version`;

julia> tmp.env[2] *= ";" * joinpath(joinpath(splitpath(clang().exec[1])[1:end-2]), "bin");

julia> run(tmp)
clang version 17.0.6 (/cache/yggdrasil/downloads/clones/llvm-project.git-5a9787eb535c2edc5dea030cc221c1d60f38c9f42344f410e425ea2139e233aa 0007e48608221f440dce2ea0d3e4f561fc10d3c6)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:\Users\gag\.julia\artifacts\a49b93cab2267cf26cc941887b119c308d7f71e3\tools

A minimal PATH is

julia> run(setenv(`$(clang()) --version`, "PATH"=>joinpath(joinpath(splitpath(clang().exec[1])[1:end-2]), "bin") * ";C:\\Users\\gag\\.julia\\juliaup\\julia-nightly\\bin"))
clang version 17.0.6 (/cache/yggdrasil/downloads/clones/llvm-project.git-5a9787eb535c2edc5dea030cc221c1d60f38c9f42344f410e425ea2139e233aa 0007e48608221f440dce2ea0d3e4f561fc10d3c6)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:\Users\gag\.julia\artifacts\a49b93cab2267cf26cc941887b119c308d7f71e3\tools
Process(setenv(`'C:\Users\gag\.julia\artifacts\a49b93cab2267cf26cc941887b119c308d7f71e3\tools\clang.exe' --version`,["PATH=C:\\Users\\gag\\.julia\\artifacts\\a49b93cab2267cf26cc941887b119c308d7f71e3\\bin;C:\\Users\\gag\\.julia\\juliaup\\julia-nightly\\bin"]), ProcessExited(0))

@Thomas008
Copy link
Author

Thank you! This seems to be very promising. I tried the lines, and the environment is extended by the right bin-directory. Unfortunately I get the same error as above.

@Zentrik
Copy link
Contributor

Zentrik commented Jul 12, 2024

Are you testing on Julia nightly? It's been working multiple times for me even with llvm 18 and LLC.

@Thomas008
Copy link
Author

Thomas008 commented Jul 15, 2024 via email

@Thomas008
Copy link
Author

Which nightly version did you use?

@Zentrik
Copy link
Contributor

Zentrik commented Jul 26, 2024

Presumably what ever was the latest 2 weeks ago, I'll try and get round to checking on a newer version.

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

No branches or pull requests

6 participants