Skip to content

Enabling LTO causes linker errors #337

@rtimpe

Description

@rtimpe

Describe the bug

When compiling with the -flto flag, I get the following error

$ /opt/opencilk-3/bin/clang -fopencilk -flto -v fib.c -o fib
clang version 19.1.7
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/opencilk-3/bin
Build config: +assertions
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/opt/opencilk-3/bin/clang-19" -cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -flto=full -flto-unit -dumpdir fib- -disable-free -clear-ast-before-backend -main-file-name fib.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/ex -v -fcoverage-compilation-dir=/ex -resource-dir /opt/opencilk-3/lib/clang/19 -internal-isystem /opt/opencilk-3/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fopencilk --opencilk-abi-bitcode=/opt/opencilk-3/lib/clang/19/lib/x86_64-unknown-linux-gnu/libopencilk-abi.bc -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/fib-8d58f4.o -x c fib.c
clang -cc1 version 19.1.7 based upon LLVM 19.1.7 default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/opencilk-3/lib/clang/19/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
 "/usr/bin/ld" -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -pie -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o fib /lib/x86_64-linux-gnu/Scrt1.o /lib/x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/13/crtbeginS.o -L/opt/opencilk-3/lib/clang/19/lib/x86_64-unknown-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/13 -L/usr/lib/gcc/x86_64-linux-gnu/13/../../../../lib64 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib64 -L/lib -L/usr/lib -plugin /opt/opencilk-3/bin/../lib/LLVMgold.so -plugin-opt=mcpu=x86-64 --plugin-opt=tapir-target=opencilk --plugin-opt=opencilk-abi-bitcode=/opt/opencilk-3/lib/clang/19/lib/x86_64-unknown-linux-gnu/libopencilk-abi.bc /tmp/fib-8d58f4.o -lopencilk-personality-c -lopencilk -L /opt/opencilk-3/lib/clang/19/lib/x86_64-unknown-linux-gnu -rpath /opt/opencilk-3/lib/clang/19/lib/x86_64-unknown-linux-gnu --enable-new-dtags -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/13/crtendS.o /lib/x86_64-linux-gnu/crtn.o
/usr/bin/ld: /opt/opencilk-3/bin/../lib/LLVMgold.so: error loading plugin: /opt/opencilk-3/bin/../lib/LLVMgold.so: cannot open shared object file: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Expected behavior

No error

OpenCilk version

  • Release version: 3.0
  • Distribution method: Docker image

I also see the same error when using the 2.1 release as a tarball

System information

  • OS: Arch linux
  • CPU: Intel Core i7-7700K

Steps to reproduce (include relevant output)

This happens with any input code - I just used fib.c from the tutorial as an example.

Working example code

Removing the -flto flag seems to be the only way to make it work

Additional comments

Let me know if I can provide any more information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions