facebook / rocksdb

A library that provides an embeddable, persistent key-value store for fast storage.
http://rocksdb.org
GNU General Public License v2.0
28.33k stars 6.29k forks source link

USE_SSE=1 will fail to compile #3782

Open absolute8511 opened 6 years ago

absolute8511 commented 6 years ago

after the commit 76698fe15e9cae718a3bc090f430a98e812ff758 , it will failed to compile with USE_SSE=1 make static_lib. Although make static_lib will be OK. Is it expected?

gcc, g++ version

gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
g++ (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)

on Linux

2.6.32-696.el6.x86_64 #1 SMP  x86_64 x86_64 x86_64 GNU/Linux

error message:

In file included from /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/unordered_map:35:0,
                 from ./include/rocksdb/db.h:17,
                 from ./db/dbformat.h:15,
                 from ./utilities/column_aware_encoding_util.h:10,
                 from utilities/column_aware_encoding_util.cc:8:
/opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
In file included from /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/chrono:35:0,
                 from ./utilities/cassandra/format.h:58,
                 from utilities/cassandra/test_utils.h:9,
                 from utilities/cassandra/test_utils.cc:6:
/opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
In file included from /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/atomic:38:0,
                 from ./table/mock_table.h:8,
                 from table/mock_table.cc:6:
/opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
In file included from /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/chrono:35:0,
                 from ./utilities/cassandra/format.h:58,
                 from utilities/cassandra/cassandra_row_merge_test.cc:8:
anand1976 commented 6 years ago

@ajkr do you mind taking a look?

anand1976 commented 6 years ago

@absolute8511 Can you check if the -std=c++11 option is set in make_config.mk? I believe we do enable that option. If that's not working, maybe upgrade to gcc 5.x.

absolute8511 commented 6 years ago

@anand1976 I noticed the content of make_config.mk is empty while using USE_SSE=1

anand1976 commented 6 years ago

Oh, that's not good. It works fine for me locally. The makefile uses build_tools/build_detect_platform to generate the make_config.mk. You can instrument Makefile to catch any errors and log it to see what's going wrong.

absolute8511 commented 6 years ago

I run the tool and got warning:

$ USE_SSE=1 build_tools/build_detect_platform ./make_config.mk
warning: USE_SSE specified but compiler could not use PCLMUL intrinsics, disabling
ajkr commented 6 years ago

Oh, we repurposed that flag to also cover -mpclmul under the (apparently wrong) assumption that our fast crc32c users' platforms would support it. We should do two followups:

  1. Introduce USE_PCLMUL flag that separately enforces -mpclmul is available.
  2. In the logs, distinguish between fast crc32c algorithm with and without pclmul.

By the way, in the meantime you don't actually need to set USE_SSE=1 if your machine supports it -- we already auto-detect SSE4.2 support, and that flag just causes compilation to fail if SSE4.2 is unsupported (well, it also causes compile failure when pclmul is unsupported, regrettably). You can look for "Fast CRC32 supported: " in the logs to verify we're using an SSE4.2-based algorithm even when you don't provide USE_SSE=1.

absolute8511 commented 6 years ago

Yeah, I noticed the fast crc32 is already supported. I think introduce USE_PCLMUL flag is good to solve this.