clang fails to find C++ headers in presence of gcc-12 package
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
llvm-toolchain-14 (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
This is a weird one. On a clean rootfs (e.g. with `docker run -it --rm ubuntu:22.04`), clang can find C++ headers just fine.
```
# apt update; apt install --no-install-
<snip>
# echo '#include <iostream>' | clang -x c++ -E - >/dev/null
#
```
But as soon as gcc-12 is also installed on the system (which can be pulled in by e.g. dkms), the exact same "source" doesn't pre-process anymore.
```
# apt install --no-install-
<snip>
# echo '#include <iostream>' | clang -x c++ -E - >/dev/null
<stdin>:1:10: fatal error: 'iostream' file not found
#include <iostream>
^~~~~~~~~~
1 error generated.
#
```
Upon further inspection, it seems like it just looks for headers in non-existent path, and somehow has "12" in it (but the resolved path isn't?)
```
# echo '#include <iostream>' | clang -x c++ -E -Wp,-v - >/dev/null
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/bin/
ignoring nonexistent directory "/usr/bin/
ignoring nonexistent directory "/usr/bin/
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/bin/
/usr/lib/
/usr/local/include
/usr/include/
/usr/include
End of search list.
<stdin>:1:10: fatal error: 'iostream' file not found
#include <iostream>
^~~~~~~~~~
1 error generated.
```
It almost seems like clang tries to detect the highest installed version of GCC, but doesn't prepare for the fact that g++ 12 isn't installed. So, I'm not sure who's at fault here...
ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: clang-14 1:14.0.0-1ubuntu1
Uname: Linux 6.1.11-
NonfreeKernelMo
ApportVersion: 2.20.11-0ubuntu82.3
Architecture: amd64
CasperMD5CheckR
CurrentDesktop: ubuntu:GNOME
Date: Sat Mar 4 01:17:58 2023
InstallationDate: Installed on 2021-03-15 (718 days ago)
InstallationMedia: Ubuntu 20.04.2.0 LTS "Focal Fossa" - Release amd64 (20210209.1)
ProcEnviron:
TERM=xterm-
PATH=(custom, no user)
XDG_RUNTIME_
LANG=th_TH.UTF-8
SHELL=/bin/bash
RebootRequiredPkgs: Error: path contained symlinks.
SourcePackage: llvm-toolchain-14
UpgradeStatus: Upgraded to jammy on 2022-10-22 (132 days ago)
Status changed to 'Confirmed' because the bug affects multiple users.