gold and debug information

Hi,

I would like to get the whole program bitcode with debug information in it.

I tried to use CFLAGS = "-O4 -g", but it ends with the following error:
collect2: ld terminated with signal 6 [Aborted]
Unknown constant!
UNREACHABLE executed at /local.toadette/aliang/fixing/llvm-2.7/llvm-2.7/lib/Bitcode/Writer/BitcodeWriter.cpp:895!

What is the right way to get a whole program bitcode with debug information using gold plugin?

Thanks,
Guoliang

That looks like a bug; can you attach a testcase?

-Eli

I suppose you also have the gold plugin with the also-emit-llvm support. It is in the mainline llvm, and I ported it back to 2.7.

The same error happened for both of them: the modified 2.7, and a mainline I checked out three weeks ago.

This problem is reproducible while compiling flex-2.5.35.tar.gz and many others (mysql and cherokee). I set the following:

export PATH="$LLVMPREFIX/bin:$LLVMGCCPREFIX/bin:$PATH"
export CC="llvm-gcc -use-gold-plugin -Wl,-plugin-opt=also-emit-llvm"
export CXX="llvm-g++ -use-gold-plugin -Wl,-plugin-opt=also-emit-llvm"
export RANLIB=/bin/true
export CFLAGS="-O4 -g"

then configure, make, and then hit the error.

The error only happens if the CFLAGS has -g in it.

Thanks,
Guoliang

export PATH="$LLVMPREFIX/bin:$LLVMGCCPREFIX/bin:$PATH"
export CC="llvm-gcc -use-gold-plugin -Wl,-plugin-opt=also-emit-llvm"
export CXX="llvm-g++ -use-gold-plugin -Wl,-plugin-opt=also-emit-llvm"
export RANLIB=/bin/true
export CFLAGS="-O4 -g"

then configure, make, and then hit the error.

The error only happens if the CFLAGS has -g in it.

Can you reduce the testcase a bit? It would be a lot easier to
reproduce with the ld invocation and the .o files given to it.

Thanks,
Guoliang

Cheers,

This (Unknown constant! in bitcode writer when -g is used) is a known
bug in CloneModule, because it is not cloning MDNodes appropriately.
So bug point is likely to run into this while reducing test case.

I do not know whether gold is cloning module at -O4 or not.

All the .o files are in the tarball. You can download it here (too large to send through the list): http://pages.cs.wisc.edu/~aliang/goldAndDebugTest.tar.gz

The command is:
llvm-gcc -use-gold-plugin -Wl,-plugin-opt=also-emit-
llvm -g -O4 -o flex ccl.o dfa.o ecs.o scanflags.o gen.o main.o misc.o nfa.o parse.o scan.o skel.o sym.o tblcmp.o yylex.o options.o scanopt.o buf.o tables.o tables_shared.o filter.o regex.o -lm
Then I got:
$ llvm-gcc -use-gold-plugin -Wl,-plugin-opt=also-emit-llvm -g -O4 -o flex ccl.o dfa.o ecs.o scanflags.o gen.o main.o misc.o nfa.o parse.o scan.o skel.o sym.o tblcmp.o yylex.o options.o scanopt.o buf.o tables.o tables_shared.o filter.o regex.o -lm

collect2: ld terminated with signal 6 [Aborted]

/local.toadette/aliang/packages/llvm-2.7/llvm-gcc/lib/gcc/i686-pc-linux-gnu/4.2.1/…/…/…/…/i686-pc-linux-gnu/bin/ld: error: buf.o:1:1: invalid character
Unknown constant!
UNREACHABLE executed at /local.toadette/aliang/fixing/llvm-2.7/llvm-2.7/lib/Bitcode/Writer/BitcodeWriter.cpp:895!

I do not know how to get the ld invocation you need. If this command is not what you need, please tell me how to get the ld invocation.

Thanks,
Guoliang

Is this bug fixed in mainline llvm?

Do you need something else from me to reproduce this?

Thanks,
Guoliang

export PATH="$LLVMPREFIX/bin:$LLVMGCCPREFIX/bin:$PATH"
export CC="llvm-gcc -use-gold-plugin -Wl,-plugin-opt=also-emit-llvm"
export CXX="llvm-g++ -use-gold-plugin -Wl,-plugin-opt=also-emit-llvm"
export RANLIB=/bin/true
export CFLAGS="-O4 -g"

then configure, make, and then hit the error.

The error only happens if the CFLAGS has -g in it.

Can you reduce the testcase a bit? It would be a lot easier to
reproduce with the ld invocation and the .o files given to it.

This (Unknown constant! in bitcode writer when -g is used) is a known
bug in CloneModule, because it is not cloning MDNodes appropriately.

What's the link to the bug report? Are you fixing it?

I do not know how to get the ld invocation you need. If this command is not
what you need, please tell me how to get the ld invocation.

Add -Wl,-debug to the llvm-gcc call. That should print the ld command
line in the end.

Thanks,
Guoliang

Thanks,

All the .o files are in the tarball. You can download it here (too large to
send through the list):
http://pages.cs.wisc.edu/~aliang/goldAndDebugTest.tar.gz

There is also something strange with these files, buf.o is actually a
.tar.gz file :slight_smile:

Thanks,
Guoliang

Cheers,

I do not know how to get the ld invocation you need. If this command is not
what you need, please tell me how to get the ld invocation.

Add -Wl,-debug to the llvm-gcc call. That should print the ld command
line in the end.

/local.toadette/aliang/packages/llvm-2.7/llvm-gcc/lib/gcc/i686-pc-linux-gnu/4.2.1/../../../../i686-pc-linux-gnu/bin/ld -plugin /local.toadette/aliang/packages/llvm-2.7/llvm-gcc/libexec/gcc/i686-pc-linux-gnu/4.2.1/libLLVMgold.so -plugin-opt=as=/local.toadette/aliang/packages/llvm-2.7/llvm-gcc/lib/gcc/i686-pc-linux-gnu/4.2.1/../../../../i686-pc-linux-gnu/bin/as --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o flex /usr/lib/crt1.o /usr/lib/crti.o /local.toadette/aliang/packages/llvm-2.7/llvm-gcc/lib/gcc/i686-pc-linux-gnu/4.2.1/crtbegin.o -L/local.toadette/aliang/packages/llvm-2.7/llvm-gcc/lib/gcc/i686-pc-linux-gnu/4.2.1 -L/local.toadette/aliang/packages/llvm-2.7/llvm-gcc/lib/gcc/i686-pc-linux-gnu/4.2.1/../../.. -plugin-opt=also-emit-llvm ccl.o dfa.o ecs.o scanflags.o gen.o main.o misc.o nfa.o parse.o scan.o skel.o sym.o tblcmp.o yylex.o options.o scanopt.o buf.o tables.o tables_shared.o filter.o regex.o -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /local.toadette/aliang/packages/llvm-2.7/llvm-gcc/lib/gcc/i686-pc-linux-gnu/4.2.1/crtend.o /usr/lib/crtn.o

http://pages.cs.wisc.edu/~aliang/goldAndDebugTest.tar.gz

There is also something strange with these files, buf.o is actually a
.tar.gz file :slight_smile:

Updated. Sorry about that.

Thanks,
Guoliang

I don't know what the bug is, but I was able to reduce the test and
reported llvm.org/PR7689.

Cheers,

PR 7689. Fixed in r109117.

I still run into the same error with this. Can someone else also try this patch?

Thanks,
Guoliang

This (Unknown constant! in bitcode writer when -g is used) is a known
bug in CloneModule, because it is not cloning MDNodes appropriately.

What’s the link to the bug report? Are you fixing it?

PR 7689. Fixed in r109117.

I still run into the same error with this. Can someone else also try this patch?

Saw Rafael reported the same thing in the Bugzilla.

This looks like some other bug that needs further investigation.