LLVM compile with -emit-llvm

Is it possible to add any flags to this command so that the resulting
compile runs perfectly fine (-c builds, but does not work)?

llvm-gcc -o conftest -g -O2 -Wall -Wpointer-arith -Wuninitialized
-Wsign-compare -Wno-pointer-sign -Wformat-security -fno-builtin-memset
-emit-llvm <filename.c>

where <filename.c> contains

#include <stdio.h>

int main() {
       exit(0);
}

Thanks in advance for any assistance.

The line you have works fine for me. There have been a lot of changes related to debug info recently so make sure you are up to date. Beyond that we'd need information about your environment to help.

Note that -emit-llvm asks for LLVM intermediate representation as output; but it has no effect without -c or -S. Combined with -c it produces binary format LLVM IR; you should not expect this to be executable.

Sorry, I should have been clearer. My question deals with -emit-llvm
and -c, not -g and debug information. If you remove the -g flag from
the command I posted previously, the problem remains. Either way, I
updated my tree recently.

Oddly enough, -emit-llvm affects the compile for me without -c or -S.
When I run the aforementioned command, llvm-gcc outputs the following:

ld warning: in /var/tmp//cc7JazVe.o, file is not of required architecture
Undefined symbols:
  "_main", referenced from:
      start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

You want to remove -emit-llvm from the command line. What is the motivation to add -emit-llvm on the command line ?

Here, -emit-llvm instructs llvm-gcc (even without -c or -S) to keep llvm IR in the generated .o file. The linker is expected to handle incoming .o file that contains LLVM IR. This is part of Link Time Optimization feature.

ld warning: in /var/tmp//cc7JazVe.o, file is not of required architecture

That's perfectly correct. .o file contains LLVM IR in this case. Linker
has no information how to deal with this sort of stuff.

I'm not quite sure understand, what you're trying to do here and/or what
are your problems. Maybe it will be better if you describe what your
doing and what you want to achieve.

To put my problem into perspective, I want to run LLVM passes on the
bitcode that results from compiling the portable version of OpenSSH
(hence the need for -emit-llvm). Right now, I run ./configure and
manually modify the Makefile to include -emit-llvm in the CFLAGS. This
suffices as a workaround for now.

However, I would like not to modify the Makefile. When I run
./configure, I can pass additional CFLAGS I would like to use in the
compilation step (-emit-llvm in my case). However, Autoconf (at least
in this particular ./configure script) runs the command from my
original post as a test, which fails because llvm-gcc dies on the
compile. In essence, the Autoconf test requires an executable, but I
want to output bitcode when I compile OpenSSH; it seems like I must
continue to use the workaround. I hope that describes my situation
clearly.