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

[Bug]: Some crate requires AR_<triple> environment to cross-compile #454

Closed
Kr328 opened this issue Nov 14, 2023 · 1 comment · Fixed by #456
Closed

[Bug]: Some crate requires AR_<triple> environment to cross-compile #454

Kr328 opened this issue Nov 14, 2023 · 1 comment · Fixed by #456
Assignees
Labels
bug Something isn't working

Comments

@Kr328
Copy link
Contributor

Kr328 commented Nov 14, 2023

Current Behavior

Corrosion already set CC_ environment for cargo build, but some crate like rusqlite-rs with feature bundled requires AR_<triple> or TARGET_AR to cross-compile.

Expected Behavior

Corrosion should set AR_<triple> or TARGET_AR with cmake variable CMAKE_AR.

Steps To Reproduce

reproduce-project.zip

  1. Download Android NDK from Github or Android Developer
  2. Generate build file with cmake -G "Unix Makefiles" -DCMAKE_MAKE_PROGRAM="\path\to\ndk\prebuilt\windows-x86_64\bin\make.exe" -DCMAKE_TOOLCHAIN_FILE="\path\to\ndk\build\cmake\android.toolchain.cmake" \path\to\reproduce-project
  3. Build project

Environment

- OS:Windows
- CMake: 3.27.7
- CMake Generator: Unix Makefiles

CMake configure log with Debug log-level

-- ANDROID_PLATFORM not set. Defaulting to minimum supported version
19.
-- The C compiler identification is Clang 14.0.7
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Users/kr328/AppData/Local/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Using Corrosion 0.4.4 with CMake 3.27.7 and the `Unix Makefiles` Generator
-- Rust Toolchain: stable-x86_64-pc-windows-msvc
-- Rust toolchain stable-x86_64-pc-windows-msvc
-- Rust toolchain path C:\Users\kr328\scoop\persist\rustup\.rustup\toolchains\stable-x86_64-pc-windows-msvc
-- Rust Target: armv7-linux-androideabi
-- Parsed Target triple: arch: armv7, vendor: , OS: linux, env: androideabi
-- Parsed Target triple: arch: x86_64, vendor: pc, OS: windows, env: msvc
-- Determining required link libraries for target armv7-linux-androideabi
-- Required static libs for target armv7-linux-androideabi: dl;log;unwind;dl;m;c
-- Determining required link libraries for target x86_64-pc-windows-msvc
-- Required static libs for host target x86_64-pc-windows-msvc: kernel32;advapi32;bcrypt;kernel32;ntdll;userenv;ws2_32;kernel32;ws2_32;kernel32;$<$<CONFIG:Debug>:msvcrtd>
-- Found Rust: C:/Users/kr328/scoop/persist/rustup/.rustup/toolchains/stable-x86_64-pc-windows-msvc/bin/rustc.exe (found version "1.73.0")
-- Cargo target armv7-linux-androideabi is an official target-triple
-- Installed targets: aarch64-linux-android;armv7-linux-androideabi;i686-linux-android;x86_64-linux-android;x86_64-pc-windows-msvc
-- Using Corrosion as a subdirectory
-- Found 1 targets in package rs
-- TARGET rs produces byproducts rs;
-- Corrosion created the following CMake targets: rs
-- Output directory property (target rs): RUNTIME_OUTPUT_DIRECTORY dir: output_directory-NOTFOUND
-- Setting IMPORTED_LOCATION for target rs to `D:/Workspace/untitled/build/rs`.
-- Adding command to copy byproducts `rs` to D:/Workspace/untitled/build/rs
-- Configuring done (7.2s)
-- Generating done (0.0s)
-- Build files have been written to: D:/Workspace/untitled/build

CMake Build step log

Change Dir: 'D:/Workspace/untitled/build'

Run Build Command(s): C:/Users/kr328/scoop/apps/cmake/3.27.7/bin/cmake.exe -E env VERBOSE=1 C:\Users\kr328\AppData\Local\Android\Sdk\ndk\25.2.9519653\prebuilt\windows-x86_64\bin\make.exe -f Makefile
C:/Users/kr328/scoop/apps/cmake/3.27.7/bin/cmake.exe -SD:/Workspace/untitled -BD:/Workspace/untitled/build --check-build-system CMakeFiles/Makefile.cmake 0
C:/Users/kr328/scoop/apps/cmake/3.27.7/bin/cmake.exe -E cmake_progress_start D:/Workspace/untitled/build/CMakeFiles D:/Workspace/untitled/build//CMakeFiles/progress.marks
C:/Users/kr328/AppData/Local/Android/Sdk/ndk/25.2.9519653/prebuilt/windows-x86_64/bin/make.exe  -f CMakeFiles/Makefile2 all
make[1]: Entering directory 'D:/Workspace/untitled/build'
C:/Users/kr328/AppData/Local/Android/Sdk/ndk/25.2.9519653/prebuilt/windows-x86_64/bin/make.exe  -f CMakeFiles/cargo-prebuild_rs.dir/build.make CMakeFiles/cargo-prebuild_rs.dir/depend
make[2]: Entering directory 'D:/Workspace/untitled/build'
C:/Users/kr328/scoop/apps/cmake/3.27.7/bin/cmake.exe -E cmake_depends "Unix Makefiles" D:/Workspace/untitled D:/Workspace/u
ntitled D:/Workspace/untitled/build D:/Workspace/untitled/build D:/Workspace/untitled/build/CMakeFiles/cargo-prebuild_rs.dir/DependInfo.cmake "--color="
make[2]: Leaving directory 'D:/Workspace/untitled/build'
C:/Users/kr328/AppData/Local/Android/Sdk/ndk/25.2.9519653/prebuilt/windows-x86_64/bin/make.exe  -f CMakeFiles/cargo-prebuild_rs.dir/build.make CMakeFiles/cargo-prebuild_rs.dir/build
make[2]: Entering directory 'D:/Workspace/untitled/build'
make[2]: Nothing to be done for 'CMakeFiles/cargo-prebuild_rs.dir/build'.
make[2]: Leaving directory 'D:/Workspace/untitled/build'
Built target cargo-prebuild_rs
C:/Users/kr328/AppData/Local/Android/Sdk/ndk/25.2.9519653/prebuilt/windows-x86_64/bin/make.exe  -f CMakeFiles/_cargo-build_rs.dir/build.make CMakeFiles/_cargo-build_rs.dir/depend
make[2]: Entering directory 'D:/Workspace/untitled/build'
C:/Users/kr328/scoop/apps/cmake/3.27.7/bin/cmake.exe -E cmake_depends "Unix Makefiles" D:/Workspace/untitled D:/Workspace/u
ntitled D:/Workspace/untitled/build D:/Workspace/untitled/build D:/Workspace/untitled/build/CMakeFiles/_cargo-build_rs.dir/DependInfo.cmake "--color="
make[2]: Leaving directory 'D:/Workspace/untitled/build'
C:/Users/kr328/AppData/Local/Android/Sdk/ndk/25.2.9519653/prebuilt/windows-x86_64/bin/make.exe  -f CMakeFiles/_cargo-build_rs.dir/build.make CMakeFiles/_cargo-build_rs.dir/build
make[2]: Entering directory 'D:/Workspace/untitled/build'
cd D:/Workspace/untitled && C:/Users/kr328/scoop/apps/cmake/3.27.7/bin/cmake.exe -E env CARGO_TARGET_ARMV7_LINUX_ANDROIDEAB
I_LINKER=C:/Users/kr328/AppData/Local/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe CC
_armv7-linux-androideabi=C:/Users/kr328/AppData/Local/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/windows-x86_64/
bin/clang.exe CXX_armv7-linux-androideabi=C:/Users/kr328/AppData/Local/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuil
t/windows-x86_64/bin/clang++.exe CORROSION_BUILD_DIR=D:/Workspace/untitled/build CARGO_BUILD_RUSTC=C:/Users/kr328/scoop/per
sist/rustup/.rustup/toolchains/stable-x86_64-pc-windows-msvc/bin/rustc.exe C:/Users/kr328/scoop/persist/rustup/.rustup/tool
chains/stable-x86_64-pc-windows-msvc/bin/cargo.exe rustc --bin=rs --target=armv7-linux-androideabi --package rs --manifest-
path D:/Workspace/untitled/Cargo.toml --target-dir D:/Workspace/untitled/build/./cargo/build -- -Clink-args=--sysroot=C:/Us
ers/kr328/AppData/Local/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Cdefault-linker-libraries=yes -Clink-args=--target=armv7-none-linux-androideabi19
   Compiling version_check v0.9.4
   Compiling cfg-if v1.0.0
   Compiling once_cell v1.18.0
   Compiling vcpkg v0.2.15
   Compiling cc v1.0.84
   Compiling pkg-config v0.3.27
   Compiling zerocopy v0.7.25
   Compiling allocator-api2 v0.2.16
   Compiling fallible-iterator v0.3.0
   Compiling fallible-streaming-iterator v0.1.9
   Compiling bitflags v2.4.1
   Compiling smallvec v1.11.2
   Compiling ahash v0.8.6                                                                                                  
   Compiling hashbrown v0.14.2                                                                                             
   Compiling hashlink v0.8.4                                                                                              
   Compiling libsqlite3-sys v0.27.0                                                                                       
error: failed to run custom build command for `libsqlite3-sys v0.27.0`                                                    

Caused by:
  process didn't exit successfully: `D:/Workspace/untitled/build/./cargo/build\debug\build\libsqlite3-sys-79bbe906344a51ef\build-script-build` (exit code: 1)
  --- stdout
  cargo:rerun-if-env-changed=LIBSQLITE3_SYS_USE_PKG_CONFIG
  cargo:rerun-if-changed=sqlite3/sqlite3.c
  cargo:rerun-if-changed=sqlite3/wasm32-wasi-vfs.c
  cargo:rerun-if-env-changed=SQLITE_MAX_VARIABLE_NUMBER
  cargo:rerun-if-env-changed=SQLITE_MAX_EXPR_DEPTH
  cargo:rerun-if-env-changed=SQLITE_MAX_COLUMN
  cargo:rerun-if-env-changed=LIBSQLITE3_FLAGS
  TARGET = Some("armv7-linux-androideabi")
  OPT_LEVEL = Some("0")
  HOST = Some("x86_64-pc-windows-msvc")
  cargo:rerun-if-env-changed=CC_armv7-linux-androideabi
  CC_armv7-linux-androideabi = Some("C:/Users/kr328/AppData/Local/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe")
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  cargo:rerun-if-env-changed=CFLAGS_armv7-linux-androideabi
  CFLAGS_armv7-linux-androideabi = None
  cargo:rerun-if-env-changed=CFLAGS_armv7_linux_androideabi
  CFLAGS_armv7_linux_androideabi = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  running: "C:/Users/kr328/AppData/Local/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
" "-O0" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "--target=armv7-l
inux-androideabi" "-DSQLITE_CORE" "-DSQLITE_DEFAULT_FOREIGN_KEYS=1" "-DSQLITE_ENABLE_API_ARMOR" "-DSQLITE_ENABLE_COLUMN_MET
ADATA" "-DSQLITE_ENABLE_DBSTAT_VTAB" "-DSQLITE_ENABLE_FTS3" "-DSQLITE_ENABLE_FTS3_PARENTHESIS" "-DSQLITE_ENABLE_FTS5" "-DSQ
LITE_ENABLE_JSON1" "-DSQLITE_ENABLE_LOAD_EXTENSION=1" "-DSQLITE_ENABLE_MEMORY_MANAGEMENT" "-DSQLITE_ENABLE_RTREE" "-DSQLITE
_ENABLE_STAT2" "-DSQLITE_ENABLE_STAT4" "-DSQLITE_SOUNDEX" "-DSQLITE_THREADSAFE=1" "-DSQLITE_USE_URI" "-DHAVE_USLEEP=1" "-D_
POSIX_THREAD_SAFE_FUNCTIONS" "-DSQLITE_TEMP_STORE=3" "-DHAVE_ISNAN" "-DHAVE_LOCALTIME_R" "-o" "D:/Workspace/untitled/build/
./cargo/build\\armv7-linux-androideabi\\debug\\build\\libsqlite3-sys-cbbebc952c7453a5\\out\\sqlite3/sqlite3.o" "-c" "sqlite3/sqlite3.c"
  exit code: 0
  cargo:rerun-if-env-changed=AR_armv7-linux-androideabi
  AR_armv7-linux-androideabi = None
  cargo:rerun-if-env-changed=AR_armv7_linux_androideabi
  AR_armv7_linux_androideabi = None
  cargo:rerun-if-env-changed=TARGET_AR
  TARGET_AR = None
  cargo:rerun-if-env-changed=AR
  AR = None
  cargo:rerun-if-env-changed=ARFLAGS_armv7-linux-androideabi
  ARFLAGS_armv7-linux-androideabi = None
  cargo:rerun-if-env-changed=ARFLAGS_armv7_linux_androideabi
  ARFLAGS_armv7_linux_androideabi = None
  cargo:rerun-if-env-changed=TARGET_ARFLAGS
  TARGET_ARFLAGS = None
  cargo:rerun-if-env-changed=ARFLAGS
  ARFLAGS = None
  running: "arm-linux-androideabi-ar" "cq" "D:/Workspace/untitled/build/./cargo/build\\armv7-linux-androideabi\\debug\\buil
d\\libsqlite3-sys-cbbebc952c7453a5\\out\\libsqlite3.a" "D:/Workspace/untitled/build/./cargo/build\\armv7-linux-androideabi\\debug\\build\\libsqlite3-sys-cbbebc952c7453a5\\out\\sqlite3/sqlite3.o"

  --- stderr


  error occurred: Failed to find tool. Is `arm-linux-androideabi-ar` installed? (see https://github.com/rust-lang/cc-rs#compile-time-requirements for help)


make[2]: *** [CMakeFiles/_cargo-build_rs.dir/build.make:70: CMakeFiles/_cargo-build_rs] Error 101
make[2]: Leaving directory 'D:/Workspace/untitled/build'
make[1]: *** [CMakeFiles/Makefile2:105: CMakeFiles/_cargo-build_rs.dir/all] Error 2
make[1]: Leaving directory 'D:/Workspace/untitled/build'
make: *** [Makefile:91: all] Error 2


@Kr328 Kr328 added the bug Something isn't working label Nov 14, 2023
@jschwe
Copy link
Collaborator

jschwe commented Nov 14, 2023

Seems reasonable to me. Thanks for the report.

jschwe added a commit that referenced this issue Nov 15, 2023
- Set the `AR_<triple>` variable for cc-rs.
- Simplify condition for CC_<triple> and CXX_<triple>.
  The target is always defined in corrosion,
  so there is no need to check if it set.

Closes #454
jschwe added a commit that referenced this issue Nov 15, 2023
- Set the `AR_<triple>` variable for cc-rs.
- Simplify condition for CC_<triple> and CXX_<triple>.
  The target is always defined in corrosion,
  so there is no need to check if it set.

Closes #454
jschwe added a commit that referenced this issue Nov 15, 2023
- Set the `AR_<triple>` variable for cc-rs.
- Simplify condition for CC_<triple> and CXX_<triple>.
  The target is always defined in corrosion,
  so there is no need to check if it set.

Closes #454
jschwe added a commit to jschwe/corrosion that referenced this issue May 10, 2024
- Set the `AR_<triple>` variable for cc-rs.
- Simplify condition for CC_<triple> and CXX_<triple>.
  The target is always defined in corrosion,
  so there is no need to check if it set.

Closes corrosion-rs#454

(cherry picked from commit b72c8ce)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants