diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2020-01-09 13:18:20 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2020-01-09 13:18:20 +0000 |
commit | d574c8aafea40bd8759cb09031ff0dc6c250d8cf (patch) | |
tree | 2a9d4cb5cda8c0decff5dad89ba215ee2a114fb8 | |
parent | 27c5a1779badd02b337af5887e26b5420fbf71c7 (diff) | |
download | gcc-d574c8aafea40bd8759cb09031ff0dc6c250d8cf.zip gcc-d574c8aafea40bd8759cb09031ff0dc6c250d8cf.tar.gz gcc-d574c8aafea40bd8759cb09031ff0dc6c250d8cf.tar.bz2 |
libstdc++: Define memory resource key functions non-inline (PR93208)
This prevents the vtables and RTTI from being emitted in every object
file that uses memory_resource and monotonic_buffer_resource.
Objects compiled by GCC 9.1 or 9.2 will contain inline definitions of
the destructors, vtable and RTTI, but this is harmless. The inline
definitions have identical effects to the ones that are now defined in
libstdc++.so so it doesn't matter if the inline ones are used instead of
calling the symbols exported from the runtime library.
PR libstdc++/93208
* config/abi/pre/gnu.ver: Add new exports.
* include/std/memory_resource (memory_resource::~memory_resource()):
Do not define inline.
(monotonic_buffer_resource::~monotonic_buffer_resource()): Likewise.
* src/c++17/memory_resource.cc (memory_resource::~memory_resource()):
Define.
(monotonic_buffer_resource::~monotonic_buffer_resource()): Define.
* testsuite/20_util/monotonic_buffer_resource/93208.cc: New test.
From-SVN: r280044
-rw-r--r-- | libstdc++-v3/ChangeLog | 12 | ||||
-rw-r--r-- | libstdc++-v3/config/abi/pre/gnu.ver | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/std/memory_resource | 4 | ||||
-rw-r--r-- | libstdc++-v3/src/c++17/memory_resource.cc | 8 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/monotonic_buffer_resource/93208.cc | 29 |
5 files changed, 57 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 0cbdc07..331d01e 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,15 @@ +2020-01-09 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/93208 + * config/abi/pre/gnu.ver: Add new exports. + * include/std/memory_resource (memory_resource::~memory_resource()): + Do not define inline. + (monotonic_buffer_resource::~monotonic_buffer_resource()): Likewise. + * src/c++17/memory_resource.cc (memory_resource::~memory_resource()): + Define. + (monotonic_buffer_resource::~monotonic_buffer_resource()): Define. + * testsuite/20_util/monotonic_buffer_resource/93208.cc: New test. + 2020-01-09 François Dumont <fdumont@gcc.gnu.org> PR libstdc++/92124 diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index 7f84f3e..edf4485 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -2291,6 +2291,12 @@ GLIBCXX_3.4.28 { _ZNSt12__shared_ptrINSt10filesystem28recursive_directory_iterator10_Dir_stackELN9__gnu_cxx12_Lock_policyE[012]EEC2EOS5_; _ZNSt12__shared_ptrINSt10filesystem7__cxx1128recursive_directory_iterator10_Dir_stackELN9__gnu_cxx12_Lock_policyE[012]EEC2EOS6_; + # key functions, vtables and rtti for memory resources + _ZNSt3pmr15memory_resourceD[0125]Ev; + _ZT[ISV]NSt3pmr15memory_resourceE; + _ZNSt3pmr25monotonic_buffer_resourceD[0125]Ev; + _ZT[ISV]NSt3pmr25monotonic_buffer_resourceE; + } GLIBCXX_3.4.27; # Symbols in the support library (libsupc++) have their own tag. diff --git a/libstdc++-v3/include/std/memory_resource b/libstdc++-v3/include/std/memory_resource index ee2d983..13be3e9 100644 --- a/libstdc++-v3/include/std/memory_resource +++ b/libstdc++-v3/include/std/memory_resource @@ -88,7 +88,7 @@ namespace pmr public: memory_resource() = default; memory_resource(const memory_resource&) = default; - virtual ~memory_resource() = default; + virtual ~memory_resource(); // key function memory_resource& operator=(const memory_resource&) = default; @@ -600,7 +600,7 @@ namespace pmr monotonic_buffer_resource(const monotonic_buffer_resource&) = delete; - virtual ~monotonic_buffer_resource() { release(); } + virtual ~monotonic_buffer_resource(); // key function monotonic_buffer_resource& operator=(const monotonic_buffer_resource&) = delete; diff --git a/libstdc++-v3/src/c++17/memory_resource.cc b/libstdc++-v3/src/c++17/memory_resource.cc index fa3d6cd..37386cd 100644 --- a/libstdc++-v3/src/c++17/memory_resource.cc +++ b/libstdc++-v3/src/c++17/memory_resource.cc @@ -37,6 +37,10 @@ namespace std _GLIBCXX_VISIBILITY(default) _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace pmr { + // This was defined inline in 9.1 and 9.2 so code compiled by those + // versions will not use this symbol. + memory_resource::~memory_resource() = default; + namespace { class newdel_res_t final : public memory_resource @@ -167,6 +171,10 @@ namespace pmr // Member functions for std::pmr::monotonic_buffer_resource + // This was defined inline in 9.1 and 9.2 so code compiled by those + // versions will not use this symbol. + monotonic_buffer_resource::~monotonic_buffer_resource() { release(); } + // Memory allocated by the upstream resource is managed in a linked list // of _Chunk objects. A _Chunk object recording the size and alignment of // the allocated block and a pointer to the previous chunk is placed diff --git a/libstdc++-v3/testsuite/20_util/monotonic_buffer_resource/93208.cc b/libstdc++-v3/testsuite/20_util/monotonic_buffer_resource/93208.cc new file mode 100644 index 0000000..b0cfdbd --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/monotonic_buffer_resource/93208.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } +// { dg-final { scan-assembler-not "_ZT\[IS\]NSt3pmr15memory_resourceE" } } +// { dg-final { scan-assembler-not "_ZT\[IS\]NSt3pmr25monotonic\[a-z_\]*E" } } + +#include <memory_resource> + +void* f(int n) +{ + std::pmr::monotonic_buffer_resource res; + return res.allocate(n); +} |