clang packages in 22.04 have the wrong libstdc++-*-dev dependency
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
llvm-toolchain-14 (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Summary: clang packages depends on the wrong version libstdc++-*-dev, so C++ compilation with Clang doesn't work without an extra, hard-to-discover step.
Workaround: apt install libstdc++-12-dev
The clang packages in Ubuntu 22.04 jammy are unusable to compile a C++ program out of the box.
```
$ cat a.cpp
#include <cstddef>
int main() {}
$ g++ a.cpp
$ clang++ a.cpp
a.cpp:1:10: fatal error: 'cstddef' file not found
#include <cstddef>
^~~~~~~~~
1 error generated.
$ clang++ --version
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ ls -lA $(which clang++)
lrwxrwxrwx 1 root root 26 Apr 1 2022 /usr/bin/clang++ -> ../lib/
$ dpkg -s clang-14 | grep -e Version -e Depends
Version: 1:14.0.0-1ubuntu1.1
Depends: libc6 (>= 2.34), libclang-cpp14 (>= 1:14.0.0), libgcc-s1 (>= 3.0), libllvm14, libstdc++6 (>= 11), libstdc++-11-dev, libgcc-11-dev, libobjc-11-dev, libclang-
```
The problem turns out to be that clang++ 14 wants libstdc++-12-dev, but declares a dependency on libstdc++-11-dev.
I filed this bug under clang-14 because that's the default clang, but I think all the other Clang versions in Ubuntu 22.04 are affected.
This has happened before with different versions (https:/
Can confirm this.
OS: Ubuntu 22.04 LTS
Clang version:
```
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
```
C++ code example:
```c++
#include <iostream>
using std::cout;
using std::endl;
int main(int argc, char** argv) {
cout << "Hello, world!" << endl;
return 0;
}
```
Tried `clang++ -v main.cc`, and got this:
``` ../lib/ gcc/x86_ 64-linux- gnu/11 ../lib/ gcc/x86_ 64-linux- gnu/12 ../lib/ gcc/x86_ 64-linux- gnu/12 lib/llvm- 14/bin/ clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all --mrelax- relocations -disable-free -clear- ast-before- backend -disable- llvm-verifier -discard- value-names -main-file-name main-kmp.cc -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 -mllvm -treat- scalable- fixed-error- as-warning -debugger- tuning= gdb -v -fcoverage- compilation- dir=/home/ tianxing/ dev/algorithms/ KMP -resource-dir /usr/lib/ llvm-14/ lib/clang/ 14.0.0 -internal-isystem /usr/bin/ ../lib/ gcc/x86_ 64-linux- gnu/12/ ../../. ./../include/ c++ -internal-isystem /usr/bin/ ../lib/ gcc/x86_ 64-linux- gnu/12/ ../../. ./../include/ c++/x86_ 64-linux- gnu -internal-isystem /usr/bin/ ../lib/ gcc/x86_ 64-linux- gnu/12/ ../../. ./../include/ c++/backward -internal-isystem /usr/lib/ llvm-14/ lib/clang/ 14.0.0/ include -internal-isystem /usr/local/include -internal-isystem /usr/bin/ ../lib/ gcc/x86_ 64-linux- gnu/12/ ../../. ./../x86_ 64-linux- gnu/include -internal- externc- isystem /usr/include/ x86_64- linux-gnu -internal- externc- isystem /include -internal- externc- isystem /usr/include -fdeprecated-macro -fdebug- compilation- dir=/home/ tianxing/ dev/algorithms/ KMP -ferror-limit 19 -fgnuc- version= 4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_ HAVE_DWARF2_ CFI_ASM= 1 -o /tmp/main- kmp-a7fd49. o -x c++ main-kmp.cc ../lib/ gcc/x86_ 64-linux- gnu/12/ ../../. ./../include/ c++/x86_ 64-linux- gnu" ../lib/ gcc/x86_ 64-linux- gnu/12/ ../../. ./../include/ c++/backward" ../lib/ gcc/x86_ 64-linux- gnu/12/ ../../. ./../x86_ 64-linux- gnu/include" ../lib/ gcc/x86_ 64-linux- gnu/12/ ../../. ./../include/ c++ llvm-14/ lib/clang/ 14.0.0/ include x86_64- linux-gnu
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/
Found candidate GCC installation: /usr/bin/
Selected GCC installation: /usr/bin/
Candidate multilib: .;@m64
Selected multilib: .;@m64
"/usr/
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.
main.cc:1:10: fatal error: 'iostream' file not found
#include <iostream>
^~~~~~~~~~
1 error generated.
```
Looks like it explicitly wants libstdc++-12-dev header & library files.