clang assembler problems

Hi,

I am trying to build clang/llvm using cmake and visual studio on a windows vista platform. When I try to build a .c file from command prompt it says it’s actually searching for gcc
to find the assembler and since i dont have gcc it’s failing to assemble the code and generating an error message.

“gcc” -v -c -o C:/Users/Kalyan/AppData/Local/Temp/cc-000001.o -x assembler c:/Users/Kalyan/AppData/Local/Temp/cc-000000.s
clang:error: unable to execute command: program not executable
clang:error: assembler command failed due to signal 1 (use -v to see invocation)

could you tell me why is the clang searching for gcc assembler. and how can i change it to point to a write assembler? what assembler does it use by the way?

Because the clang driver doesn't know how to deal with the toolchain
on Windows, it is actually looking for gcc, which is used as a
fallback when clang doesn't know the correct commands to assemble and
link files. Note that because clang only knows how to output GNU
assembler syntax on Windows, you'll need the GNU assembler (which is
available in MinGW, among other places).

-Eli

hi,
I tried this by installing MinGW. When I execute a small program like helloworld.c

#include<stdio.h>
int main()
{
printf(“\n hello world”);
return 0;
}

It gives the output as given in this snapshot. It still connects to mingw but the assembler cant figure out these statements i guess. It is giving errors as shown in the snapshot. Do you know why is it doing this?

Thanks

Hmm, I was under the impression that this was supposed to work; I
think it has something to do with the target triple. Can someone
who's been working on Windows stuff please comment?

-Eli

This is almost certainly because it's using the 'windows' target triple, not hte mingw target triple. Anton, do you know anything about this?

-Chris

Without the target triple it produces different directives for align and DB.

C:\_projects_\build-all-llvm\bin\Debug>clang.exe -v -S -o - helloworld.c
clang version 1.1 (trunk)
Target: i686-pc-win32
Thread model: posix
"C:/_projects_/build-all-llvm/bin/Debug/clang.exe" -cc1 -triple
i686-pc-win32 -S -disable-free -main-file-name helloworld.c
-mrelocation-model static
-mdisable-fp-elim -v -resource-dir
C:/_projects_/build-all-llvm/bin/lib/clang/1.1 -fmessage-length 150
-fms-extensions -fgnu-runtime -fdiagnostics-sh
ow-option -fcolor-diagnostics -o - -x c helloworld.c
clang -cc1 version 1.1 based upon llvm 2.7svn hosted on i686-pc-win32
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
C:/_projects_/build-all-llvm/bin/lib/clang/1.1/include
C:\Program Files\Microsoft Visual Studio 9.0\VC\include
C:\Program Files\Microsoft SDKs\Windows\v6.0A
End of search list.
        .text
        .globl _main
        ALIGN 16
_main:
        pushl %ebp
        movl %esp, %ebp
        subl $8, %esp
        movl $0, -4(%ebp)
        movl %esp, %eax
        movl $($_.str), (%eax)
        call _printf
        movl $0, -4(%ebp)
        movl -4(%ebp), %eax
        addl $8, %esp
        popl %ebp
        ret

        .data
$_.str:
        db "\n hello world\000"

C:\_projects_\build-all-llvm\bin\Debug>clang.exe -Xclang
-triple=i686-pc-mingw32 -v -S -o - helloworld.c
clang version 1.1 (trunk)
Target: i686-pc-win32
Thread model: posix
"C:/_projects_/build-all-llvm/bin/Debug/clang.exe" -cc1 -triple
i686-pc-win32 -S -disable-free -main-file-name helloworld.c
-mrelocation-model sta
-mdisable-fp-elim -v -resource-dir
C:/_projects_/build-all-llvm/bin/lib/clang/1.1 -fmessage-length 150
-fms-extensions -fgnu-runtime -fdiagnostics
ow-option -fcolor-diagnostics -triple=i686-pc-mingw32 -o - -x c helloworld.c
clang -cc1 version 1.1 based upon llvm 2.7svn hosted on i686-pc-win32
ignoring nonexistent directory "c:/mingw/include"
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
C:/_projects_/build-all-llvm/bin/lib/clang/1.1/include
End of search list.
        .def _main; .scl 2; .type 32; .endef
        .text
        .globl _main
        .align 16
_main:
        pushl %ebp
        movl %esp, %ebp

This is almost certainly because it's using the 'windows' target triple, not hte mingw target triple. Anton, do you know anything about this?

Yes, I'm going to drop windows target triple in favor of mingw pretty
soon. This patch just didn't reach the top of my patch queue yet :slight_smile: