ajor / bpftrace

High-level tracing language for Linux eBPF - development moved to https://github.com/iovisor/bpftrace
https://github.com/iovisor/bpftrace
Apache License 2.0
250 stars 15 forks source link

build error converting to std::tuple #1

Closed brendangregg closed 7 years ago

brendangregg commented 7 years ago

Build error:

[ 97%] Built target bpftrace_test
/mnt/src/bpftrace/src/codegen_llvm.cpp: In member function ‘virtual uint8_t* bpftrace::ast::BPFtraceMemoryManager::allocateCodeSection(uintptr_t, unsigned int, unsigned int, llvm::StringRef)’:
/mnt/src/bpftrace/src/codegen_llvm.cpp:365:34: error: converting to ‘std::tuple<unsigned char*, long unsigned int>’ from initializer list would use explicit constructor ‘constexpr std::tuple<_T1, _T2>::tuple(_U1&&, _U2&&) [with _U1 = unsigned char*&; _U2 = long unsigned int&; <template-parameter-2-3> = void; _T1 = unsigned char*; _T2 = long unsigned int]’
     sections_[SectionName.str()] = {addr, Size};
                                  ^
/mnt/src/bpftrace/src/codegen_llvm.cpp: In member function ‘virtual uint8_t* bpftrace::ast::BPFtraceMemoryManager::allocateDataSection(uintptr_t, unsigned int, unsigned int, llvm::StringRef, bool)’:
/mnt/src/bpftrace/src/codegen_llvm.cpp:372:34: error: converting to ‘std::tuple<unsigned char*, long unsigned int>’ from initializer list would use explicit constructor ‘constexpr std::tuple<_T1, _T2>::tuple(_U1&&, _U2&&) [with _U1 = unsigned char*&; _U2 = long unsigned int&; <template-parameter-2-3> = void; _T1 = unsigned char*; _T2 = long unsigned int]’
     sections_[SectionName.str()] = {addr, Size};
                                  ^
src/CMakeFiles/bpftrace.dir/build.make:134: recipe for target 'src/CMakeFiles/bpftrace.dir/codegen_llvm.cpp.o' failed
make[2]: *** [src/CMakeFiles/bpftrace.dir/codegen_llvm.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:275: recipe for target 'src/CMakeFiles/bpftrace.dir/all' failed
make[1]: *** [src/CMakeFiles/bpftrace.dir/all] Error 2
Makefile:94: recipe for target 'all' failed
make: *** [all] Error 2

Here's my g++ version:

# g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I was able to hack this to fix it (I think):

# git diff
diff --git a/src/codegen_llvm.cpp b/src/codegen_llvm.cpp
index 1f3e5bc..47c6483 100644
--- a/src/codegen_llvm.cpp
+++ b/src/codegen_llvm.cpp
@@ -362,14 +362,14 @@ public:
   uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName) override
   {
     uint8_t *addr = SectionMemoryManager::allocateCodeSection(Size, Alignment, SectionID, SectionName);
-    sections_[SectionName.str()] = {addr, Size};
+    sections_[SectionName.str()] = std::tuple<unsigned char*, long unsigned int>(addr, Size);
     return addr;
   }

   uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName, bool isReadOnly) override
   {
     uint8_t *addr = SectionMemoryManager::allocateDataSection(Size, Alignment, SectionID, SectionName, isReadOnly);
-    sections_[SectionName.str()] = {addr, Size};
+    sections_[SectionName.str()] = std::tuple<unsigned char*, long unsigned int>(addr, Size);
     return addr;
   }
ajor commented 7 years ago

Thanks for the report - fixed it now