[libc] Fix benchmarks build.
authorSiva Chandra Reddy <sivachandra@google.com>
Tue, 28 Apr 2020 21:00:12 +0000 (14:00 -0700)
committerSiva Chandra Reddy <sivachandra@google.com>
Tue, 28 Apr 2020 21:30:48 +0000 (14:30 -0700)
Reviewers: gchatelet, echristo

Subscribers: mgorny, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D79040

libc/utils/benchmarks/CMakeLists.txt
libc/utils/benchmarks/JSON.cpp
libc/utils/benchmarks/LibcMemoryBenchmarkMain.cpp

index d5926d6..49eba9b 100644 (file)
@@ -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=<INSTALL_DIR>
         -DBENCHMARK_ENABLE_TESTING:BOOL=OFF)
index 175aa22..2f37041 100644 (file)
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/MathExtras.h"
+
 #include <chrono>
 #include <limits>
 #include <memory>
+#include <string>
 #include <vector>
 
 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");
index e305971..79774c3 100644 (file)
@@ -17,6 +17,8 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/raw_ostream.h"
 
+#include <string>
+
 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);