Clang-Cl - support for the FAcs flag?

Hello Clang-Dev-List-People,

I use clang-cl integrated to Visual Studio to compile my projects. This is working fine. I wanted to ask, if there are plans for supporting the /FAcs flag of the visual studio compiler? Or at least is there a work around?

For those how doesn’t know the flag:
It generates assembly output, but also mixes the C/C++ source code as comments into it. This really helps to find points of interest.

Kind regards

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.

I don’t think there are any plans to add it. We don’t have support for the equivalent GCC flags yet either (-Wa,-adhln, I think?), so this isn’t just a matter of hooking things up. The feature would need to be implemented from scratch.

But patches are of course gladly accepted, if you want to give it a try yourself :slight_smile:

Other ways to get what you want:

  • If you use vim, whodis ( can show the assembly of the current function and it color-codes which parts of the function become which assembly. It works reasonably well. I haven’t tried it on Windows yet, but in a chrome/win cross build on linux it worked well.
  • Ideally we’d add clang-cl support to I looked at this for a tiny bit a few months ago ( but got distracted (and I’m not super likely to get re-tracted…uh…back-on-track soon – so this would be a cool project for someone too)

I don’t think I’m good enough to make a patch for clang.
Is there at least a way to have the line numbers of the source code in the assembly output?

Yes: If you also pass /Z7 to clang-cl, then the assembly will contain debug information, containing line markers. You can also pass the assembly through a demangler (MSVC’s undname, or e.g. to unmangle function names.

$ cat
int f(int a, int b) {
int c = a + b;
int d = a * b;
return c / d;

$ bin/clang-cl /Z7 /c /FA && cat test.asm | demumble

“int __cdecl f(int,int)”: # @“\01int __cdecl f(int,int)”

.cv_loc 0 1 1 0 is_stmt 0 #
.cv_fpo_proc “int __cdecl f(int,int)” 8

%bb.0: # %entry

push ebp
.cv_fpo_pushreg ebp
mov ebp, esp
.cv_fpo_setframe ebp
sub esp, 16
.cv_fpo_stackalloc 16
mov eax, dword ptr [ebp + 12]
mov ecx, dword ptr [ebp + 8]
.cv_loc 0 1 2 0 #
mov edx, dword ptr [ebp + 8]
add edx, dword ptr [ebp + 12]
mov dword ptr [ebp - 4], edx
.cv_loc 0 1 3 0 #
mov edx, dword ptr [ebp + 8]
imul edx, dword ptr [ebp + 12]
mov dword ptr [ebp - 8], edx
.cv_loc 0 1 4 0 #
mov edx, dword ptr [ebp - 4]
mov dword ptr [ebp - 12], eax # 4-byte Spill
mov eax, edx
idiv dword ptr [ebp - 8]
mov dword ptr [ebp - 16], ecx # 4-byte Spill
add esp, 16
pop ebp

See the # comments at the end of the .cv_loc lines.