Open
Description
Hi,
I was trying to obtain whole program bitcode through lto but run into some issues. Here's the step to reproduce.
Running
clang -c -flto=thin hello.c
clang -c -flto=thin foo.c
clang -flto=thin -fuse-ld=lld -Wl,-plugin-opt=-lto-embed-bitcode=optimized hello.o foo.o -o hello
objcopy --dump-section .llvmbc=hello.bc hello
clang hello.bc
gives the following error
error: Invalid encoding
1 error generated.
This issue does not occur when using -flto=full. The rust compiler also reports similar issues here: rust-lang/rust#84395
hello.c
#include <stdio.h>
extern void foo();
int main() {
printf("Hello, world!\n");
foo();
return 0;
}
foo.c
#include <stdio.h>
void foo() {
printf("foo!\n");
}
clang version:
clang version 16.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin