FS#63651 - [gcc8] gcc8 has incorrect paths? stdc++fs not found when gcc is not installed

Attached to Project: Community Packages
Opened by Mateusz Szychowski (muttley) - Wednesday, 04 September 2019, 09:57 GMT
Last edited by Sven-Hendrik Haase (Svenstaro) - Monday, 23 September 2019, 11:22 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Sven-Hendrik Haase (Svenstaro)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
When trying to build simple C++ program using stdc++fs, ld will say '/usr/sbin/ld: cannot find -lstdc++fs'.
This happens when 'gcc' is not installed (only gcc8, gcc8-libs and gcc-libs are installed)

Additional info:
$ pacman -Qi gcc8 gcc8-libs | grep -i version
Version : 8.3.0-2
Version : 8.3.0-2

Steps to reproduce:
docker run --rm -it archlinux/base:latest bash
pacman -Sy git gcc8
git clone https://github.com/muttleyxd/gcc_8_arch_issue.git
cd gcc_8_arch_issue
./error.sh

If 'gcc' is not installed:
$ ./error.sh
+ g++-8 -g2 -O0 -std=c++17 -c main.cpp -o main.o
+ g++-8 main.o -o main -lstdc++fs
/usr/sbin/ld: cannot find -lstdc++fs
collect2: error: ld returned 1 exit status
+ set +x

If 'gcc' is installed:
$ ./error.sh
+ g++-8 -g2 -O0 -std=c++17 -c main.cpp -o main.o
+ g++-8 main.o -o main -lstdc++fs
/usr/sbin/ld: main.o: in function `std::filesystem::__cxx11::operator==(std::filesystem::__cxx11::path const&, std::filesystem::__cxx11::path const&)':
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/c++/bits/fs_path.h:545: undefined reference to `std::filesystem::__cxx11::path::compare(std::filesystem::__cxx11::path const&) const'
/usr/sbin/ld: main.o: in function `std::filesystem::__cxx11::path::path<char [6], std::filesystem::__cxx11::path>(char const (&) [6], std::filesystem::__cxx11::path::format)':
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/c++/bits/fs_path.h:184: undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/sbin/ld: main.o: in function `std::filesystem::__cxx11::path::path<char [5], std::filesystem::__cxx11::path>(char const (&) [5], std::filesystem::__cxx11::path::format)':
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/c++/bits/fs_path.h:184: undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
collect2: error: ld returned 1 exit status
+ set +x
This task depends upon

Closed by  Sven-Hendrik Haase (Svenstaro)
Monday, 23 September 2019, 11:22 GMT
Reason for closing:  Fixed
Comment by Mateusz Szychowski (muttley) - Wednesday, 04 September 2019, 09:59 GMT
This doesn't happen on Ubuntu and Fedora, but happens on Arch and Manjaro, so I assume it's some kind of packaging issue

source for main.cpp
#include <filesystem>

int main()
{
std::filesystem::path p("/root");
std::filesystem::path p2("/usr");
if (p == p2)
return 1;
return 0;
}
Comment by loqs (loqs) - Thursday, 05 September 2019, 16:11 GMT
Can you try gcc8 8.3.0-1 from the Arch Linux Archive please.
I believe the issue is the lack of libstdc++fs.a which conflicts with the same file supplied by gcc.
If the file were moved to /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0 it would not conflict,
would need to test if it is used instead of the one in /usr/lib.
Comment by Mateusz Szychowski (muttley) - Friday, 06 September 2019, 11:30 GMT
I couldn't install gcc8-libs and gcc8 with:
pacman -U https://archive.archlinux.org/packages/g/gcc8/gcc8-8.3.0-1-x86_64.pkg.tar.xz https://archive.archlinux.org/packages/g/gcc8-libs/gcc8-libs-8.3.0-1-x86_64.pkg.tar.xz

errors:
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/libmpx.spec exists in both 'gcc8-libs' and 'gcc8'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/libstdc++.so exists in both 'gcc8-libs' and 'gcc8'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/libstdc++.so.6 exists in both 'gcc8-libs' and 'gcc8'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/libstdc++.so.6.0.25 exists in both 'gcc8-libs' and 'gcc8'
/usr/lib/gcc/x86_64-pc-linux-gnu/lib/libgcc_s.so exists in both 'gcc8-libs' and 'gcc8'
/usr/lib/gcc/x86_64-pc-linux-gnu/lib/libgcc_s.so.1 exists in both 'gcc8-libs' and 'gcc8'

But overwriting worked, so I can say that gcc8 8.3.0-1 works fine.
Comment by loqs (loqs) - Friday, 06 September 2019, 15:13 GMT
PKGBUID change to leave in gcc8 the following files:
usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/libstdc++.a
usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/libstdc++fs.a

The latter file is needed to link libstdc++fs unsure on the former.
The provided test then builds successfully.
Comment by Sven-Hendrik Haase (Svenstaro) - Sunday, 22 September 2019, 11:34 GMT
Ok, check now.
Comment by Mateusz Szychowski (muttley) - Monday, 23 September 2019, 06:49 GMT
It works fine, thanks!

Loading...