clang8.0及以上编译rocks问题
阅读原文时间:2023年07月09日阅读:2

升级了MacOS 10.15 Beta版,结果编译 CockroachDB 遇到了问题。

[ %] Building CXX object CMakeFiles/rocksdb.dir/db/builder.cc.o
[ %] Building CXX object CMakeFiles/rocksdb.dir/db/column_family.cc.o
[ %] Building CXX object CMakeFiles/rocksdb.dir/db/compacted_db_impl.cc.o
[ %] Building CXX object CMakeFiles/rocksdb.dir/db/compaction.cc.o
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/column_family.cc::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WAL_FILE_BYTES,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
WAL_FILE_BYTES, // Number of bytes written to WAL
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/column_family.cc::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WAL_FILE_SYNCED,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
WAL_FILE_SYNCED, // Number of times WAL sync is done
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/column_family.cc::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
BYTES_WRITTEN,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
BYTES_WRITTEN,
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/column_family.cc::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
NUMBER_KEYS_WRITTEN,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
NUMBER_KEYS_WRITTEN,
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/column_family.cc::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WRITE_DONE_BY_OTHER,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
WRITE_DONE_BY_OTHER, // Equivalent to writes done for others
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/column_family.cc::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WRITE_DONE_BY_SELF,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
WRITE_DONE_BY_SELF,
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/column_family.cc::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WRITE_WITH_WAL,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
WRITE_WITH_WAL, // Number of Write calls that request WAL
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.cc::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WAL_FILE_BYTES,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
WAL_FILE_BYTES, // Number of bytes written to WAL
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.cc::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WAL_FILE_SYNCED,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
WAL_FILE_SYNCED, // Number of times WAL sync is done
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.cc::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
BYTES_WRITTEN,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
BYTES_WRITTEN,
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.cc::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
NUMBER_KEYS_WRITTEN,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
NUMBER_KEYS_WRITTEN,
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.cc::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WRITE_DONE_BY_OTHER,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
WRITE_DONE_BY_OTHER, // Equivalent to writes done for others
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.cc::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WRITE_DONE_BY_SELF,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
WRITE_DONE_BY_SELF,
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.cc::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h::
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WRITE_WITH_WAL,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
WRITE_WITH_WAL, // Number of Write calls that request WAL
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/builder.cc::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WAL_FILE_BYTES,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
WAL_FILE_BYTES, // Number of bytes written to WAL
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/builder.cc::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WAL_FILE_SYNCED,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
WAL_FILE_SYNCED, // Number of times WAL sync is done
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/builder.cc::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
BYTES_WRITTEN,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
BYTES_WRITTEN,
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/builder.cc::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
NUMBER_KEYS_WRITTEN,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
NUMBER_KEYS_WRITTEN,
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/builder.cc::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WRITE_DONE_BY_OTHER,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
WRITE_DONE_BY_OTHER, // Equivalent to writes done for others
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/builder.cc::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WRITE_DONE_BY_SELF,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
WRITE_DONE_BY_SELF,
^
In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/builder.cc::
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h::: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WRITE_WITH_WAL,
^
/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h::: note: previous declaration is here
WRITE_WITH_WAL, // Number of Write calls that request WAL
^
errors generated.
gmake[]: *** [CMakeFiles/rocksdb.dir/build.make:: CMakeFiles/rocksdb.dir/db/builder.cc.o] Error
gmake[]: *** Waiting for unfinished jobs….
errors generated.
gmake[]: *** [CMakeFiles/rocksdb.dir/build.make:: CMakeFiles/rocksdb.dir/db/compacted_db_impl.cc.o] Error
errors generated.
gmake[]: *** [CMakeFiles/rocksdb.dir/build.make:: CMakeFiles/rocksdb.dir/db/column_family.cc.o] Error
gmake[]: *** [CMakeFiles/Makefile2:: CMakeFiles/rocksdb.dir/all] Error
gmake[]: *** [CMakeFiles/Makefile2:: CMakeFiles/rocksdb.dir/rule] Error
gmake[]: *** [Makefile:: rocksdb] Error
gmake[]: *** [Makefile:: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/native/x86_64-unknown-freebsd12./rocksdb/librocksdb.a] Error
gmake[]: Leaving directory '/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach'
gmake: *** [Makefile:: buildoss] Error
gmake: Leaving directory '/usr/ports/databases/cockroach/work/cockroach-v19.1.1'
*** Error code

Stop.
make: stopped in /usr/ports/databases/cockroach

MacOS 使用的 C 语言编译器是 llvm 下的 clang,所有的 gcc 的使用都会被链接到 clang 的使用上。

比如检查 gcc 版本

$ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.
Apple clang version 11.0. (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

显示的就是 clang 的版本了。目前我的机器上的 clang 是 11.0.0

出现上面问题的原因是 clang 在8.0版本后对于代码的要求更为严格,有一种特殊的情况被判定为错误,无法正常编译。

报错信息中的 shadow 指的是函数内定义了和传入参数同名的变量,这就是 clang 拒绝的情况。

仔细看报错信息,可以看到这些错误都发生在 rocksdb 文件夹下。到目前为止,rocksdb 都没有要改一下代码的意思,因为又不是不能用。

编译的时候可以加上标签 -Wno-error= 让包含特定信息的错误强行不报错。

更改 /rocksdb/CMakeLists.txt 文件,diff 形式(如果是 CockroachDB 的工程,该文件在 /cockroach/c-deps/ 文件夹下):

option(FAIL_ON_WARNINGS "Treat compile warnings as errors" ON)
if(FAIL_ON_WARNINGS)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
else() # assume GCC

  • set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
  • set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error")
    endif()
    endif()

修改 /rocksdb/Makefile 文件:

ifndef DISABLE_WARNING_AS_ERROR

  • WARNING_FLAGS += -Werror
  • WARNING_FLAGS += # -Werror
    endif

参考:

Problems building on FreeBSD (with clang 8)

gcc警告选项汇总

build: compile RocksDB with -Wno-error-shadow

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章