]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix std::filesystem errors with -fkeep-inline-functions [PR108636]
authorJonathan Wakely <jwakely@redhat.com>
Thu, 2 Feb 2023 14:06:40 +0000 (14:06 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 21 Feb 2023 00:48:05 +0000 (00:48 +0000)
commit0a2597477e482df4d67db6696431286df1ff4428
tree1065c701dac9732c902c64f916791c2b47cd60bf
parentd642468d9cc562197572347a3f85caa208307b4a
libstdc++: Fix std::filesystem errors with -fkeep-inline-functions [PR108636]

With -fkeep-inline-functions there are linker errors when including
<filesystem>. This happens because there are some filesystem::path
constructors defined inline which call non-exported functions defined in
the library. That's usually not a problem, because those constructors
are only called by code that's also inside the library. But when the
header is compiled with -fkeep-inline-functions those inline functions
are emitted even though they aren't called. That then creates an
undefined reference to the other library internsl. The fix is to just
move the private constructors into the library where they are called.
That way they are never even seen by users, and so not compiled even if
-fkeep-inline-functions is used.

libstdc++-v3/ChangeLog:

PR libstdc++/108636
* include/bits/fs_path.h (path::path(string_view, _Type))
(path::_Cmpt::_Cmpt(string_view, _Type, size_t)): Move inline
definitions to ...
* src/c++17/fs_path.cc: ... here.
* testsuite/27_io/filesystem/path/108636.cc: New test.

(cherry picked from commit db8d6fc572ec316ccfcf70b1dffe3be0b1b37212)
libstdc++-v3/include/bits/fs_path.h
libstdc++-v3/src/c++17/fs_path.cc
libstdc++-v3/testsuite/27_io/filesystem/path/108636.cc [new file with mode: 0644]