Closed
Description
I have a project depending on turbojpeg-sys
which I need to compile for the armv7-linux-androideabi
target for Android API level 17, meaning that I need to use Android NDK v21.
Compiling a project with the latest version of turbojpeg-sys
with version 1.0.83 of cc works:
# Setup project
cd /tmp
cargo new cc-repro
cd cc-repro
rustup override set 1.67.1
cargo add turbojpeg-sys@=0.2.3 -F cmake --no-default-features
cargo add cc@=1.0.83
# Setup variables
export NDK_VERSION=21
ANDROID_API_LEVEL=17
export ANDROID_ABI=armeabi-v7a
export CARGO_BUILD_TARGET=armv7-linux-androideabi
export NDK_TARGET=armv7a-linux-androideabi
export ANDROID_NDK=$HOME/Android/Sdk/ndk/21.4.7075529
NDK_BIN_PATH=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin
export AR="$NDK_BIN_PATH/llvm-ar"
export CC="$NDK_BIN_PATH/$NDK_TARGET$ANDROID_API_LEVEL-clang"
export AS="$CC"
export CXX="$NDK_BIN_PATH/$NDK_TARGET$ANDROID_API_LEVEL-clang++"
export LD="$NDK_BIN_PATH/ld"
export RANLIB="$NDK_BIN_PATH/llvm-ranlib"
export STRIP="$NDK_BIN_PATH/llvm-strip"
export CMAKE_TOOLCHAIN_FILE="$ANDROID_NDK/build/cmake/android.toolchain.cmake"
export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="$CC"
export ANDROID_PLATFORM=android-$ANDROID_API_LEVEL
export ANDROID_TOOLCHAIN=clang
# Build (succeeds)
cargo build
However, if I upgrade cc
to version 1.0.84 the build fails:
cargo add cc@=1.0.84
export RUST_BACKTRACE=1
cargo build
Error:
Compiling turbojpeg-sys v0.2.3
error: failed to run custom build command for `turbojpeg-sys v0.2.3`
Caused by:
process didn't exit successfully: `/tmp/cc-repro/target/debug/build/turbojpeg-sys-61fad519915a5af1/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs
cargo:rerun-if-env-changed=ARMV7_LINUX_ANDROIDEABI_TURBOJPEG_STATIC
ARMV7_LINUX_ANDROIDEABI_TURBOJPEG_STATIC unset
cargo:rerun-if-env-changed=TURBOJPEG_STATIC
TURBOJPEG_STATIC unset
cargo:rerun-if-env-changed=ARMV7_LINUX_ANDROIDEABI_TURBOJPEG_DYNAMIC
ARMV7_LINUX_ANDROIDEABI_TURBOJPEG_DYNAMIC unset
cargo:rerun-if-env-changed=TURBOJPEG_DYNAMIC
TURBOJPEG_DYNAMIC unset
cargo:rerun-if-env-changed=ARMV7_LINUX_ANDROIDEABI_TURBOJPEG_SHARED
ARMV7_LINUX_ANDROIDEABI_TURBOJPEG_SHARED unset
cargo:rerun-if-env-changed=TURBOJPEG_SHARED
TURBOJPEG_SHARED unset
cargo:rerun-if-env-changed=ARMV7_LINUX_ANDROIDEABI_TURBOJPEG_SOURCE
ARMV7_LINUX_ANDROIDEABI_TURBOJPEG_SOURCE unset
cargo:rerun-if-env-changed=TURBOJPEG_SOURCE
TURBOJPEG_SOURCE unset
Building turbojpeg from source
NASM version 2.16.01 compiled on Mar 18 2023
CMAKE_TOOLCHAIN_FILE_armv7-linux-androideabi = None
CMAKE_TOOLCHAIN_FILE_armv7_linux_androideabi = None
TARGET_CMAKE_TOOLCHAIN_FILE = None
CMAKE_TOOLCHAIN_FILE = Some("/home/tyilo/Android/Sdk/ndk/21.4.7075529/build/cmake/android.toolchain.cmake")
CMAKE_GENERATOR_armv7-linux-androideabi = None
CMAKE_GENERATOR_armv7_linux_androideabi = None
TARGET_CMAKE_GENERATOR = None
CMAKE_GENERATOR = None
CMAKE_PREFIX_PATH_armv7-linux-androideabi = None
CMAKE_PREFIX_PATH_armv7_linux_androideabi = None
TARGET_CMAKE_PREFIX_PATH = None
CMAKE_PREFIX_PATH = None
CMAKE_armv7-linux-androideabi = None
CMAKE_armv7_linux_androideabi = None
TARGET_CMAKE = None
CMAKE = None
running: "cmake" "/home/tyilo/.cargo/registry/src/github.com-1ecc6299db9ec823/turbojpeg-sys-0.2.3/libjpeg-turbo" "-DCMAKE_INSTALL_DEFAULT_LIBDIR=lib" "-DCMAKE_TOOLCHAIN_FILE=/home/tyilo/Android/Sdk/ndk/21.4.7075529/build/cmake/android.toolchain.cmake" "-DCMAKE_INSTALL_PREFIX=/tmp/cc-repro/target/armv7-linux-androideabi/debug/build/turbojpeg-sys-2af90a23e30f6c9a/out" "-DCMAKE_C_FLAGS= -DANDROID -ffunction-sections -fdata-sections -fPIC --target=armv7-linux-androideabi" "-DCMAKE_CXX_FLAGS= -DANDROID -ffunction-sections -fdata-sections -fPIC --target=armv7-linux-androideabi" "-DCMAKE_ASM_FLAGS= -DANDROID -ffunction-sections -fdata-sections -fPIC --target=armv7-linux-androideabi" "-DCMAKE_BUILD_TYPE=Debug" "-DENABLE_SHARED=0" "-DENABLE_STATIC=1" "-DANDROID_ABI=armeabi-v7a"
-- ANDROID_PLATFORM not set. Defaulting to minimum supported version
16.
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /home/tyilo/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /home/tyilo/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang - broken
-- Configuring incomplete, errors occurred!
--- stderr
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
CMake Error at /usr/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
The C compiler
"/home/tyilo/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: '/tmp/cc-repro/target/armv7-linux-androideabi/debug/build/turbojpeg-sys-2af90a23e30f6c9a/out/build/CMakeFiles/CMakeScratch/TryCompile-3eovQe'
Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_f5251/fast
/usr/bin/make -f CMakeFiles/cmTC_f5251.dir/build.make CMakeFiles/cmTC_f5251.dir/build
make[1]: Entering directory '/tmp/cc-repro/target/armv7-linux-androideabi/debug/build/turbojpeg-sys-2af90a23e30f6c9a/out/build/CMakeFiles/CMakeScratch/TryCompile-3eovQe'
Building C object CMakeFiles/cmTC_f5251.dir/testCCompiler.c.o
/home/tyilo/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi16 --gcc-toolchain=/home/tyilo/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/tyilo/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -DANDROID -ffunction-sections -fdata-sections -fPIC --target=armv7-linux-androideabi -fPIE -MD -MT CMakeFiles/cmTC_f5251.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_f5251.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_f5251.dir/testCCompiler.c.o -c /tmp/cc-repro/target/armv7-linux-androideabi/debug/build/turbojpeg-sys-2af90a23e30f6c9a/out/build/CMakeFiles/CMakeScratch/TryCompile-3eovQe/testCCompiler.c
Linking C executable cmTC_f5251
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f5251.dir/link.txt --verbose=1
/home/tyilo/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi16 --gcc-toolchain=/home/tyilo/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/tyilo/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -DANDROID -ffunction-sections -fdata-sections -fPIC --target=armv7-linux-androideabi -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,--gc-sections CMakeFiles/cmTC_f5251.dir/testCCompiler.c.o -o cmTC_f5251 -latomic -lm
/home/tyilo/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtbegin_dynamic.o: No such file or directory
/home/tyilo/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtend_android.o: No such file or directory
external/jemalloc_new/src/jemalloc.c:1291: error: undefined reference to 'atexit'
external/jemalloc_new/src/jemalloc.c:1367: error: undefined reference to 'pthread_atfork'
/buildbot/src/android/gcc/toolchain/build/../gcc/gcc-4.9/libgcc/config/arm/lib1funcs.S:1337: error: undefined reference to 'raise'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [CMakeFiles/cmTC_f5251.dir/build.make:100: cmTC_f5251] Error 1
make[1]: Leaving directory '/tmp/cc-repro/target/armv7-linux-androideabi/debug/build/turbojpeg-sys-2af90a23e30f6c9a/out/build/CMakeFiles/CMakeScratch/TryCompile-3eovQe'
make: *** [Makefile:127: cmTC_f5251/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:12 (project)
thread 'main' panicked at '
command did not execute successfully, got: exit status: 1
build script failed, must exit now', /home/tyilo/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.50/src/lib.rs:1098:5
stack backtrace:
0: rust_begin_unwind
at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/panicking.rs:64:14
2: cmake::fail
at /home/tyilo/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.50/src/lib.rs:1098:5
3: cmake::run
at /home/tyilo/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.50/src/lib.rs:1076:9
4: cmake::Config::build
at /home/tyilo/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.50/src/lib.rs:813:13
5: build_script_build::build_vendor
at ./build.rs:167:20
6: build_script_build::build_or_find_library
at ./build.rs:70:17
7: build_script_build::main
at ./build.rs:12:19
8: core::ops::function::FnOnce::call_once
at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Metadata
Metadata
Assignees
Labels
No labels