Hi Colin,<br><br>I would definitely like to improve this, but I also think that the llvm-gcc behavior (which clang is just copying) was chosen by design. Poor design, perhaps, but I believe the intent was that -emit-llvm simply changes the output format, not the functionality. Thus -S -emit-llvm is output in LLVM IR, -c -emit-llvm is output in LLVM bitcode, -emit-llvm alone is an executable, but having been compiled with LLVM tools. The problem, of course, is when the linker doesn't have LLVM support.<br>
<br>I'd rather not break "compatibility" with llvm-gcc... is there a specific reason you wante to change this (why not use "-c"?). If it just comes down to eliminating the current bad user experience, we could augment the tool chain to understand whether the system supports LLVM inputs and avoid trying to pass them to the linker and give an error instead.<br>
<br> - Daniel<br><br><div class="gmail_quote">On Wed, Apr 29, 2009 at 3:54 PM, Collin Winter <span dir="ltr"><<a href="mailto:collinwinter@google.com">collinwinter@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all,<br>
<br>
Currently on Linux, clang -emit-llvm and -emit-llvm-bc will attempt to<br>
run the generated LLVM file through gcc, resulting in errors like<br>
those below. The attached patch tells clang to stop at compilation for<br>
-emit-llvm and -emit-llvm-bc, rather than attempting to pass them to<br>
ld. The patch also includes tests for this behavior.<br>
<br>
The patch is against r70419. I've tested this on Darwin and Linux with<br>
clang's make test.<br>
<br>
Thanks,<br>
Collin Winter<br>
<br>
<br>
<br>
$ ../../llvm/Debug/bin/clang -ccc-echo -O3 -emit-llvm-bc  -I.<br>
-IInclude -I../trunk -I../trunk/Include   -DPy_BUILD_CORE<br>
../trunk/Python/llvm_inline_functions.c -o<br>
Python/llvm_inline_functions.bc<br>
 "/usr/local/google/collinwinter/llvm/Debug/bin/clang-cc" -triple<br>
i386-unknown-linux-gnu -S -disable-free -main-file-name<br>
llvm_inline_functions.c --relocation-model static --disable-fp-elim<br>
--unwind-tables=0 --fmath-errno=1 -DPy_BUILD_CORE -I. -IInclude<br>
-I../trunk -I../trunk/Include -O3 -fdiagnostics-show-option -o<br>
/tmp/cc-4HJUGl.s -x c ../trunk/Python/llvm_inline_functions.c<br>
 "/usr/bin/gcc" -O3 -emit-llvm-bc -I. -IInclude -I../trunk<br>
-I../trunk/Include -DPy_BUILD_CORE -c -o /tmp/cc-fL4PGn.o -x assembler<br>
/tmp/cc-4HJUGl.s<br>
 "/usr/bin/gcc" -O3 -emit-llvm-bc -I. -IInclude -I../trunk<br>
-I../trunk/Include -DPy_BUILD_CORE -o Python/llvm_inline_functions.bc<br>
/tmp/cc-fL4PGn.o<br>
/usr/bin/ld: warning: cannot find entry symbol mit-llvm-bc; defaulting<br>
to 0000000008048f50<br>
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/crt1.o: In function `_start':<br>
/tmp/glibc.iZwOIW/glibc-2.3.6-0ubuntu20/build-tree/glibc-2.3.6/csu/../sysdeps/i386/elf/start.S:115:<br>
undefined reference to `main'<br>
/tmp/cc-fL4PGn.o: In function `_PyLlvm_WrapDealloc':<br>
../trunk/Python/llvm_inline_functions.c:(.text+0x9ed): undefined<br>
reference to `_Py_Dealloc'<br>
/tmp/cc-fL4PGn.o: In function `_PyLlvm_WrapIsExceptionOrString':<br>
../trunk/Python/llvm_inline_functions.c:(.text+0xa0a): undefined<br>
reference to `PyClass_Type'<br>
/tmp/cc-fL4PGn.o: In function `_PyLlvm_WrapEnterExceptOrFinally':<br>
../trunk/Python/llvm_inline_functions.c:(.text+0xa3a): undefined<br>
reference to `PyThreadState_Get'<br>
../trunk/Python/llvm_inline_functions.c:(.text+0xa56): undefined<br>
reference to `PyErr_Fetch'<br>
../trunk/Python/llvm_inline_functions.c:(.text+0xa65): undefined<br>
reference to `_Py_NoneStruct'<br>
../trunk/Python/llvm_inline_functions.c:(.text+0xa6b): undefined<br>
reference to `_Py_RefTotal'<br>
../trunk/Python/llvm_inline_functions.c:(.text+0xa85): undefined<br>
reference to `PyErr_NormalizeException'<br>
../trunk/Python/llvm_inline_functions.c:(.text+0xaa4): undefined<br>
reference to `_PyEval_SetExcInfo'<br>
../trunk/Python/llvm_inline_functions.c:(.text+0xaaf): undefined<br>
reference to `_Py_RefTotal'<br>
../trunk/Python/llvm_inline_functions.c:(.text+0xab5): undefined<br>
reference to `_Py_NoneStruct'<br>
../trunk/Python/llvm_inline_functions.c:(.text+0xabb): undefined<br>
reference to `_Py_NoneStruct'<br>
../trunk/Python/llvm_inline_functions.c:(.text+0xac0): undefined<br>
reference to `PyErr_Clear'<br>
collect2: ld returned 1 exit status<br>
$<br>
<br>
<br>
$ ../../llvm/Debug/bin/clang -ccc-echo -O3 -emit-llvm  -I. -IInclude<br>
-I../trunk -I../trunk/Include   -DPy_BUILD_CORE<br>
../trunk/Python/llvm_inline_functions.c -o<br>
Python/<a href="http://llvm_inline_functions.ir" target="_blank">llvm_inline_functions.ir</a><br>
 "/usr/local/google/collinwinter/llvm/Debug/bin/clang-cc" -triple<br>
i386-unknown-linux-gnu -emit-llvm-bc -disable-free -main-file-name<br>
llvm_inline_functions.c --relocation-model static --disable-fp-elim<br>
--unwind-tables=0 --fmath-errno=1 -DPy_BUILD_CORE -I. -IInclude<br>
-I../trunk -I../trunk/Include -O3 -fdiagnostics-show-option -o<br>
/tmp/cc-zFrEU8.o -x c ../trunk/Python/llvm_inline_functions.c<br>
 "/usr/bin/gcc" -O3 -emit-llvm -I. -IInclude -I../trunk<br>
-I../trunk/Include -DPy_BUILD_CORE -o Python/<a href="http://llvm_inline_functions.ir" target="_blank">llvm_inline_functions.ir</a><br>
/tmp/cc-zFrEU8.o<br>
/tmp/cc-zFrEU8.o: file not recognized: File format not recognized<br>
collect2: ld returned 1 exit status<br>
collinwinter@lagos:/usr/local/google/collinwinter/us/obj$<br>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br>