msys2 / MINGW-packages

Package scripts for MinGW-w64 targets to build under MSYS2.
https://packages.msys2.org
BSD 3-Clause "New" or "Revised" License
2.27k stars 1.21k forks source link

after most recent update clang++ cannot find standard library include files #10762

Open TomislavGoles opened 2 years ago

TomislavGoles commented 2 years ago

After most recent update my build script fails when trying to include standard c++ library files.

$ clang --version clang version 13.0.1 Target: x86_64-w64-windows-gnu Thread model: posix InstalledDir: C:/msys64/clang64/bin

Here is the simple c++ program saved in hello_world.cpp file.

#include <iostream>
int main( void )
{
    std::cout << "Hello world" << std::endl;
    return( 0 );
}

When I try to compile it I get the following:

$ clang++ -Wall -o hello_world.o hello_world.cpp
hello_world.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
         ^~~~~~~~~~
1 error generated.
Biswa96 commented 2 years ago

I can not reproduce the issue in my system. Can you check if all the packages are up-to-date with pacman -Syyuu command?

TomislavGoles commented 2 years ago

I just ran that command and my system told me I am up to date. By the way I never had this issue with any previous clang update (my makefiles and all the options have not changed for a long time). Also, in case it helps I also have g++ installed and it has no problem compiling this.

TomislavGoles commented 2 years ago

Here is the output of that command:

$ pacman -Syyuu :: Synchronizing package databases... mingw32 1448.3 KiB 767 KiB/s 00:02 [#########################################################] 100% mingw64 1455.7 KiB 1280 KiB/s 00:01 [#########################################################] 100% ucrt64 1587.6 KiB 1267 KiB/s 00:01 [#########################################################] 100% clang64 1499.1 KiB 812 KiB/s 00:02 [#########################################################] 100% msys 374.2 KiB 334 KiB/s 00:01 [#########################################################] 100% :: Starting core system upgrade... there is nothing to do :: Starting full system upgrade... there is nothing to do

TomislavGoles commented 2 years ago

Is there a way to cleanly downgrade to previous version of clang toolchain I had before this most recent update?

Biswa96 commented 2 years ago

I am only aware of the manual way. But it is too complex. From the InstalledDir: C:/msys64/clang64/bin path, I assume that you are using clang64 environment. For that, download the required .zst file in this page https://repo.msys2.org/mingw/clang64/. And install it with pacman -U command. Make sure to follow that will all the dependencies.

TomislavGoles commented 2 years ago

Ok - thanks. I will try that.

Biswa96 commented 2 years ago

Alternatively, if you are familiar with GitHub Actions you can use clang64 environment with dummy cpp file to reproduce this issue.

TomislavGoles commented 2 years ago

I have never used GitHub Actions (new to GitHub). Any links to where I can get educated on how to use it?

Biswa96 commented 2 years ago

Then that will be a whole new chapter 😊 You can find the documentation here https://www.msys2.org/docs/ci/

TomislavGoles commented 2 years ago

Ok - thanks again.

TomislavGoles commented 2 years ago

Downgrading from version 13.0.1-1 to 13.0.0-5 fixed the problem for me.

mati865 commented 2 years ago

I cannot reproduce it either:

$ clang -v
clang version 13.0.1
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: D:/msys64/clang64/bin
TomislavGoles commented 2 years ago

Thanks. Just out of curiosity is there an easy way to find out the folder in which compiler is actually looking for those standard include files? Are there any flags (some type of verbose setting) that would reveal this?

Biswa96 commented 2 years ago

Are there any flags (some type of verbose setting) that would reveal this?

gcc --print-search-dirs

TomislavGoles commented 2 years ago

Thanks. I'll update again to the latest version that is not working for me and run this (and look whether those standard c++ library files are in on of the locations printed by that command - if I still can't figure it out at least now I know how to downgrade again).

IEXPECTATION commented 2 years ago

Thanks. I'll update again to the latest version that is not working for me and run this (and look whether those standard c++ library files are in on of the locations printed by that command - if I still can't figure it out at least now I know how to downgrade again).

I encountered this problem, when installing ucrt or other versions of GCC, it seems that clang cannot find the standard library.I try to install mingw-w64-clang-x86_64-gcc-compat and it solved.

TomislavGoles commented 2 years ago

Thanks! That fixed it for me as well.

jeremyd2019 commented 2 years ago

So it sounds like you were actually using some GCC (probably msys GCC), and it was using its own search paths. The new gcc-compat package just installs gcc-named aliases of clang.exe.

TomislavGoles commented 2 years ago

I do have both mingw64 and clang64 installed so yes I do have GCC as well (11.2.0). What is strange is that before updating clang to version 13.0.1 I did not have this issue. Only after updating something got messed up (before upgrade I did not have that compat package installed at all and everything was compiling fine with both compilers).

jeremyd2019 commented 2 years ago

Before 13.0.1 the clang package included the gcc aliases. They were removed in 13.0.1 (people were confused, were they using GCC or Clang?), but a number of issues cropped up that things were depending on the gcc names, so I made the gcc-compat package in 13.0.1-2 to install them separately.

TomislavGoles commented 2 years ago

Ok, thanks. My workaround solution (before the compat msg was posted today) was to run clang from the msys2 msys terminal shell (which does not see mingw64 installation at all in it's path). That works fine as well (so I used msys2 shell when I want to use clang and msy2 mingw64 terminal for developing with GCC). But after installing the compat package I can use mingw64 shell for both again (same as before I reported the problem in this thread).

mati865 commented 2 years ago

Is there anything left to do here?