skip to Main Content

I’ve been trying to compile the rocksdb platform for iOS for a while now.
The simple git clone the repo and run

TARGET_OS="IOS" make static_lib -j8

fails with a spew of errors, and I’m not sure where I can also add the preprocessor directives.

I have then been looking at wrappers, and trying to compile them for a later version:

  1. https://github.com/koraykoska/rocksdb.swift : This uses a rocksdb version of 6.4.7, and uses CocoaPods to compile the rocksdb library and the swift wrapper. I have tried cloning the rocksdb repo into the upstream folder, and then use this ‘rocksdb.swift’ pod in an Xcode Project.
    Here are the changes I made in the pod spec(v6.22.1 being the one I need to compile.)
(librocksdb.podspec)

  s.name             = 'librocksdb'
  s.version          = '***6.22.1***'
  s.summary          = 'rocksdb bindings for Swift. Cocoapods and SPM support. Linux support.'
(rocksdb.swift.podspec)

  s.name             = 'rocksdb.swift'
  s.version          = '***6.22.1***'
  s.summary          = 'rocksdb Wrapper for Swift. Cocoapods and SPM support. Linux support.'
  ...
  s.dependency 'librocksdb', '~> ***6.22.1***'
  ...

The pod install now fails as it cannot find the ‘new’ version of librocksdb so I add both librocksdb and rocksdb.swift to my Podfile with the :path => format.
The pod then installs, and the Xcode project has this error

/.../librdb/librocksdb/rocksdb/memtable/write_buffer_manager.cc:10:10: 'rocksdb/write_buffer_manager.h' file not found
  1. https://github.com/hlzhang/rocksdb-build : Along similar lines to the previous wrapper, I tried changing the versions and then compiling. This meant some changes in common.sh and build-rocksdb-ios.sh scripts. Fails with
monitoring/perf_context.cc:23:2: error: "No thread-local support. Disable perf context with -DNPERF_CONTEXT."
#error "No thread-local support. Disable perf context with -DNPERF_CONTEXT."
 ^
1 error generated.
monitoring/iostats_context.cc:19:2: error: "No thread-local support. Disable iostats context with -DNIOSTATS_CONTEXT."
#error 
 ^
1 error generated.
$DEBUG_LEVEL is 0
monitoring/iostats_context.cc:19:2: error: "No thread-local support. Disable iostats context with -DNIOSTATS_CONTEXT."
#error 
 ^
monitoring/perf_context.cc:23:2: error: "No thread-local support. Disable perf context with -DNPERF_CONTEXT."
#error "No thread-local support. Disable perf context with -DNPERF_CONTEXT."
 ^
1 error generated.
1 error generated.
In file included from cache/sharded_cache.cc:16:
In file included from ./util/hash.h:26:
./util/fastrange.h:60:5: error: unknown type name '__uint128_t'
    __uint128_t wide = __uint128_t{range} * hash;
    ^
./util/fastrange.h:60:24: error: use of undeclared identifier '__uint128_t'
    __uint128_t wide = __uint128_t{range} * hash;
                       ^
./util/fastrange.h:60:35: error: expected ';' at end of declaration
    __uint128_t wide = __uint128_t{range} * hash;
                                  ^
                                  ;
./util/fastrange.h:53:35: error: unused parameter 'hash' [-Werror,-Wunused-parameter]
  static inline Range Fn(uint64_t hash, Range range) {
                                  ^
./util/fastrange.h:53:47: error: unused parameter 'range' [-Werror,-Wunused-parameter]
  static inline Range Fn(uint64_t hash, Range range) {
                                              ^
5 errors generated.

I try adding the relevant flags to the CFLAGS variable, and also add the -std=c++17 flag to attempt to resolve the uint__128 issue.
This then fails with

./cache/lru_cache.h:269:11: error: aligned deallocation function of type 'void (void *, std::align_val_t) noexcept' is only available on iOS 11 or newer
  virtual ~LRUCacheShard() override = default;
          ^
cache/lru_cache.cc:656:18: note: in defaulted destructor for 'rocksdb::LRUCacheShard' first required here
      shards_[i].~LRUCacheShard();
                 ^
./cache/lru_cache.h:269:11: note: if you supply your own aligned allocation functions, use -faligned-allocation to silence this diagnostic
  virtual ~LRUCacheShard() override = default;
          ^
1 error generated.

This is not resolved using by changing the IOS_SDK_VERSION to a newer version in the build-rockdb-ios.sh script.

I was hence looking for someone who has compiled a recent version of rocksdb/a wrapper of rocksdb for iOS and am looking for guidance.

TIA

2

Answers


  1. Try RocksDB 6.x version, from 7.0 RocksDB need C++17。

    Dropping some compiler support in 7.0#9388

    Login or Signup to reply.
  2. #Xcode Version 13.2.1 (13C100)
     
    $ brew install git
     
    $ brew install cmake
     
    $ git clone https://github.com/facebook/rocksdb.git
     
    $ git checkout v6.29.5
     
    $ export PORTABLE=1
     
    $ export TARGET_OS=IOS
     
    $ export ROCKSDB_LITE=1
     
    $ export IOS_CROSS_COMPILE=1
     
    #disable int128
    
    $ export TEST_UINT128_COMPAT=1
     
    $ export DISABLE_WARNING_AS_ERROR=1
     
    $ export DEBUG_LEVEL=0 
     
    $ export EXTRA_CXXFLAGS="-DNPERF_CONTEXT -DNIOSTATS_CONTEXT"
     
    $ make V=1 VERBOSE=1 -j16 static_lib
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search