Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Allow clang-cl.exe /c -emit-llvm #34163

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR35190
Status NEW
Importance P enhancement
Reported by Andreas Haferburg (andreas.haferburg@gmx.de)
Reported on 2017-11-03 01:21:42 -0700
Last modified on 2018-06-03 17:44:34 -0700
Version 5.0
Hardware PC Windows NT
CC d.maljutin@yandex.ru, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

There is no -emit-llvm flag in gcc, but the GCC driver was extended to support -emit-llvm. The equivalent for cl.exe would be /c -emit-llvm, but it doesn't work.

What I found very surprising is that clang-cl /c -Xclang -emit-llvm hello_world.c doesn't even work. Maybe that is a bug.

All the examples on https://clang.llvm.org/docs/UsersManual.html are written for clang.exe, and they don't work anymore for clang-cl.exe.

The workaround for getting clang-cl.exe to emit IR is to run clang-cl.exe -###, and then replace the -emit-obj with -emit-llvm, which I personally find quite unintuitive.

The goal for clang-cl.exe is to be compatible with cl.exe. But in my opinion, it should also remain compatible with LLVM: clang.exe should be LLVM+gcc, and clang-cl.exe should be LLVM+cl.

Cf. https://bugs.llvm.org/show_bug.cgi?id=35120

Quuxplusone commented 6 years ago
Second this. Seems very strange that this is not working and manually adding
all ms-compatibility flags set up by clang-cl is very cumbersome.

Currently this is the error clang-cl emits when trying to -Xclang -emit-llvm:

fatal error LNK1107: invalid or corrupt file: cannot read at 0xFEA
clang-cl.exe: error: linker command failed with exit code 1107 (use -v to see
invocation)