[Bug 2009223] [NEW] clang fails to find C++ headers in presence of gcc-12 package

Ratchanan Srirattanamet 2009223 at bugs.launchpad.net
Fri Mar 3 18:32:09 UTC 2023


Public bug reported:

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-recommends clang
<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-recommends gcc-12
<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/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/backward"
ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /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-gitv6.1.11-1-gb07abe8e29e1 x86_64
NonfreeKernelModules: nvidia_modeset nvidia
ApportVersion: 2.20.11-0ubuntu82.3
Architecture: amd64
CasperMD5CheckResult: unknown
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-256color
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 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)

** Affects: llvm-toolchain-14 (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug jammy wayland-session

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to llvm-toolchain-14 in Ubuntu.
https://bugs.launchpad.net/bugs/2009223

Title:
  clang fails to find C++ headers in presence of gcc-12 package

Status in llvm-toolchain-14 package in Ubuntu:
  New

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-recommends clang
  <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-recommends gcc-12
  <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/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/x86_64-linux-gnu"
  ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/backward"
  ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
  ignoring nonexistent directory "/include"
  #include "..." search starts here:
  #include <...> search starts here:
   /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++
   /usr/lib/llvm-14/lib/clang/14.0.0/include
   /usr/local/include
   /usr/include/x86_64-linux-gnu
   /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-gitv6.1.11-1-gb07abe8e29e1 x86_64
  NonfreeKernelModules: nvidia_modeset nvidia
  ApportVersion: 2.20.11-0ubuntu82.3
  Architecture: amd64
  CasperMD5CheckResult: unknown
  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-256color
   PATH=(custom, no user)
   XDG_RUNTIME_DIR=<set>
   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)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/llvm-toolchain-14/+bug/2009223/+subscriptions




More information about the foundations-bugs mailing list