Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android cross-compilation issue #3

Open
therealjmj opened this issue Jun 30, 2022 · 9 comments
Open

Android cross-compilation issue #3

therealjmj opened this issue Jun 30, 2022 · 9 comments

Comments

@therealjmj
Copy link

therealjmj commented Jun 30, 2022

After successful building for months, we are hitting a new cross-compilation build error on multiple machines, while building leveldown-nodejs-mobile (and leveldown) as a native module across all Android architectures.

...
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: Release/obj.target/leveldb/deps/leveldb/leveldb-1.20/util/options.o is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: Release/obj.target/leveldb/deps/leveldb/leveldb-1.20/util/status.o is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: Release/obj.target/leveldb/deps/leveldb/leveldb-1.20/port/port_posix.o is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: Release/obj.target/leveldb/deps/leveldb/leveldb-1.20/util/env_posix.o is not an object file (not allowed in a library)
make: *** [Release/leveldb.a] Error 1

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/<HOME>/.nvm/versions/node/v16.15.1/lib/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Darwin 21.5.0
gyp ERR! command "/Users/<HOME>/.nvm/versions/node/v16.15.1/bin/node" "/Users/johnnym/.nvm/versions/node/v16.15.1/bin/node-gyp" "rebuild" "--build-from-source" "--verbose"
gyp ERR! cwd /Users/<PROJ>/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-armeabi-v7a/nodejs-project/node_modules/leveldown
gyp ERR! node -v v16.15.1
gyp ERR! node-gyp -v v9.0.0

Wondering if anyone has seen this, or has any ideas for debugging?

@therealjmj
Copy link
Author

therealjmj commented Jun 30, 2022

These above "not an object file" errors follow a variety of these build warnings:

~/Library/Android/sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi24-clang++ -o Release/obj.target/leveldb/deps/leveldb/leveldb-1.20/util/env_posix.o ../deps/leveldb/leveldb-1.20/util/env_posix.cc '-DNODE_GYP_MODULE_NAME=leveldb' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_THREADS' '-DOPENSSL_NO_ASM' '-DSNAPPY=1' '-DLEVELDB_PLATFORM_POSIX=1' '-DOS_ANDROID=1' '-D_REENTRANT=1' '-D_GLIBCXX_USE_C99_MATH' -I/Users/johnnym/railway-private/node_modules/nodejs-mobile-react-native/android/libnode/include/node -I/Users/johnnym/railway-private/node_modules/nodejs-mobile-react-native/android/libnode/src -I/Users/johnnym/railway-private/node_modules/nodejs-mobile-react-native/android/libnode/deps/openssl/config -I/Users/johnnym/railway-private/node_modules/nodejs-mobile-react-native/android/libnode/deps/openssl/openssl/include -I/Users/johnnym/railway-private/node_modules/nodejs-mobile-react-native/android/libnode/deps/uv/include -I/Users/johnnym/railway-private/node_modules/nodejs-mobile-react-native/android/libnode/deps/zlib -I/Users/johnnym/railway-private/node_modules/nodejs-mobile-react-native/android/libnode/deps/v8/include -I../deps/leveldb/leveldb-1.20 -I../deps/leveldb/leveldb-1.20/include -I../deps/snappy/linux -I../deps/snappy/snappy  -fasm-blocks -mpascal-strings -O3 -gdwarf-2 -arch x86_64  -MMD -MF ./Release/.deps/Release/obj.target/leveldb/deps/leveldb/leveldb-1.20/util/env_posix.o.d.raw   -c
clang++: warning: argument unused during compilation: '-arch x86_64' [-Wunused-command-line-argument]

@staltz
Copy link
Owner

staltz commented Jul 1, 2022

Probably related to updating Xcode and/or macOS

@therealjmj
Copy link
Author

Interesting. Would you suggest using an earlier version of Xcode CLI tools?

@therealjmj
Copy link
Author

Tried with clang 13.0.0 (Xcode 13) to no avail.
I wonder if it's MacOS Monterey that's causing the problem... Although I recall upgrading to Monterey when it became available in Oct 2021, and was able to build leveldown for all android architectures at the time.

@therealjmj
Copy link
Author

therealjmj commented Jul 1, 2022

What is strange is that I can node-gyp rebuild leveldown just fine by itself: no warnings/errors and leveldown.node is created successfully.

However within the Android native-module build stage, it fails.

I created a shell script to rebuild leveldown for armeabi-v7a, as occurs within the Android native build process... So it's very easy to run by itself and hit this failure (takes only 15 seconds):

#!/bin/bash

#
# SETUP:
# 1. Kick off a full Android build to fill the ./android/build directory: `./tools/build-nodejs.js --android`
# 2. Set PATH=~/<PROJ>/node_modules/nodejs-mobile-react-native/node_modules/.bin:$PATH
#

cd ~/<PROJ>/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-armeabi-v7a/nodejs-project/node_modules/leveldown;
ndk_bundle_path="~/Library/Android/sdk/ndk/24.0.8215888"
projectDir="~/<PROJ>/node_modules/nodejs-mobile-react-native/android"
temp_host_tag="darwin-x86_64"
temp_binutils_prefix="arm-linux-androideabi"
temp_compiler_prefix="armv7a-linux-androideabi24"
cargo_build_target='arm-linux-androideabi'
toolchain_path="${ndk_bundle_path}/toolchains/llvm/prebuilt/${temp_host_tag}"
npm_toolchain_ar="${toolchain_path}/bin/${temp_binutils_prefix}-ar"
npm_toolchain_cc="${toolchain_path}/bin/${temp_compiler_prefix}-clang"
npm_toolchain_cxx="${toolchain_path}/bin/${temp_compiler_prefix}-clang++"
npm_toolchain_link="${toolchain_path}/bin/${temp_compiler_prefix}-clang++"
npm_gyp_defines="target_arch=arm v8_target_arch=arm android_target_arch=arm host_os=mac OS=android";
npm_config_node_engine="v8" \
npm_config_nodedir="${projectDir}/libnode" \
npm_config_node_gyp="${projectDir}/../node_modules/nodejs-mobile-gyp/bin/node-gyp.js" \
npm_config_arch="arm" \
npm_config_platform="android" \
npm_config_format="make-android" \
CARGO_BUILD_TARGET="${cargo_build_target}" \
CARGO_TARGET_ARM_LINUX_ANDROIDEABI_AR="${npm_toolchain_ar}" \
CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER="${npm_toolchain_link}" \
TOOLCHAIN="${toolchain_path}" \
AR="${npm_toolchain_ar}" \
CC="${npm_toolchain_cc}" \
CXX="${npm_toolchain_cxx}" \
LINK="${npm_toolchain_link}" \
GYP_DEFINES="${npm_gyp_defines}" \
node-gyp rebuild --build-from-source --verbose;

@staltz
Copy link
Owner

staltz commented Jul 1, 2022

When you run node-gyp rebuild it is not compiling for Android, is compiling for macOS, that's why it worked.

@therealjmj
Copy link
Author

Hi @staltz, we are still having trouble with this Android native module build, a month later. :(

Have you had success compiling leveldown from a Mac recently?
We can compile from Linux but our frontend devs all use Mac.

@staltz
Copy link
Owner

staltz commented Aug 8, 2022

@jrmeurer Okay, let's start over:

Please provide some version information, such as

  • sdkmanager --list
  • react-native info
  • Version of nodejs-mobile and/or nodejs-mobile-react-native
  • Version of leveldown-nodejs-mobile
  • Link to your repository, only if it's a public one

For example, for me they show

Installed packages:=====================] 100% Computing updates...             
  Path                        | Version      | Description                     | Location                    
  -------                     | -------      | -------                         | -------                     
  build-tools;23.0.1          | 23.0.1       | Android SDK Build-Tools 23.0.1  | build-tools/23.0.1/         
  build-tools;28.0.3          | 28.0.3       | Android SDK Build-Tools 28.0.3  | build-tools/28.0.3/         
  build-tools;29.0.2          | 29.0.2       | Android SDK Build-Tools 29.0.2  | build-tools/29.0.2/         
  build-tools;29.0.3          | 29.0.3       | Android SDK Build-Tools 29.0.3  | build-tools/29.0.3/         
  build-tools;30.0.2          | 30.0.2       | Android SDK Build-Tools 30.0.2  | build-tools/30.0.2/         
  build-tools;30.0.3          | 30.0.3       | Android SDK Build-Tools 30.0.3  | build-tools/30.0.3/         
  build-tools;31.0.0          | 31.0.0       | Android SDK Build-Tools 31      | build-tools/31.0.0/         
  cmake;3.10.2.4988404        | 3.10.2       | CMake 3.10.2.4988404            | cmake/3.10.2.4988404/       
  cmake;3.6.4111459           | 3.6.4111459  | CMake 3.6.4111459               | cmake/3.6.4111459/          
  emulator                    | 30.8.4       | Android Emulator                | emulator/                   
  extras;android;m2repository | 47.0.0       | Android Support Repository      | extras/android/m2repository/
  ndk;16.1.4479499            | 16.1.4479499 | NDK (Side by side) 16.1.4479499 | ndk/16.1.4479499/           
  ndk;17.2.4988734            | 17.2.4988734 | NDK (Side by side) 17.2.4988734 | ndk/17.2.4988734/           
  ndk;18.1.5063045            | 18.1.5063045 | NDK (Side by side) 18.1.5063045 | ndk/18.1.5063045/           
  ndk;19.2.5345600            | 19.2.5345600 | NDK (Side by side) 19.2.5345600 | ndk/19.2.5345600/           
  ndk;20.1.5948944            | 20.1.5948944 | NDK (Side by side) 20.1.5948944 | ndk/20.1.5948944/           
  ndk;21.3.6528147            | 21.3.6528147 | NDK (Side by side) 21.3.6528147 | ndk/21.3.6528147/           
  ndk;21.4.7075529            | 21.4.7075529 | NDK (Side by side) 21.4.7075529 | ndk/21.4.7075529/           
  patcher;v4                  | 1            | SDK Patch Applier v4            | patcher/v4/                 
  platform-tools              | 31.0.3       | Android SDK Platform-Tools      | platform-tools/             
  platforms;android-21        | 2            | Android SDK Platform 21         | platforms/android-21/       
  platforms;android-22        | 2            | Android SDK Platform 22         | platforms/android-22/       
  platforms;android-23        | 3            | Android SDK Platform 23         | platforms/android-23/       
  platforms;android-24        | 2            | Android SDK Platform 24         | platforms/android-24/       
  platforms;android-25        | 3            | Android SDK Platform 25         | platforms/android-25/       
  platforms;android-26        | 2            | Android SDK Platform 26         | platforms/android-26/       
  platforms;android-27        | 3            | Android SDK Platform 27         | platforms/android-27/       
  platforms;android-28        | 6            | Android SDK Platform 28         | platforms/android-28/       
  platforms;android-29        | 5            | Android SDK Platform 29         | platforms/android-29/       
  platforms;android-30        | 3            | Android SDK Platform 30         | platforms/android-30/       
  sources;android-21          | 1            | Sources for Android 21          | sources/android-21/         
  sources;android-22          | 1            | Sources for Android 22          | sources/android-22/         
  sources;android-23          | 1            | Sources for Android 23          | sources/android-23/         
  sources;android-24          | 1            | Sources for Android 24          | sources/android-24/         
  sources;android-25          | 1            | Sources for Android 25          | sources/android-25/         
  sources;android-26          | 1            | Sources for Android 26          | sources/android-26/         
  sources;android-27          | 1            | Sources for Android 27          | sources/android-27/         
  sources;android-28          | 1            | Sources for Android 28          | sources/android-28/         
  sources;android-29          | 1            | Sources for Android 29          | sources/android-29/ 

and

System:
    OS: Linux 5.13 elementary OS 6.1 Jólnir
    CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
    Memory: 352.45 MB / 15.40 GB
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 12.19.1 - ~/.nvm/versions/node/v12.19.1/bin/node
    Yarn: 1.22.15 - ~/.nvm/versions/node/v12.19.1/bin/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v12.19.1/bin/npm
    Watchman: 4.9.0 - /usr/bin/watchman
  SDKs:
    Android SDK:
      API Levels: 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
      Build Tools: 23.0.1, 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0
      Android NDK: 20.1.5948944
  IDEs:
    Android Studio: Not Found
  Languages:
    Java: 11.0.16 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: ~6.4.0 => 6.4.0 
    react: 17.0.2 => 17.0.2 
    react-native: 0.66.4 => 0.66.4 
  npmGlobalPackages:
    *react-native*: Not Found

@staltz
Copy link
Owner

staltz commented Aug 8, 2022

I managed to compile leveldown-nodejs-mobile for Android on my macOS, so this indicates your issue is probably a problem of configuration or incompatible versions of some software.

react-native info

System:
    OS: macOS 11.6.5
    CPU: (4) x64 Intel(R) Core(TM) i7-4558U CPU @ 2.80GHz
    Memory: 665.27 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 12.22.10 - ~/.nvm/versions/node/v12.22.10/bin/node
    Yarn: 1.22.15 - ~/.nvm/versions/node/v12.22.10/bin/yarn
    npm: 6.14.16 - ~/.nvm/versions/node/v12.22.10/bin/npm
    Watchman: 4.7.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.0 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
    Android SDK:
      API Levels: 19, 26, 27, 28, 29, 30
      Build Tools: 28.0.3, 29.0.2, 30.0.3, 31.0.0
      System Images: android-19 | ARM EABI v7a, android-26 | Google APIs Intel x86 Atom
      Android NDK: 21.0.6113669
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_222 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: ~6.4.0 => 6.4.0 
    react: 17.0.2 => 17.0.2 
    react-native: 0.66.4 => 0.66.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

nodejs-mobile

0.3.3

leveldown-nodejs-mobile

5.4.1-1

Repo

https://github.com/staltz/manyverse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants