This shows up with the gold plugin, but I don't think it is gold specific: $ cat test.ll @skel = global [1 x i8*] [i8* null] !llvm.dbg.gv = !{!0} !0 = metadata !{i1 true, [1 x i8*]* @skel} $ llvm-as test.ll -o test.o $ ld -plugin LLVMgold.so -o flex -shared -plugin-opt=emit-llvm test.o Unknown constant! UNREACHABLE executed at /usr/local/google/home/espindola/llvm/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:904! Aborted
Could you update to r109036 and post the output on this testcase?
Sure, the output is: @skel = global [1 x i8*] zeroinitializer ; <[1 x i8*]*> [#uses=0] Unknown constant! UNREACHABLE executed at /usr/local/google/home/espindola/llvm/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:903!
Fixed in r109117.
I still get the same failure: @skel = global [1 x i8*] zeroinitializer ; <[1 x i8*]*> [#uses=0] Unknown constant! UNREACHABLE executed at /usr/local/google/home/espindola/llvm/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:909!
I program that should allow you to reproduce without gold: #include <assert.h> #include "llvm-c/lto.h" int main(int argc, char *argv[]) { lto_module_t M = lto_module_create(argv[1]); assert (M); unsigned sym_count = lto_module_get_num_symbols(M); lto_code_gen_t cg = lto_codegen_create(); lto_codegen_add_module(cg, M); lto_codegen_model output_type = LTO_CODEGEN_PIC_MODEL_STATIC; lto_codegen_set_pic_model(cg, output_type); lto_codegen_set_debug_model(cg, LTO_DEBUG_MODEL_DWARF); bool err = lto_codegen_write_merged_modules(cg, "foo.bc"); return 0; } Just pass the test.bc file to it and lto_codegen_write_merged_modules will abort with the same error message.
This is related to PR7700.
Fixed in r111949 and related commits.
(In reply to comment #7) > Fixed in r111949 and related commits. With those patches, the test case in the original description gave me these: @skel = global [1 x i8*] zeroinitializer ; <[1 x i8*]*> [#uses=0] Unknown constant! UNREACHABLE executed at /local.toadette/aliang/fixing/llvmsvn/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:909! Aborted Does anyone else see the same result?
(In reply to comment #8) > @skel = global [1 x i8*] zeroinitializer ; <[1 x i8*]*> [#uses=0] > > Unknown constant! > UNREACHABLE executed at > /local.toadette/aliang/fixing/llvmsvn/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:909! That UNREACHABLE is no longer at line 909 in BitcodeWriter.cpp on ToT; are your sources up to date?
(In reply to comment #9) > (In reply to comment #8) > > @skel = global [1 x i8*] zeroinitializer ; <[1 x i8*]*> [#uses=0] > > > > Unknown constant! > > UNREACHABLE executed at > > /local.toadette/aliang/fixing/llvmsvn/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:909! > > That UNREACHABLE is no longer at line 909 in BitcodeWriter.cpp on ToT; are your > sources up to date? This UNREACHABLE disappeared. Thanks. The reason is that I did not replace those old LLVMgold.so and libLTO.so. But I got the following: /local/llvm-gcc/lib/gcc/i686-pc-linux-gnu/4.2.1/../../../../i686-pc-linux-gnu/bin/ld: error: /local/llvm-gcc/libexec/gcc/i686-pc-linux-gnu/4.2.1/LLVMgold.so: could not load plugin library: /local/llvm-gcc/libexec/gcc/i686-pc-linux-gnu/4.2.1/LLVMgold.so: undefined symbol: lto_codegen_set_cpu
Missing lto_codegen_set_cpu is a separate gold plugin issue. Please use new PR.
(In reply to comment #11) > Missing lto_codegen_set_cpu is a separate gold plugin issue. Please use new PR. I fixed this by adding lto_codegen_set_cpu and lto_codegen_set_assembler_args to lto.exports Then I still got the Unknown constant! by doing: $ cat conftest.c int main () { return 0; } $ llvm-gcc -use-gold-plugin -Wl,-plugin-opt=also-emit-llvm -O4 -g conftest.c collect2: ld terminated with signal 6 [Aborted] declare i32 @main() nounwind readnone Unknown constant! UNREACHABLE executed at /local.toadette/aliang/fixing/llvmsvn/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:910!
It turns out there was another bug in bitcode linking. This is now fixed in r112091. I updated lto.exports too.
(In reply to comment #13) > It turns out there was another bug in bitcode linking. This is now fixed in > r112091. I updated lto.exports too. I compiled httpd-2.2.9.tar.gz using the latest code. It compiles without problem, however, I got a lot of "BFD: Dwarf Error: Could not find abbrev number" when I do objdump. It is configured with: ../configure --prefix=/local/install CFLAGS="-O4 -g" CC="llvm-gcc -use-gold-plugin -Wl,-plugin-opt=also-emit-llvm" CXX="llvm-g++ -use-gold-plugin -Wl,-plugin-opt=also-emit-llvm" RANLIB="/bin/true" --with-mpm=worker then I make then go to .libs and do objdump -l -S httpd > httpd.S and got: " BFD: Dwarf Error: Could not find abbrev number 116. BFD: Dwarf Error: Could not find abbrev number 5864. BFD: Dwarf Error: Could not find abbrev number 117. BFD: Dwarf Error: Could not find abbrev number 110. BFD: Dwarf Error: Could not find abbrev number 116. BFD: Dwarf Error: Could not find abbrev number 116. BFD: Dwarf Error: Could not find abbrev number 120. BFD: Dwarf Error: Could not find abbrev number 116. BFD: Dwarf Error: Could not find abbrev number 127. BFD: Dwarf Error: Could not find abbrev number 127. BFD: Dwarf Error: Could not find abbrev number 116. BFD: Dwarf Error: Could not find abbrev number 116. BFD: Dwarf Error: Could not find abbrev number 111. BFD: Dwarf Error: Could not find abbrev number 267. BFD: Dwarf Error: Could not find abbrev number 267. BFD: Dwarf Error: Could not find abbrev number 5495. BFD: Dwarf Error: Could not find abbrev number 12928. ... ... " I did get one httpd.S though.
Please file a new bug with an example of a bitcode file that produces a .o with broken debug info. Thanks!
(In reply to comment #15) > Please file a new bug with an example of a bitcode file that produces a .o with > broken debug info. Thanks! http://llvm.org/bugs/show_bug.cgi?id=8003 I haven't reduce it to a single bytecode file. Instead I uploaded a tarball of bytecode files that can be linked to get the final binary.