Handmade Network»Forums
33 posts
Clang-cl and Microsoft's link.exe
When I build through 4coder, Clang-cl cannot seem to find link.exe. The directory the linker is in my path, and 4coder is launched with this script

1
2
3
4
5
6
7
8
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64 -no_logo
set path=[Redacted]\Documents\project920\code;%path%

pushd [Redacted]\Documents\project920\code
start C:\4coder\4ed.exe
popd

start devenv


This is the directory for the linker in my path:
1
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.24728\bin\


But this is the error Clang-cl gives

1
2
clang-cl.exe: error: unable to execute command: program not executable
clang-cl.exe: error: linker command failed with exit code 1 (use -v to see invocation)


The full error log can be found here : https://gist.github.com/anonymous/4f334a9a5051960331ea5d78d5a79407

It's not clear what exactly is the issue. Has anyone ran into this?
498 posts
Clang-cl and Microsoft's link.exe
does that directory end up in %path% after the call to VsDevCmd.bat?
Mārtiņš Možeiko
2237 posts / 1 project
Clang-cl and Microsoft's link.exe
Edited by Mārtiņš Možeiko on
Who, from where and how calls clang-cl.exe ?
33 posts
Clang-cl and Microsoft's link.exe
Edited by Jesse on
ratchetfreak
does that directory end up in %path% after the call to VsDevCmd.bat?


Yes. I confirmed this by printing the %PATH% variable at the end of the startup script.

mmozeiko
Who, from where and how calls clang-cl.exe ?


My build.bat, which is inside my project/code directory. The actual line that gets ran is

1
clang-cl %CommonCompilerFlags% [Redacted]\project\code\jesse.cpp /LD %CommonLinkerFlags% -PDB:jesse_%random%.pdb /EXPORT:GameUpdate
498 posts
Clang-cl and Microsoft's link.exe
can you check that the %path% is properly propagated down to the build.bat?
33 posts
Clang-cl and Microsoft's link.exe
ratchetfreak
can you check that the %path% is properly propagated down to the build.bat?


Yup, it does.
Mārtiņš Možeiko
2237 posts / 1 project
Clang-cl and Microsoft's link.exe
Are you able to run clang-cl.exe successfully (including linker) from .bat file that calls VsDevCmd? Without calling 4coder.
33 posts
Clang-cl and Microsoft's link.exe
mmozeiko
Are you able to run clang-cl.exe successfully (including linker) from .bat file that calls VsDevCmd? Without calling 4coder.


Hmm, there seems to be progress here.

1
2
3
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64 -no_logo
clang-cl.exe: warning: unknown argument ignored in clang-cl: '-PDB:jesse_15885.pdb' [-Wunknown-argument]
clang-cl.exe: error: no such file or directory: '/EXPORT:GameUpdate'


But I don't know how to address these errors, because I don't know what's causing them.
Mārtiņš Možeiko
2237 posts / 1 project
Clang-cl and Microsoft's link.exe
Edited by Mārtiņš Možeiko on
clang-cl.exe doesn't support exactly same arguments as cl.exe. There are differences: http://clang.llvm.org/docs/UsersManual.html#clang-cl

You probably would want to use clang native arguments - cl.exe compatible arguments cannot express all that clang supports. I think they are there only to make porting from cl.exe to clang a bit easier.
33 posts
Clang-cl and Microsoft's link.exe
Edited by Jesse on
Yes, I am aware of those. The plan is to eventually shift over, but I need to get it working with what I have first.

Do you have an idea why calling Clang-cl from within a batch file using 4coder doesn't seem to work?
Mārtiņš Možeiko
2237 posts / 1 project
Clang-cl and Microsoft's link.exe
No idea. I don't use 4coder and have no idea how it works when calling external commands.

What happens if you put call to VsDevCmd.bat file inside build.bat?
33 posts
Clang-cl and Microsoft's link.exe
Interestingly that doesn't work. Same errors as before.
Mārtiņš Možeiko
2237 posts / 1 project
Clang-cl and Microsoft's link.exe
Then 4coder is not a problem here. You need to figure how to use clang-cl, before putting it into 4coder.
33 posts
Clang-cl and Microsoft's link.exe
mmozeiko
Then 4coder is not a problem here.


The logic for how everything goes together is now twisty enough that I don't have a clear idea how you arrived at that conclusion. Can you elaborate?
Mārtiņš Možeiko
2237 posts / 1 project
Clang-cl and Microsoft's link.exe
If build.bat sets up environment (vsdevcmd.bat) and in same file calls clang-cl, then it shouldn't matter where from build.bat is called. I haven't used VS2017, but if vsdevcmd.bat is something like vcvarsall.bat from previous VS versions, then clang-cl should work after call to vsdevcmd unless something else is wrong.