mstorsjo / llvm-mingw

An LLVM/Clang/LLD based mingw-w64 toolchain
Other
1.99k stars 188 forks source link

"unable to execute command: program not executable" on Windows #422

Closed MyStupidUserName closed 7 months ago

MyStupidUserName commented 7 months ago

llvm-mingw-20240404-msvcrt (both i686 and x64builds) for Windows fails with an error when using gcc.exe, g++.exe or clang.exe to perform a single-step compile/link.

gcc.exe hello.c generates the error "clang-18: error: unable to execute command: program not executable".

g++ hello.cpp does the same.

This error also occurs with llvm-mingw-20240320-msvcrt on Windows.

Compiler option -c works to generate a valid .o file.

This 2-step process works to build an executable: gcc.exe -c sieve.c gcc -o sieve.exe sieve.o

2-step g++ build works also.

Running as a stand-alone installation, no MSVC. Running on Windows 7 Pro 64-bit.

0hip commented 7 months ago

llvm-mingw-20240404-msvcrt (both i686 and x64builds) for Windows fails with an error when using gcc.exe, g++.exe or clang.exe to perform a single-step compile/link.

gcc.exe hello.c generates the error "clang-18: error: unable to execute command: program not executable".

g++ hello.cpp does the same. . . . . . . . Running as a stand-alone installation, no MSVC. Running on Windows 7 Pro 64-bit.

image

Windows 10 here. For one step you could try: gcc.exe -o hello.exe hello.c

mstorsjo commented 7 months ago

This sounds weird and surprising. Especially if separate compilation and linking succeeds, but one command to both compile and link fails.

I tested this on a Windows 7 VM, with llvm-mingw-20240404-msvcrt-x86_64, and it successfully compiled and linked with one command, just by executing e.g. gcc hello.c.

MyStupidUserName commented 7 months ago

Aaaaand... I take it back.

I could not get it to work, no matter what I tried, a few days ago, but now it's all working, using clang.exe, gcc.exe, and g++.exe!

Maybe it's time to restart Windows. Kindly disregard my previous post.

mstorsjo commented 7 months ago

Ok, let's close this one then.