Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pika compile error with gcc 9.3 which is default in ubuntu 20.04 #1103

Closed
kernelai opened this issue Nov 5, 2021 · 3 comments · Fixed by #1104
Closed

pika compile error with gcc 9.3 which is default in ubuntu 20.04 #1103

kernelai opened this issue Nov 5, 2021 · 3 comments · Fixed by #1104

Comments

@kernelai
Copy link
Collaborator

kernelai commented Nov 5, 2021

env:

➜  rocksdb git:(004237e62) hostnamectl
   Static hostname: ubuntu
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 0cf4eb7841d1420ca74911c50be49e02
           Boot ID: d712388d9098445986b53c13bb4d70d9
    Virtualization: oracle
  Operating System: Ubuntu 20.04.3 LTS
            Kernel: Linux 5.4.0-89-generic
      Architecture: x86-64

compiler:

➜  rocksdb git:(004237e62) g++ --version
g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 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.

error:

./db/version_edit.h: In constructor ‘rocksdb::FdWithKeyRange::FdWithKeyRange(rocksdb::FileDescriptor, rocksdb::Slice, rocksdb::Slice, rocksdb::FileMetaData*)’:
**./db/version_edit.h:156:33: error: implicitly-declared ‘constexpr rocksdb::FileDescriptor::FileDescriptor(const rocksdb::FileDescriptor&)’ is deprecated [-Werror=deprecated-copy]**
  156 |         largest_key(_largest_key) {}
      |                                 ^
./db/version_edit.h:47:19: note: because ‘rocksdb::FileDescriptor’ has user-provided ‘rocksdb::FileDescriptor& rocksdb::FileDescriptor::operator=(const rocksdb::FileD
escriptor&)’
   47 |   FileDescriptor& operator=(const FileDescriptor& fd) {
      |                   ^~~~~~~~
./db/version_edit.h: In instantiation of ‘constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U1 = int&; _U2 = rocksdb::FileMetaData; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = true; _T1 = int; _T2 = rocksdb::FileMetaData]’:
/usr/include/c++/9/ext/new_allocator.h:147:4:   required from ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::pair<int, rocksdb::FileMetaData>; _Args = {int&, rocksdb::FileMetaData}; _Tp = std::pair<int, rocksdb::FileMetaData>]’
/usr/include/c++/9/bits/alloc_traits.h:484:4:   required from ‘static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::pair<int, rocksdb::FileMetaData>; _Args = {int&, rocksdb::FileMetaData}; _Tp = std::pair<int, rocksdb::FileMetaData>; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<std::pair<int, rocksdb::FileMetaData> >]’
/usr/include/c++/9/bits/vector.tcc:115:30:   required from ‘void std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, rocksdb::FileMetaData}; _Tp = std::pair<int, rocksdb::FileMetaData>; _Alloc = std::allocator<std::pair<int, rocksdb::FileMetaData> >]’
./db/version_edit.h:218:48:   required from here
./db/version_edit.h:76:8: error: implicitly-declared ‘constexpr rocksdb::FileDescriptor::FileDescriptor(const rocksdb::FileDescriptor&)’ is deprecated [-Werror=deprecated-copy]
@kernelai kernelai self-assigned this Nov 5, 2021
@kernelai kernelai changed the title pika with high compiler (gcc 9.3) errror pika with high version compiler (gcc 9.3) errror Nov 5, 2021
@kernelai
Copy link
Collaborator Author

kernelai commented Nov 5, 2021

facebook rocksdb try to fix it. #issue

@kernelai kernelai changed the title pika with high version compiler (gcc 9.3) errror pika compile error with gcc 9.3 which is default in ubuntu 20.04 Nov 5, 2021
@kernelai
Copy link
Collaborator Author

kernelai commented Nov 5, 2021

编译报错的原因是 comment总结起来是声明了拷贝赋值函数,而没有声明拷贝构造函数,当隐式使用拷贝构造函数时,编译器会报错。早期的编译器不报错,但gcc 8 9 会强制报错。

方案:
1, rocksdb修复了这个问题pull。升级新版本rocksdb。
2, 使用编译选项CXXFLAGS='-Wno-error=deprecated-copy -Wno-error=pessimizing-move'

@kernelai
Copy link
Collaborator Author

kernelai commented Nov 5, 2021

新的报错:

./memtable/inlineskiplist.h:282:11: error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct std::atomic<rocksdb::InlineSkipList<const rocksdb::MemTableRep::KeyComparator&>::Node*>’ with no trivial copy-assignment [-Werror=class-memaccess]
  282 |     memcpy(&next_[0], &height, sizeof(int));
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./memtable/inlineskiplist.h:47,
                 from memtable/skiplistrep.cc:6:
/usr/include/c++/9/atomic:356:12: note: ‘struct std::atomic<rocksdb::InlineSkipList<const rocksdb::MemTableRep::KeyComparator&>::Node*>’ declared here
  356 |     struct atomic<_Tp*>
      |            ^~~~~~~~~~~~
In file included from ./db/range_del_aggregator.h:15,
                 from ./db/memtable.h:19,
                 from memtable/skiplistrep.cc:7:
./db/version_edit.h: In instantiation of ‘constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U1 = int&; _U2 = rocksdb::FileMetaData; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = true; _T1 = int; _T2 = rocksdb::FileMetaData]’:
/usr/include/c++/9/ext/new_allocator.h:147:4:   required from ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::pair<int, rocksdb::FileMetaData>; _Args = {int&, rocksdb::FileMetaData}; _Tp = std::pair<int, rocksdb::FileMetaData>]’
/usr/include/c++/9/bits/alloc_traits.h:484:4:   required from ‘static void std::allocator_traits<std::allocator<_Tp> >::construct(std::allocator_traits<std::allocator<_Tp> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::pair<int, rocksdb::FileMetaData>; _Args = {int&, rocksdb::FileMetaData}; _Tp = std::pair<int, rocksdb::FileMetaData>; std::allocator_traits<std::allocator<_Tp> >::allocator_type = std::allocator<std::pair<int, rocksdb::FileMetaData> >]’
/usr/include/c++/9/bits/vector.tcc:115:30:   required from ‘void std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, rocksdb::FileMetaData}; _Tp = std::pair<int, rocksdb::FileMetaData>; _Alloc = std::allocator<std::pair<int, rocksdb::FileMetaData> >]’

对象没有普通拷贝复制函数。
rocksdb fix it pr.
可以使用-Wno-error=class-memaccess 忽略掉该错误。

报错:

./memtable/inlineskiplist.h:302:54: error: array subscript -1 is below array bounds of ‘std::atomic<rocksdb::InlineSkipList<rocksdb::TestComparator>::Node*> [1]’ [-Werror=array-bounds]
  302 |     return (next_[-n].load(std::memory_order_acquire));
      |                                                      ^

数组越界。但其实node是个指针,使用[]操作。
使用-Wno-error=array-bounds屏蔽报错。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant