[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 --- Comment #35 from Jonathan Wakely --- includes just so that std::random_device can do: random_device() { _M_init("default"); } explicit random_device(const std::string& __token) { _M_init(__token); } If we didn't need to construct a string in the default constructor, we could avoid including all of in and just include instead.
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 Jonathan Wakely changed: What|Removed |Added Target Milestone|12.4|---
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 Richard Biener changed: What|Removed |Added Target Milestone|12.3|12.4 --- Comment #34 from Richard Biener --- GCC 12.3 is being released, retargeting bugs to GCC 12.4.
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 Richard Biener changed: What|Removed |Added Target Milestone|12.2|12.3 --- Comment #33 from Richard Biener --- GCC 12.2 is being released, retargeting bugs to GCC 12.3.
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 Jakub Jelinek changed: What|Removed |Added Target Milestone|12.0|12.2 --- Comment #32 from Jakub Jelinek --- GCC 12.1 is being released, retargeting bugs to GCC 12.2.
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 --- Comment #31 from Jonathan Wakely --- std::construct_at and std::destroy_at are in alongside std::_Construct and std::_Destroy. But the latter need iterator category definitions for destroying sequences. std::construct_at and std::destroy_at have no dependencies. They could be moved into or or something smaller. This would benefit (and maybe other headers).
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 --- Comment #30 from Jonathan Wakely --- (In reply to Jonathan Wakely from comment #29) > Avoiding makes a big difference: > > $ : | g++-11 -std=gnu++17 -P -E -x c++ - -include algorithm | wc -l > 27018 Doh, pasted the wrong line, the first number is g++-10 not g++-11 > $ : | g++-11 -std=gnu++17 -P -E -x c++ - -include algorithm | wc -l > 25188 > $ : | g++-12 -std=gnu++17 -P -E -x c++ - -include algorithm | wc -l > 12268 > > $ : | g++-11 -std=gnu++20 -P -E -x c++ - -include algorithm | wc -l > 45780 Same here > $ : | g++-11 -std=gnu++20 -P -E -x c++ - -include algorithm | wc -l > 42404 > $ : | g++-12 -std=gnu++20 -P -E -x c++ - -include algorithm | wc -l > 20918
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 --- Comment #29 from Jonathan Wakely --- Avoiding makes a big difference: $ : | g++-11 -std=gnu++17 -P -E -x c++ - -include algorithm | wc -l 27018 $ : | g++-11 -std=gnu++17 -P -E -x c++ - -include algorithm | wc -l 25188 $ : | g++-12 -std=gnu++17 -P -E -x c++ - -include algorithm | wc -l 12268 $ : | g++-11 -std=gnu++20 -P -E -x c++ - -include algorithm | wc -l 45780 $ : | g++-11 -std=gnu++20 -P -E -x c++ - -include algorithm | wc -l 42404 $ : | g++-12 -std=gnu++20 -P -E -x c++ - -include algorithm | wc -l 20918 Improvements still to be done (in stage 1): - Replace std::vector in (comment 19) - Replace std::vector in - Reduce PSTL includes (comment 27)
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 --- Comment #28 from CVS Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:ac73c944eac88f37db2767aa4acc7ff6f4983f21 commit r12-7699-gac73c944eac88f37db2767aa4acc7ff6f4983f21 Author: Jonathan Wakely Date: Thu Mar 17 16:45:43 2022 + libstdc++: Reduce header dependencies from PSTL headers [PR92546] This avoids including the whole of in , as the header only actually needs std::pair. This also avoids including in , which only needs , std::bad_alloc, and std::terminate (which can be repalced with std::__terminate). This matters less, because is only included by the headers and they all use anyway, and are only included by . libstdc++-v3/ChangeLog: PR libstdc++/92546 * include/pstl/glue_algorithm_defs.h: Replace with . * include/pstl/utils.h: Replace with . (__pstl::__internal::__except_handler): Use std::__terminate instead of std::terminate. * src/c++17/fs_path.cc: Include . * testsuite/25_algorithms/adjacent_find/constexpr.cc: Include . * testsuite/25_algorithms/binary_search/constexpr.cc: Likewise. * testsuite/25_algorithms/clamp/constrained.cc: Likewise. * testsuite/25_algorithms/equal/constrained.cc: Likewise. * testsuite/25_algorithms/for_each/constrained.cc: Likewise. * testsuite/25_algorithms/includes/constrained.cc: Likewise. * testsuite/25_algorithms/is_heap/constexpr.cc: Likewise. * testsuite/25_algorithms/is_heap_until/constexpr.cc: Likewise. * testsuite/25_algorithms/is_permutation/constrained.cc: Include . * testsuite/25_algorithms/is_sorted/constexpr.cc: Include . * testsuite/25_algorithms/is_sorted_until/constexpr.cc: Likewise. * testsuite/25_algorithms/lexicographical_compare/constexpr.cc: Likewise. * testsuite/25_algorithms/lexicographical_compare/constrained.cc: Likewise. * testsuite/25_algorithms/lexicographical_compare_three_way/1.cc: Include . * testsuite/25_algorithms/lower_bound/constexpr.cc: Include . * testsuite/25_algorithms/max/constrained.cc: Likewise. * testsuite/25_algorithms/max_element/constrained.cc: Likewise. * testsuite/25_algorithms/min/constrained.cc: Likewise. * testsuite/25_algorithms/min_element/constrained.cc: Likewise. * testsuite/25_algorithms/minmax_element/constrained.cc: Likewise. * testsuite/25_algorithms/mismatch/constexpr.cc: Likewise. * testsuite/25_algorithms/move/93872.cc: Likewise. * testsuite/25_algorithms/move_backward/93872.cc: Include . * testsuite/25_algorithms/nth_element/constexpr.cc: Include . * testsuite/25_algorithms/partial_sort/constexpr.cc: Likewise. * testsuite/25_algorithms/partial_sort_copy/constexpr.cc: Likewise. * testsuite/25_algorithms/search/constexpr.cc: Likewise. * testsuite/25_algorithms/search_n/constrained.cc: Likewise. * testsuite/25_algorithms/set_difference/constexpr.cc: Likewise. * testsuite/25_algorithms/set_difference/constrained.cc: Likewise. * testsuite/25_algorithms/set_intersection/constexpr.cc: Likewise. * testsuite/25_algorithms/set_intersection/constrained.cc: Likewise. * testsuite/25_algorithms/set_symmetric_difference/constexpr.cc: Likewise. * testsuite/25_algorithms/set_union/constexpr.cc: Likewise. * testsuite/25_algorithms/set_union/constrained.cc: Likewise. * testsuite/25_algorithms/sort/constexpr.cc: Likewise. * testsuite/25_algorithms/sort_heap/constexpr.cc: Likewise. * testsuite/25_algorithms/transform/constrained.cc: Likewise. * testsuite/25_algorithms/unique/constexpr.cc: Likewise. * testsuite/25_algorithms/unique/constrained.cc: Likewise. * testsuite/25_algorithms/unique_copy/constexpr.cc: Likewise. * testsuite/25_algorithms/upper_bound/constexpr.cc: Likewise. * testsuite/std/ranges/adaptors/elements.cc: Include . * testsuite/std/ranges/adaptors/lazy_split.cc: Likewise. * testsuite/std/ranges/adaptors/split.cc: Likewise.
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 --- Comment #27 from Jonathan Wakely --- pst/algorithm_impl.h includes just because it needs std::not_fn. We could move that to a separate header. Even without that, we could do: --- a/libstdc++-v3/include/pstl/algorithm_impl.h +++ b/libstdc++-v3/include/pstl/algorithm_impl.h @@ -10,11 +10,12 @@ #ifndef _PSTL_ALGORITHM_IMPL_H #define _PSTL_ALGORITHM_IMPL_H -#include #include -#include #include #include +#include +#include +#include #include "execution_impl.h" #include "memory_impl.h" And similarly: --- a/libstdc++-v3/include/pstl/glue_numeric_impl.h +++ b/libstdc++-v3/include/pstl/glue_numeric_impl.h @@ -10,7 +10,7 @@ #ifndef _PSTL_GLUE_NUMERIC_IMPL_H #define _PSTL_GLUE_NUMERIC_IMPL_H -#include +#include #include "utils.h" #include "numeric_fwd.h" And: --- a/libstdc++-v3/include/pstl/memory_impl.h +++ b/libstdc++-v3/include/pstl/memory_impl.h @@ -10,7 +10,8 @@ #ifndef _PSTL_MEMORY_IMPL_H #define _PSTL_MEMORY_IMPL_H -#include +#include +#include #include "unseq_backend_simd.h" However, these headers come from upstream, so this would slightly complicate rebasing on new upstream versions.
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 --- Comment #26 from CVS Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:00df7ee4474faca91d3460fe78a88e280c6c1126 commit r12-7691-g00df7ee4474faca91d3460fe78a88e280c6c1126 Author: Jonathan Wakely Date: Thu Mar 17 14:36:07 2022 + libstdc++: Avoid including in [PR92546] This only affects Windows, but reduces the preprocessed size of significantly. libstdc++-v3/ChangeLog: PR libstdc++/92546 * include/bits/fs_path.h (path::make_preferred): Use handwritten loop instead of std::replace.
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 --- Comment #25 from CVS Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:a1fc4075fcdf028f2e1dc00ce515a947127e2667 commit r12-4252-ga1fc4075fcdf028f2e1dc00ce515a947127e2667 Author: Jonathan Wakely Date: Thu Apr 8 10:01:08 2021 +0100 libstdc++: Reduce header dependencies of in C++20 [PR 92546] The header doesn't need the stream and streambuf iterators, so don't include the whole of . libstdc++-v3/ChangeLog: PR libstdc++/92546 * include/bits/ranges_algobase.h: Replace with a subset of the headers it includes.
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 --- Comment #24 from CVS Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:acf3a21cbc26b39b73c0006300f35ff017ddd6cb commit r12-4083-gacf3a21cbc26b39b73c0006300f35ff017ddd6cb Author: Jonathan Wakely Date: Fri Oct 1 20:37:02 2021 +0100 libstdc++: Reduce header dependencies for C++20 std::erase [PR92546] This reduces the preprocessed size of , and by not including for std::remove and std::remove_if. Also unwrap iterators using __niter_base, to avoid redundant debug mode checks. PR libstdc++/92546 * include/bits/erase_if.h (__erase_nodes_if): Use __niter_base to unwrap debug iterators. * include/bits/refwrap.h: Do not error if included in C++03. * include/bits/stl_algo.h (__remove_if): Move to ... * include/bits/stl_algobase.h (__remove_if): ... here. * include/std/deque (erase, erase_if): Use __remove_if instead of remove and remove_if. * include/std/string (erase, erase_if): Likewise. * include/std/vector (erase, erase_if): Likewise.
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 --- Comment #23 from Jonathan Wakely --- The other improvement we could make for C++20 is to replace in with smaller pieces, as it doesn't need the definition of std::streambuf_iterator: --- a/libstdc++-v3/include/bits/ranges_algobase.h +++ b/libstdc++-v3/include/bits/ranges_algobase.h @@ -33,7 +33,10 @@ #if __cplusplus > 201703L #include -#include +#include +#include +#include +#include #include // ranges::begin, ranges::range etc. #include // __invoke #include // __is_byte And doesn't need , just .
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 Jonathan Wakely changed: What|Removed |Added CC||hewillk at gmail dot com --- Comment #22 from Jonathan Wakely --- *** Bug 99958 has been marked as a duplicate of this bug. ***
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 --- Comment #21 from Jonathan Wakely --- This seems to work: diff --git a/libstdc++-v3/include/pstl/glue_algorithm_defs.h b/libstdc++-v3/include/pstl/glue_algorithm_defs.h index 48bc56ae401..cef78e22e31 100644 --- a/libstdc++-v3/include/pstl/glue_algorithm_defs.h +++ b/libstdc++-v3/include/pstl/glue_algorithm_defs.h @@ -10,7 +10,7 @@ #ifndef _PSTL_GLUE_ALGORITHM_DEFS_H #define _PSTL_GLUE_ALGORITHM_DEFS_H -#include +#include #include "execution_defs.h" diff --git a/libstdc++-v3/include/pstl/utils.h b/libstdc++-v3/include/pstl/utils.h index 1711f292678..69d78c3ca0f 100644 --- a/libstdc++-v3/include/pstl/utils.h +++ b/libstdc++-v3/include/pstl/utils.h @@ -10,8 +10,9 @@ #ifndef _PSTL_UTILS_H #define _PSTL_UTILS_H +#include #include -#include +#include namespace __pstl { The header only requires declarations of std::bad_alloc and std::terminate(), but includes and to get them. That could be reduced with some minor surgery.
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 --- Comment #20 from Jonathan Wakely --- As noted in PR 99958 comment 1, got big, because: is included by which is included by which is included by which is included by which is included by which is included by . is included by , which is included by . That should not be including the whole of . It looks like it only needs .
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 --- Comment #19 from Jonathan Wakely --- (In reply to Jonathan Wakely from comment #16) > includes so std::boyer_moore_searcher can use > std::vector, but it doesn't need it at all. Using std::unique_ptr would > do fine. We can't change that now though, because the C++17 ABI is stable. I have a patch for a lightweight vector that is ABI compatible though, so we could use that.
[Bug libstdc++/92546] Large increase in preprocessed file sizes in C++2a mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546 Jonathan Wakely changed: What|Removed |Added Target Milestone|10.3|12.0 Summary|[10/11 Regression] Large|Large increase in |increase in preprocessed|preprocessed file sizes in |file sizes in C++2a mode|C++2a mode --- Comment #18 from Jonathan Wakely --- Definitely defer. I think we could remove the regression marker now too.