[compiler-rt] 7e8d5a9 - Avoid use of std::make_unique in compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
Hans Wennborg via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 28 03:34:06 PDT 2020
Author: Hans Wennborg
Date: 2020-07-28T12:33:51+02:00
New Revision: 7e8d5a90f2c101388d3b0bbce8555e871c670232
URL: https://github.com/llvm/llvm-project/commit/7e8d5a90f2c101388d3b0bbce8555e871c670232
DIFF: https://github.com/llvm/llvm-project/commit/7e8d5a90f2c101388d3b0bbce8555e871c670232.diff
LOG: Avoid use of std::make_unique in compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
make_unique is a C++14 feature, and this prevents us from building on
Ubuntu Trusty. While we do use a C++14 compatible toolchain for building
in general, we fall back to the system toolchain for building the
compiler-rt tests.
The reason is that those tests get cross-compiled for e.g. 32-bit and
64-bit x86, and while the toolchain provides libstdc++ in those
flavours, the resulting compiler-rt test binaries don't get RPATH set
and so won't start if they're linked with that toolchain.
We've tried linking the test binaries against libstdc++ statically, by
passing COMPILER_RT_TEST_COMPILER_CFLAGS=-static-libstdc++. That mostly
works, but some test targets append -lstdc++ to the compiler invocation.
So, after spending way too much time on this, let's just avoid C++14
here for now.
Added:
Modified:
compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
index c144ad0ae32a..6cefe18b8f15 100644
--- a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
@@ -78,7 +78,7 @@ template <typename Config> struct TestAllocator : scudo::Allocator<Config> {
template <class Config> static void testAllocator() {
using AllocatorT = TestAllocator<Config>;
- auto Allocator = std::make_unique<AllocatorT>();
+ auto Allocator = std::unique_ptr<AllocatorT>(new AllocatorT());
EXPECT_FALSE(Allocator->isOwned(&Mutex));
EXPECT_FALSE(Allocator->isOwned(&Allocator));
@@ -352,7 +352,7 @@ template <typename AllocatorT> static void stressAllocator(AllocatorT *A) {
template <class Config> static void testAllocatorThreaded() {
using AllocatorT = TestAllocator<Config>;
- auto Allocator = std::make_unique<AllocatorT>();
+ auto Allocator = std::unique_ptr<AllocatorT>(new AllocatorT());
std::thread Threads[32];
for (scudo::uptr I = 0; I < ARRAY_SIZE(Threads); I++)
Threads[I] = std::thread(stressAllocator<AllocatorT>, Allocator.get());
@@ -399,7 +399,7 @@ struct DeathConfig {
TEST(ScudoCombinedTest, DeathCombined) {
using AllocatorT = TestAllocator<DeathConfig>;
- auto Allocator = std::make_unique<AllocatorT>();
+ auto Allocator = std::unique_ptr<AllocatorT>(new AllocatorT());
const scudo::uptr Size = 1000U;
void *P = Allocator->allocate(Size, Origin);
@@ -434,7 +434,7 @@ TEST(ScudoCombinedTest, DeathCombined) {
// operation without issue.
TEST(ScudoCombinedTest, ReleaseToOS) {
using AllocatorT = TestAllocator<DeathConfig>;
- auto Allocator = std::make_unique<AllocatorT>();
+ auto Allocator = std::unique_ptr<AllocatorT>(new AllocatorT());
Allocator->releaseToOS();
}
@@ -443,7 +443,7 @@ TEST(ScudoCombinedTest, ReleaseToOS) {
// fulfill the allocation through a larger size class.
TEST(ScudoCombinedTest, FullRegion) {
using AllocatorT = TestAllocator<DeathConfig>;
- auto Allocator = std::make_unique<AllocatorT>();
+ auto Allocator = std::unique_ptr<AllocatorT>(new AllocatorT());
std::vector<void *> V;
scudo::uptr FailedAllocationsCount = 0;
@@ -474,7 +474,7 @@ TEST(ScudoCombinedTest, FullRegion) {
TEST(ScudoCombinedTest, OddEven) {
using AllocatorT = TestAllocator<scudo::AndroidConfig>;
using SizeClassMap = AllocatorT::PrimaryT::SizeClassMap;
- auto Allocator = std::make_unique<AllocatorT>();
+ auto Allocator = std::unique_ptr<AllocatorT>(new AllocatorT());
if (!Allocator->useMemoryTagging())
return;
More information about the llvm-commits
mailing list