How to use clang 8?

I’m trying to use clang 8 in my linux build (leaving out unrelated stuff):

matrix:
include:
- os: linux
dist: xenial
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-8
packages:
- clang-8
env:
- MATRIX_EVAL=“CC=clang-8 && CXX=clang+±8”

before_install:

  • eval “${MATRIX_EVAL}”

script:

  • make archive DEBUG=0 OS=LINUX CC=clang-8 && CXX=clang+±8

According to the log, this actually uses clang-8, but compilation fails with

fatal error: ‘cstddef’ file not found

I have no idea how to proceed on that. Using the default installed clang 7 works without any problems…

There is a problem with the include path provided to the compiler.

I’ll have to remark I’ve not run into this.

Possibilities:

  • I’m using CMake it might add the required paths.
  • You or a dependency could be trying to use libc++ when clang 8 is detected.

Yes, I am using libc++; isn’t that part of the llvm toolchain? How would I install that, I don’t see anything promising in the source safelist? I’m sorry for sounding dense, I do all my development work on macOS and just wait for the next Xcode; never had to worry about manually installing a new compiler and everything it needs, never used apt etc…

Please link to the build, copypasting things here gives incomplete information.

This line looks suspicious, probably should have been DEBUG=0 OS=LINUX CC=clang-8 CXX=clang++8 make archive or make archive DEBUG=0 OS=LINUX CC=clang-8 CXX=clang++8.

Also eval “${MATRIX_EVAL}” has no effect. A var assignment should use export to have an effect on a child process like make.

(Btw these both are the same for MacOS so you can’t plead ignorance here :wink: )

It’s a private project, unfortunately I cannot link to it…

make archive DEBUG=0 OS=LINUX CC=clang-8 && CXX=clang+±8

This line looks suspicious

Oh ffs… yeah, I just copy/pasted from the matrix line, ofc the “&&” is wrong here…

(Btw these both are the same for MacOS so you can’t plead ignorance here :wink: )

I plead half ignorance, I said “Xcode” :wink:
The “&&” was stupid and indeed I should have seen that. That weird “plus-minus” sign is a function of this board, it was “++ -” (without the space) and that’s where I still plead ignorance, I have no idea how those versions are really named.

Using just “++” results in

clang++8: Command not found

so it seems “clang+±8” was correct, that at least starts compiling. Leaving out the “&&” changes nothing, I still get

fatal error: ‘cstddef’ file not found

I am almost sure I also have to install an updated version of libc++ at a place where “llvm-toolchain-xenial-8” expects it; I have no idea how, though…

Thinking the toolchain should include libcc+, maybe it needs to be explicitly “activated” I tried:

      packages:
        - clang-8
        - libc++1

…still cannot find cstddef :frowning:

Your thought is right, all parts of the toolchain are installed separately.
See the documentation on https://apt.llvm.org for the naming:

packages:
  - clang-8
  - libc++-8-dev
  - libc++abi-8-dev
1 Like

This is strange, this was’t the case in LLVM 7: How can I setup LLVM 7 as default C / C++ compiler in Bionic

And checking http://apt.llvm.org/buster/dists/llvm-toolchain-buster-8/main/binary-amd64/Packages shows that clang-8 does depend on libstdc++-8-dev (but not libc++-8-dev).

Without seeing the build and the codebase, I cannot say more.

Actually, you still can link to the build, but only Travis support staff will be able to open the link.

Ah, that’s it! Now it compiles; throws some errors, but those seem to be in my code, not a problem of the toolchain…

Thanks for the help

Actually, you still can link to the build, but only Travis support staff will be able to open the link.

Fair enough :slight_smile:

Imprint