From 1852af16a1c52e5d61e30a43ed74a446514152fc Mon Sep 17 00:00:00 2001 From: Siva Chandra Reddy Date: Tue, 28 Apr 2020 14:00:12 -0700 Subject: [PATCH] [libc] Fix benchmarks build. Reviewers: gchatelet, echristo Subscribers: mgorny, tschuett, libc-commits Tags: #libc-project Differential Revision: https://reviews.llvm.org/D79040 --- libc/utils/benchmarks/CMakeLists.txt | 1 + libc/utils/benchmarks/JSON.cpp | 4 +++- libc/utils/benchmarks/LibcMemoryBenchmarkMain.cpp | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libc/utils/benchmarks/CMakeLists.txt b/libc/utils/benchmarks/CMakeLists.txt index d5926d67ab687..49eba9bccbea2 100644 --- a/libc/utils/benchmarks/CMakeLists.txt +++ b/libc/utils/benchmarks/CMakeLists.txt @@ -24,6 +24,7 @@ ExternalProject_Add(google-benchmark -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_FLAGS:STRING=${GOOGLE_BENCHMARK_TARGET_FLAGS} + -DCMAKE_CXX_STANDARD:STRING=14 -DCMAKE_BUILD_TYPE:STRING=RELEASE -DCMAKE_INSTALL_PREFIX:PATH= -DBENCHMARK_ENABLE_TESTING:BOOL=OFF) diff --git a/libc/utils/benchmarks/JSON.cpp b/libc/utils/benchmarks/JSON.cpp index 175aa2209ef20..2f37041449837 100644 --- a/libc/utils/benchmarks/JSON.cpp +++ b/libc/utils/benchmarks/JSON.cpp @@ -17,9 +17,11 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/JSON.h" #include "llvm/Support/MathExtras.h" + #include #include #include +#include #include namespace llvm { @@ -48,7 +50,7 @@ static Error fromJson(const json::Value &V, double &Out) { static Error fromJson(const json::Value &V, std::string &Out) { if (auto S = V.getAsString()) { - Out = *S; + Out = std::string(*S); return Error::success(); } return createStringError(errc::io_error, "Can't parse String"); diff --git a/libc/utils/benchmarks/LibcMemoryBenchmarkMain.cpp b/libc/utils/benchmarks/LibcMemoryBenchmarkMain.cpp index e30597187c52c..79774c3526a04 100644 --- a/libc/utils/benchmarks/LibcMemoryBenchmarkMain.cpp +++ b/libc/utils/benchmarks/LibcMemoryBenchmarkMain.cpp @@ -17,6 +17,8 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" +#include + namespace llvm { namespace libc_benchmarks { @@ -61,7 +63,7 @@ void Main() { size_t Steps = 0; for (auto FunctionName : Runner->getFunctionNames()) { FunctionMeasurements FM; - FM.Name = FunctionName; + FM.Name = std::string(FunctionName); for (size_t Run = 0; Run < Runs; ++Run) { for (uint32_t Size = SR.From; Size <= SR.To; Size += SR.Step) { const auto Result = Runner->benchmark(S.Options, FunctionName, Size);