facebook / facebook/rocksdb

pkg-config file causes build errors

Open
#8,286 2 comments 0 reactions 0 assignees View on GitHub
enhancement up-for-grabs
Dominant language
C++
Stars
32.1k
Forks
6.9k
Avg merge
32m
Merged PRs (30d)
1

Description

The pkg-config file that recently started being generated by RocksDB contains flags that make it hard to use on different systems/compilers/etc.

### Expected behavior

The pkg-config file should work on all systems as well as with C and C++.

### Actual behavior

Trying to use RocksDB in a C application results in errors like this:
```
cc1: error: command-line option '-std=c++11' is valid for C++/ObjC++ but not for C [-Werror]
cc1: error: command-line option '-faligned-new=1' is valid for C++/ObjC++ but not for C [-Werror]
cc1: error: third-party/gtest-1.8.1/fused-src: No such file or directory [-Werror=missing-include-dirs]
cc1: error: ./third-party/folly: No such file or directory [-Werror=missing-include-dirs]
```

Clang also does not know about some of the flags:
```
error: unknown warning option '-Werror=deprecated-copy'; did you mean '-Werror=deprecated'? [-Werror,-Wunknown-warning-option]
error: invalid argument '-std=c++11' not allowed with 'C'
```

The generated one causing problems looks something like this:
```
prefix=$SPACK/opt/spack/linux-fedora34-zen2/gcc-11.1.1/rocksdb-6.19.3-dd5zq7iizz54mqxivkpm74mvbbuhxmbn
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=$SPACK/opt/spack/linux-fedora34-zen2/gcc-11.1.1/rocksdb-6.19.3-dd5zq7iizz54mqxivkpm74mvbbuhxmbn/lib

Name: rocksdb
Description: An embeddable persistent key-value store for fast storage
Version: 6.19.3
Libs: -L${libdir} -ldl -Wl,-rpath -Wl, -lrocksdb
Libs.private: -lpthread -lrt -ldl -lgflags -lz -llz4
Cflags: -I${includedir} -std=c++11 -faligned-new -DHAVE_ALIGNED_NEW -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -Wno-error=deprecated-copy -Wno-error=pessimizing-move -Wno-error=redundant-move -I$SPACK/opt/spack/linux-fedora34-zen2/gcc-11.1.1/zlib-1.2.11-4ymlsgm3l63qbi5tliaeop2xpppaci2b/include -I$SPACK/opt/spack/linux-fedora34-zen2/gcc-11.1.1/lz4-1.9.3-bpkgu6gpnzshfjdbc2qvd2f5m6aisqas/include -I$SPACK/opt/spack/linux-fedora34-zen2/gcc-11.1.1/gflags-2.2.2-gy6ezqt56zhofysz2wmr4w47qi4cjqip/include -DOS_LINUX -fno-builtin-memcmp -DROCKSDB_FALLOCATE_PRESENT -DGFLAGS=1 -DZLIB -DLZ4 -DROCKSDB_MALLOC_USABLE_SIZE -DROCKSDB_PTHREAD_ADAPTIVE_MUTEX -DROCKSDB_BACKTRACE -DROCKSDB_RANGESYNC_PRESENT -DROCKSDB_SCHED_GETCPU_PRESENT -DROCKSDB_AUXV_GETAUXVAL_PRESENT -DHAVE_SSE42 -DHAVE_PCLMUL -DHAVE_AVX2 -DHAVE_BMI -DHAVE_LZCNT -DHAVE_UINT128_EXTENSION -DROCKSDB_SUPPORT_THREAD_LOCAL -isystem third-party/gtest-1.8.1/fused-src -isystem ./third-party/folly
```

A working one generated by Spack or Fedora looks like this:
```
prefix=$SPACK/opt/spack/linux-ubuntu18.04-westmere/gcc-9.3.0/rocksdb-6.11.4-rsjvyzatxw7pfy2aurjozt3jv54hovka
exec_prefix=${prefix}
libdir=$SPACK/opt/spack/linux-ubuntu18.04-westmere/gcc-9.3.0/rocksdb-6.11.4-rsjvyzatxw7pfy2aurjozt3jv54hovka/lib
includedir=$SPACK/opt/spack/linux-ubuntu18.04-westmere/gcc-9.3.0/rocksdb-6.11.4-rsjvyzatxw7pfy2aurjozt3jv54hovka/include

Name: rocksdb
Description: RocksDB: A Persistent Key-Value Store for Flash and RAM Storage
Version: 6.11.4
Cflags: -I${includedir}
Libs: -L${libdir} -lrocksdb -ldl
```

### Steps to reproduce the behavior

Try to use recent release of RocksDB from C and/or with Clang.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.