Open jahead opened 1 month ago
On react native 0.74.3
With release mode we get
Execution failed for task ':react-native-leveldb:buildCMakeRelWithDebInfo[arm64-v8a]'. > com.android.ide.common.process.ProcessException: ninja: Entering directory `/Users/jahead/projects/bcs/BcsInspectionsMobileApp/node_modules/react-native-leveldb/android/.cxx/RelWithDebInfo/306y1138/arm64-v8a' [1/4] Building CXX object leveldb/CMakeFiles/leveldb.dir/util/cache.cc.o FAILED: leveldb/CMakeFiles/leveldb.dir/util/cache.cc.o /Users/jahead/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android23 --sysroot=/Users/jahead/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -DLEVELDB_COMPILE_LIBRARY -DLEVELDB_PLATFORM_POSIX=1 -I/Users/jahead/projects/bcs/BcsInspectionsMobileApp/node_modules/react-native-leveldb/android/.cxx/RelWithDebInfo/306y1138/arm64-v8a/leveldb/include -I/Users/jahead/projects/bcs/BcsInspectionsMobileApp/node_modules/react-native-leveldb/cpp/leveldb/. -I/Users/jahead/projects/bcs/BcsInspectionsMobileApp/node_modules/react-native-leveldb/cpp/leveldb/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -O2 -Wall -Wno-unused-variable -fstack-protector-all -fno-exceptions -fno-rtti -O2 -g -DNDEBUG -fPIC -Werror -Wthread-safety -pthread -std=c++11 -MD -MT leveldb/CMakeFiles/leveldb.dir/util/cache.cc.o -MF leveldb/CMakeFiles/leveldb.dir/util/cache.cc.o.d -o leveldb/CMakeFiles/leveldb.dir/util/cache.cc.o -c /Users/jahead/projects/bcs/BcsInspectionsMobileApp/node_modules/react-native-leveldb/cpp/leveldb/util/cache.cc /Users/jahead/projects/bcs/BcsInspectionsMobileApp/node_modules/react-native-leveldb/cpp/leveldb/util/cache.cc:130:14: error: variable 'count' set but not used [-Werror,-Wunused-but-set-variable] uint32_t count = 0; ^ 1 error generated. ninja: build stopped: subcommand failed.
From looking at the build this is likely from react-native-leveldb/cpp/leveldb/util/cache.cc:130:14
react-native-leveldb/cpp/leveldb/util/cache.cc:130:14
uint32_t count = 0; for (uint32_t i = 0; i < length_; i++) { LRUHandle* h = list_[i]; while (h != nullptr) { LRUHandle* next = h->next_hash; uint32_t hash = h->hash; LRUHandle** ptr = &new_list[hash & (new_length - 1)]; h->next_hash = *ptr; *ptr = h; h = next; count++; } } assert(elems_ == count);
likely assert(elems_ == count); is being optimised out in release and therefore not being used. So in debug it complies fine, but release not.
assert(elems_ == count);
The cppFlags are being controlled in build.gradle
build.gradle
externalNativeBuild { cmake { cppFlags '-O2 -frtti -fexceptions -Wall -Wno-unused-variable -fstack-protector-all' arguments '-DANDROID_STL=c++_shared' abiFilters(*reactNativeArchitectures()) } }
the -Wall and -Wno-unused-variable are the cause removing those two flags restores building in release
-Wall
-Wno-unused-variable
I'm not sure why it only just started breaking in 0.74.3
Just hit this. Thanks OP for providing a patch.
On react native 0.74.3
With release mode we get
From looking at the build this is likely from
react-native-leveldb/cpp/leveldb/util/cache.cc:130:14
likely
assert(elems_ == count);
is being optimised out in release and therefore not being used. So in debug it complies fine, but release not.The cppFlags are being controlled in
build.gradle
the
-Wall
and-Wno-unused-variable
are the cause removing those two flags restores building in releaseI'm not sure why it only just started breaking in 0.74.3