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.45k stars 6.3k forks source link

Cant build librocksdb.a for iOS platform in M1 #8416

Open chuckern opened 3 years ago

chuckern commented 3 years ago

As the title says. Here is the code I use TARGET_OS=IOS DEBUG_LEVEL=0 make static_lib

And here is the message :

$DEBUG_LEVEL is 0
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.
mkdir -p ios-x86/cache/
g++  -march=armv8-a+crc+crypto -fno-rtti -W -Wextra -Wall -Wsign-compare -Wshadow -Wunused-parameter -Werror -I. -I./include -std=c++11  -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX  -DOS_MACOSX -DIOS_CROSS_COMPILE -DROCKSDB_LITE -Wshorten-64-to-32 -DHAVE_UINT128_EXTENSION  -isystem third-party/gtest-1.8.1/fused-src -O2 -fno-omit-frame-pointer -momit-leaf-frame-pointer -DNDEBUG -DNDEBUG -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk -arch i686 -arch x86_64 -c cache/cache.cc -o ios-x86/cache/cache.o
error: unknown target CPU 'armv8-a+crc+crypto'
note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, icelake-server, tigerlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64
make: *** [cache/cache.o] Error 1

And my computer message: OS: 11.3.1 CPU: M1

The Branch I use: Master (ecccc6317)

jurmous commented 3 years ago

It works for me with the following flags:

Screenshot 2021-06-19 at 14 11 04

You can see it warns for some flags in the errors.

chuckern commented 3 years ago

It works for me with the following flags:

Screenshot 2021-06-19 at 14 11 04

You can see it warns for some flags in the errors.

Thanks for reply. One question is which project u set these flags? I cant find a ios project is rocksdb-master file.

jurmous commented 3 years ago

I use this project and this branch: https://github.com/marykdb/ObjectiveRocks/tree/redo It includes an Xcode project to use RocksDB as a library with an Objective C/Swift interface.

chuckern commented 3 years ago

@jurmous Sorry but i still not very clear. First I want get the new .a file to fix old librocksdb.a bug in M1( for rosetta2 trans x86_64 to arm64 have a auto_roll_logger.cc error) so i try to build a new librocksdb.a in master branch and get the error ahead. after before discussion i still dont know:

  1. in which project should i do the make order (this project or the project u provide)
  2. if in this project(i guess), how i can fix the error at the first.
  3. where i should set the flag NPERF_CONTEXT, NDEBUG in this project.
chuckern commented 3 years ago

run make check first then run TARGET_OS=IOS make static_lib can get the librocksdb.a but run lipo -info find this file only have arm64. I guess this is because my mac is m1 cpu, so i will check if use Intel cpu mac can get the librocksdb.a include both x64_64 and arm64

cailianqing commented 2 years ago

run make check first then run TARGET_OS=IOS make static_lib can get the librocksdb.a but run lipo -info find this file only have arm64. I guess this is because my mac is m1 cpu, so i will check if use Intel cpu mac can get the librocksdb.a include both x64_64 and arm64

i have the same question ! have u resolved the problem?