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

turbojpeg-sys fails to build with cc 1.0.84 with Android NDK 21 #903

Closed
tyilo opened this issue Nov 14, 2023 · 13 comments
Closed

turbojpeg-sys fails to build with cc 1.0.84 with Android NDK 21 #903

tyilo opened this issue Nov 14, 2023 · 13 comments

Comments

@tyilo
Copy link

tyilo commented Nov 14, 2023

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.
@NobodyXu
Copy link
Collaborator

cmake uses cc to obtain the compiler, I think this might be related to #709 .

@tyilo Can you try compiling with cc@=1.0.83 and get cmake to print the compiler it is used?

I suspect it might be using gcc with cc@=1.0.83 and clang with cc@1.0.84

@tyilo
Copy link
Author

tyilo commented Nov 23, 2023

@NobodyXu There is no gcc compiler included in the Android NDK, only clang, so that would be impossible I think (especially when the build completes successfully).

Anyway here is the values of c_compiler, cxx_compiler and asm_compiler in cmake when running with cc@=1.0.83:

c_compiler: Tool { path: "/home/tyilo/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi17-clang", cc_wrapper_path: None, cc_wrapper_args: [], args: ["-O0", "-DANDROID", "-ffunction-sections", "-fdata-sections", "-fPIC"], env: [], family: Clang, cuda: false, removed_args: [] }
cxx_compiler: Tool { path: "/home/tyilo/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi17-clang++", cc_wrapper_path: None, cc_wrapper_args: [], args: ["-O0", "-DANDROID", "-ffunction-sections", "-fdata-sections", "-fPIC"], env: [], family: Clang, cuda: false, removed_args: [] }
asm_compiler: Tool { path: "/home/tyilo/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi17-clang", cc_wrapper_path: None, cc_wrapper_args: [], args: ["-O0", "-DANDROID", "-ffunction-sections", "-fdata-sections", "-fPIC"], env: [], family: Clang, cuda: false, removed_args: [] }

Here is the same when using cc@=1.0.84 (yanked):

c_compiler: Tool { path: "/home/tyilo/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi17-clang", cc_wrapper_path: None, cc_wrapper_args: [], args: ["-O0", "-DANDROID", "-ffunction-sections", "-fdata-sections", "-fPIC", "--target=armv7-linux-androideabi"], env: [], family: Clang, cuda: false, removed_args: [], has_internal_target_arg: false }
cxx_compiler: Tool { path: "/home/tyilo/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi17-clang++", cc_wrapper_path: None, cc_wrapper_args: [], args: ["-O0", "-DANDROID", "-ffunction-sections", "-fdata-sections", "-fPIC", "--target=armv7-linux-androideabi"], env: [], family: Clang, cuda: false, removed_args: [], has_internal_target_arg: false }
asm_compiler: Tool { path: "/home/tyilo/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi17-clang", cc_wrapper_path: None, cc_wrapper_args: [], args: ["-O0", "-DANDROID", "-ffunction-sections", "-fdata-sections", "-fPIC", "--target=armv7-linux-androideabi"], env: [], family: Clang, cuda: false, removed_args: [], has_internal_target_arg: false }

Seems like the difference is that --target=armv7-linux-androideabi is getting passed to clang in 1.0.84, but not in 1.0.83.

@NobodyXu
Copy link
Collaborator

hmmm @tyilo Can you do a bisect on v1.0.83..v1.0.84 to find out which commits caused this error?

@tyilo
Copy link
Author

tyilo commented Nov 29, 2023

@NobodyXu Done:

53564e00498156c9be00361c4b039952cbf7ff59 is the first bad commit
commit 53564e00498156c9be00361c4b039952cbf7ff59
Author: Arc-blroth <45273859+Arc-blroth@users.noreply.github.com>
Date:   Wed Jul 27 13:42:07 2022 -0700

    Fix `--target` getting passed twice to the Android NDK clang on Windows

 src/lib.rs | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

@NobodyXu
Copy link
Collaborator

Thanks!

I will investigate this, would be great if you can also get the build commands run by cmake.

@tyilo
Copy link
Author

tyilo commented Nov 29, 2023

Seems to be the following with at commit 53564e0:

cd "/home/tyilo/tmp/cc-repro/target/armv7-linux-androideabi/debug/build/turbojpeg-sys-6d3bd97a5c68f099/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/home/tyilo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/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=/home/tyilo/tmp/cc-repro/target/armv7-linux-androideabi/debug/build/turbojpeg-sys-6d3bd97a5c68f099/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"

and using the previous commit 755e4fe:

cd "/home/tyilo/tmp/cc-repro/target/armv7-linux-androideabi/debug/build/turbojpeg-sys-6d3bd97a5c68f099/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/home/tyilo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/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=/home/tyilo/tmp/cc-repro/target/armv7-linux-androideabi/debug/build/turbojpeg-sys-6d3bd97a5c68f099/out" "-DCMAKE_C_FLAGS= -DANDROID -ffunction-sections -fdata-sections -fPIC" "-DCMAKE_CXX_FLAGS= -DANDROID -ffunction-sections -fdata-sections -fPIC" "-DCMAKE_ASM_FLAGS= -DANDROID -ffunction-sections -fdata-sections -fPIC" "-DCMAKE_BUILD_TYPE=Debug" "-DENABLE_SHARED=0" "-DENABLE_STATIC=1" "-DANDROID_ABI=armeabi-v7a"

Again, the only difference seems to be the --target=armv7-linux-androideabi flag.

@NobodyXu
Copy link
Collaborator

Seems that 53564e0 actually adds --target=armv7-linux-androideabi to the args for compilers.

@glandium
Copy link
Contributor

IIRC, recent clang wants an API version in the target, as in --target=armv7-linux-androideabi16, rather than --target=armv7-linux-androideabi

@thomcc
Copy link
Member

thomcc commented Nov 30, 2023

That's unfortunate. Is there an environment variable or something we can use to get that value (similar to MACOSX_DEPLOYMENT_TARGET)

@NobodyXu
Copy link
Collaborator

@tyilo Can you try cc 1.0.87 to see if it fixes your issue?
Thanks!

@tyilo
Copy link
Author

tyilo commented Feb 26, 2024

@tyilo Can you try cc 1.0.87 to see if it fixes your issue? Thanks!

I still get the same 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-af221b871b0a29d8/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-79b1b4b97d68384c/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-79b1b4b97d68384c/out/build/CMakeFiles/CMakeScratch/TryCompile-3Z28bx'

      Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_c9455/fast
      /usr/bin/make  -f CMakeFiles/cmTC_c9455.dir/build.make CMakeFiles/cmTC_c9455.dir/build
      make[1]: Entering directory '/tmp/cc-repro/target/armv7-linux-androideabi/debug/build/turbojpeg-sys-79b1b4b97d68384c/out/build/CMakeFiles/CMakeScratch/TryCompile-3Z28bx'
      Building C object CMakeFiles/cmTC_c9455.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_c9455.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_c9455.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_c9455.dir/testCCompiler.c.o -c /tmp/cc-repro/target/armv7-linux-androideabi/debug/build/turbojpeg-sys-79b1b4b97d68384c/out/build/CMakeFiles/CMakeScratch/TryCompile-3Z28bx/testCCompiler.c
      Linking C executable cmTC_c9455
      /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_c9455.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_c9455.dir/testCCompiler.c.o -o cmTC_c9455  -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_c9455.dir/build.make:100: cmTC_c9455] Error 1
      make[1]: Leaving directory '/tmp/cc-repro/target/armv7-linux-androideabi/debug/build/turbojpeg-sys-79b1b4b97d68384c/out/build/CMakeFiles/CMakeScratch/TryCompile-3Z28bx'
      make: *** [Makefile:127: cmTC_c9455/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
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@tyilo
Copy link
Author

tyilo commented Feb 26, 2024

Same thing happens with cc 1.0.86 and 1.0.88.

@tyilo
Copy link
Author

tyilo commented Mar 13, 2024

cc 1.0.90 seems to have fixed this.

@tyilo tyilo closed this as completed Mar 13, 2024
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

4 participants