From: Nick Lewycky
The following example shows a worked example of the gold plugin mixing + LLVM bitcode and native code. +
+--- a.c ---
+#include <stdio.h>
+
+extern void foo1(void);
+extern void foo4(void);
+
+void foo2(void) {
+ printf("Foo2\n");
+}
+
+void foo3(void) {
+ foo4();
+}
+
+int main(void) {
+ foo1();
+}
+
+--- b.c ---
+#include <stdio.h>
+
+extern void foo2(void);
+
+void foo1(void) {
+ foo2();
+}
+
+void foo4(void) {
+ printf("Foo4");
+}
+
+--- command lines ---
+$ llvm-gcc -flto a.c -c -o a.o # <-- a.o is LLVM bitcode file
+$ llvm-gcc b.c -c -o b.o # <-- b.o is native object file
+$ llvm-gcc -use-gold-plugin a.o b.o -o main # <-- link with LLVMgold plugin
+
+ Gold informs the plugin that foo3 is never referenced outside the IR, + leading LLVM to delete that function. However, unlike in the + libLTO + example gold does not currently eliminate foo4.
+