Xenial image includes clang without LLVMgold support

xenial images include clang:

clang version 7.0.0 (tags/RELEASE_700/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-7.0.0/bin

however, using clang -flto crashes:

/usr/bin/ld: /usr/local/clang-7.0.0/bin/…/lib/LLVMgold.so: error loading plugin: /usr/local/clang-7.0.0/bin/…/lib/LLVMgold.so: cannot open shared object file: No such file or directory
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)

1 Like

Same issue for bionic:

/usr/bin/ld: /usr/local/clang-7.0.0/bin/../lib/LLVMgold.so: error loading plugin: /usr/local/clang-7.0.0/bin/../lib/LLVMgold.so: cannot open shared object file: No such file or directory

clang-7: error: linker command failed with exit code 1 (use -v to see invocation)

Seems clang was not build with the gold linker, or the linker is not installed?

Quick googling shows that LLVMgold.so is a plugin. And https://docs.travis-ci.com/user/reference/xenial/#compilers-and-build-toolchain doesn’t specify whether any plugins are installed.

You can install Apt package llvm-7-dev which has this plugin:

addons:
  apt:
    packages:
      - llvm-7-dev
1 Like

Thanks, but that does not really solve the problem since the deb package installs the plugin somewhere in /usr/lib/.. and the pre-installed clang expects the .so somewhere in /usr/local/...

After some back-and-forth I ended up installing the clang-7 package under bionic and use this one instead of the pre-installed one. Maybe I could have copied the file to the right place where the linker expected it?

os:
  - linux

dist: bionic

addons:
  apt:
    packages:
      - clang-7
      - llvm-7-dev

I wonder why Travis maintains its own clang version despite having a readily available packaged version from Ubuntu? (which has the added benefit of a working gold linker with LTO support)

I really hoped that it would pick up the libs under /usr/lib/

That puzzled me, too. It’s way more straightforward to just use the Apt package. A custom installation is only good if there are some customizations – and there don’t seem to be any.

The clang version pre-installed on our bionic image is 6.0.0 https://travis-ci.org/BanzaiMan/travis_production_test/jobs/616889573#L102

If the addition of clang-7 and llvm-7-dev packages are tripping this, I tend to think the issue lies upstream with them.

the link you posted is to the arm64 job.
the amd64 job in your build uses clang/llvm-7: https://travis-ci.org/BanzaiMan/travis_production_test/jobs/616889571

'${CXX} printf.cpp" is a bad test case. The problem appears when the linker tries to use to LTO plugin so you need at least 2 compilation units that are linked in a separate step.

it’s not an upstream problem. apt installing llvm/clang works and fixes the problem. The installed instance in /usr/local/clang-7.0.0 doesn’t include the necessary plugin for lto.

You are right the version. But the problem still remains, no? The pre-built binaries from http://releases.llvm.org/download.html#7.0.0 do not contain this shared object file:

$ curl -SsfL http://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz | tar tvf - | grep /LLVM.*.so
-rw-r--r--  0 root   root  4367800 Sep 21  2018 clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04/lib/LLVMPolly.so
-rw-r--r--  0 root   root    15040 Sep 21  2018 clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04/lib/LLVMHello.so
$

and you will have to figure out how to install the plugin.

http://llvm.org/docs/GoldPlugin.html

ah, that’s what you meant by upstream problem.
It looks like the gold plugin is built only if LLVM_BINUTILS_INCDIR is set at configure time. I’m not sure if there’s a plugin that was built with the upstream binary tarball.
for ubuntu it’s distributed in llvm-X-dev package.
it might be best to just use the apt version, either the distro one or https://apt.llvm.org

1 Like

There’s one more reason to use the apt versions. The binary tarball is built using clang, so running llvm-config --cxxflags can include flags that are not supported by the system compiler.
This topic can be renamed to “Use apt version of llvm/clang”.

Let’s just document this and move on.

@jvesely can use Clang 7 from Apt:

addons:
  apt:
    packages:
      - clang-7
      - llvm-7-dev
env:
  global:
    - CC="/usr/bin/clang-7"
Imprint