Hi all, Currently on Linux, clang -emit-llvm and -emit-llvm-bc will attempt to run the generated LLVM file through gcc, resulting in errors like those below. The attached patch tells clang to stop at compilation for -emit-llvm and -emit-llvm-bc, rather than attempting to pass them to ld. The patch also includes tests for this behavior.
The patch is against r70419. I've tested this on Darwin and Linux with clang's make test. Thanks, Collin Winter $ ../../llvm/Debug/bin/clang -ccc-echo -O3 -emit-llvm-bc -I. -IInclude -I../trunk -I../trunk/Include -DPy_BUILD_CORE ../trunk/Python/llvm_inline_functions.c -o Python/llvm_inline_functions.bc "/usr/local/google/collinwinter/llvm/Debug/bin/clang-cc" -triple i386-unknown-linux-gnu -S -disable-free -main-file-name llvm_inline_functions.c --relocation-model static --disable-fp-elim --unwind-tables=0 --fmath-errno=1 -DPy_BUILD_CORE -I. -IInclude -I../trunk -I../trunk/Include -O3 -fdiagnostics-show-option -o /tmp/cc-4HJUGl.s -x c ../trunk/Python/llvm_inline_functions.c "/usr/bin/gcc" -O3 -emit-llvm-bc -I. -IInclude -I../trunk -I../trunk/Include -DPy_BUILD_CORE -c -o /tmp/cc-fL4PGn.o -x assembler /tmp/cc-4HJUGl.s "/usr/bin/gcc" -O3 -emit-llvm-bc -I. -IInclude -I../trunk -I../trunk/Include -DPy_BUILD_CORE -o Python/llvm_inline_functions.bc /tmp/cc-fL4PGn.o /usr/bin/ld: warning: cannot find entry symbol mit-llvm-bc; defaulting to 0000000008048f50 /usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/crt1.o: In function `_start': /tmp/glibc.iZwOIW/glibc-2.3.6-0ubuntu20/build-tree/glibc-2.3.6/csu/../sysdeps/i386/elf/start.S:115: undefined reference to `main' /tmp/cc-fL4PGn.o: In function `_PyLlvm_WrapDealloc': ../trunk/Python/llvm_inline_functions.c:(.text+0x9ed): undefined reference to `_Py_Dealloc' /tmp/cc-fL4PGn.o: In function `_PyLlvm_WrapIsExceptionOrString': ../trunk/Python/llvm_inline_functions.c:(.text+0xa0a): undefined reference to `PyClass_Type' /tmp/cc-fL4PGn.o: In function `_PyLlvm_WrapEnterExceptOrFinally': ../trunk/Python/llvm_inline_functions.c:(.text+0xa3a): undefined reference to `PyThreadState_Get' ../trunk/Python/llvm_inline_functions.c:(.text+0xa56): undefined reference to `PyErr_Fetch' ../trunk/Python/llvm_inline_functions.c:(.text+0xa65): undefined reference to `_Py_NoneStruct' ../trunk/Python/llvm_inline_functions.c:(.text+0xa6b): undefined reference to `_Py_RefTotal' ../trunk/Python/llvm_inline_functions.c:(.text+0xa85): undefined reference to `PyErr_NormalizeException' ../trunk/Python/llvm_inline_functions.c:(.text+0xaa4): undefined reference to `_PyEval_SetExcInfo' ../trunk/Python/llvm_inline_functions.c:(.text+0xaaf): undefined reference to `_Py_RefTotal' ../trunk/Python/llvm_inline_functions.c:(.text+0xab5): undefined reference to `_Py_NoneStruct' ../trunk/Python/llvm_inline_functions.c:(.text+0xabb): undefined reference to `_Py_NoneStruct' ../trunk/Python/llvm_inline_functions.c:(.text+0xac0): undefined reference to `PyErr_Clear' collect2: ld returned 1 exit status $ $ ../../llvm/Debug/bin/clang -ccc-echo -O3 -emit-llvm -I. -IInclude -I../trunk -I../trunk/Include -DPy_BUILD_CORE ../trunk/Python/llvm_inline_functions.c -o Python/llvm_inline_functions.ir "/usr/local/google/collinwinter/llvm/Debug/bin/clang-cc" -triple i386-unknown-linux-gnu -emit-llvm-bc -disable-free -main-file-name llvm_inline_functions.c --relocation-model static --disable-fp-elim --unwind-tables=0 --fmath-errno=1 -DPy_BUILD_CORE -I. -IInclude -I../trunk -I../trunk/Include -O3 -fdiagnostics-show-option -o /tmp/cc-zFrEU8.o -x c ../trunk/Python/llvm_inline_functions.c "/usr/bin/gcc" -O3 -emit-llvm -I. -IInclude -I../trunk -I../trunk/Include -DPy_BUILD_CORE -o Python/llvm_inline_functions.ir /tmp/cc-zFrEU8.o /tmp/cc-zFrEU8.o: file not recognized: File format not recognized collect2: ld returned 1 exit status collinwin...@lagos:/usr/local/google/collinwinter/us/obj$
emit_llvm.patch
Description: Binary data
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
