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

No rule to make target '/bin/mkrename' (and similar) when cross-compiling for Android #308

Closed
alexeyr opened this issue May 14, 2020 · 4 comments

Comments

@alexeyr
Copy link

alexeyr commented May 14, 2020

I've tried to follow "Importing SLEEF into your project" section of https://sleef.org/compile.xhtml:

set(ANDROID_FLAGS -DCMAKE_TOOLCHAIN_FILE=${PROJECT_SOURCE_DIR}/thirdparty/Android/Sdk/ndk/21.0.6113669/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_NATIVE_API_LEVEL=24)

externalproject_add(libsleef
  SOURCE_DIR "${PROJECT_SOURCE_DIR}/thirdparty/sleef"
  CMAKE_ARGS ${ANDROID_FLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/sleef -DSLEEF_SHOW_CONFIG=true -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=false -DBUILD_DFT=false
)

This produces

[ 56%] No download step for 'libsleef'
[ 59%] No patch step for 'libsleef'
[ 62%] No update step for 'libsleef'
[ 65%] Performing configure step for 'libsleef'
CMake Deprecation Warning at CMakeLists.txt:24 (cmake_policy):
  The OLD behavior for policy CMP0066 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


-- Check for working C compiler: /mnt/e/MyProgramming/fused-transformer-mobile-1/thirdparty/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /mnt/e/MyProgramming/fused-transformer-mobile-1/thirdparty/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/clang - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of long double
-- Check size of long double - done
-- Performing Test COMPILER_SUPPORTS_LONG_DOUBLE
-- Performing Test COMPILER_SUPPORTS_LONG_DOUBLE - Success
-- Performing Test COMPILER_SUPPORTS_FLOAT128
-- Performing Test COMPILER_SUPPORTS_FLOAT128 - Failed
-- Performing Test COMPILER_SUPPORTS_SVE
-- Performing Test COMPILER_SUPPORTS_SVE - Failed
-- Found OpenMP_C: -fopenmp=libomp (found version "3.1") 
-- Found OpenMP: TRUE (found version "3.1")  
-- Performing Test COMPILER_SUPPORTS_OPENMP
-- Performing Test COMPILER_SUPPORTS_OPENMP - Success
-- Performing Test COMPILER_SUPPORTS_WEAK_ALIASES
-- Performing Test COMPILER_SUPPORTS_WEAK_ALIASES - Success
-- Performing Test COMPILER_SUPPORTS_BUILTIN_MATH
-- Performing Test COMPILER_SUPPORTS_BUILTIN_MATH - Success
-- Performing Test COMPILER_SUPPORTS_SYS_GETRANDOM
-- Performing Test COMPILER_SUPPORTS_SYS_GETRANDOM - Success
-- Configuring build for SLEEF-v3.5.0
   Target system: Android-1
   Target processor: aarch64
   Host system: Linux-4.4.0-18362-Microsoft
   Host processor: x86_64
   Detected C compiler: Clang @ /mnt/e/MyProgramming/fused-transformer-mobile-1/thirdparty/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
   Crosscompiling SLEEF.
   Native build dir: 
-- Using option `-Wall -Wno-unused -Wno-attributes -Wno-unused-result -ffp-contract=off -fno-math-errno -fno-trapping-math` to compile libsleef
-- Building shared libs : ON
-- MPFR : LIB_MPFR-NOTFOUND
-- GMP : LIBGMP-NOTFOUND
-- RT : 
-- FFTW3 : LIBFFTW3-NOTFOUND
-- OPENSSL : 
-- SDE : SDE_COMMAND-NOTFOUND
-- RUNNING_ON_TRAVIS : 0
-- COMPILER_SUPPORTS_OPENMP : 1
-- A version of SLEEF compatible  with libm and libmvec in GNU libc will be produced (sleefgnuabi.so)
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    BUILD_INLINE_HEADERS


-- Build files have been written to: /mnt/e/MyProgramming/fused-transformer-mobile-1/build/libsleef-prefix/src/libsleef-build
[ 68%] Performing build step for 'libsleef'
make[5]: *** No rule to make target '/bin/mkrename_gnuabi', needed by 'src/libm/include/renameadvsimd_gnuabi.h'.  Stop.
CMakeFiles/Makefile2:571: recipe for target 'src/libm/CMakeFiles/sleefgnuabiadvsimddp.dir/all' failed
make[4]: *** [src/libm/CMakeFiles/sleefgnuabiadvsimddp.dir/all] Error 2
make[4]: *** Waiting for unfinished jobs....
Scanning dependencies of target alias_advsimd.h_generated
Scanning dependencies of target renameADVSIMD.h_generated
Scanning dependencies of target common
Scanning dependencies of target headers
Scanning dependencies of target renamePUREC_SCALAR.h_generated
Scanning dependencies of target renameADVSIMDNOFMA.h_generated
Scanning dependencies of target renamePURECFMA_SCALAR.h_generated
make[5]: *** No rule to make target '/bin/mkalias', needed by 'src/libm/include/alias_advsimd.h'.  Stop.
CMakeFiles/Makefile2:239: recipe for target 'src/libm/CMakeFiles/alias_advsimd.h_generated.dir/all' failed
make[4]: *** [src/libm/CMakeFiles/alias_advsimd.h_generated.dir/all] Error 2
make[5]: *** No rule to make target '/bin/mkrename', needed by 'src/libm/include/renameadvsimdnofma.h'.  Stop.
make[5]: *** No rule to make target '/bin/mkrename', needed by 'src/libm/include/renamepurecfma_scalar.h'.  Stop.
CMakeFiles/Makefile2:374: recipe for target 'src/libm/CMakeFiles/renamePURECFMA_SCALAR.h_generated.dir/all' failed
make[4]: *** [src/libm/CMakeFiles/renamePURECFMA_SCALAR.h_generated.dir/all] Error 2
CMakeFiles/Makefile2:266: recipe for target 'src/libm/CMakeFiles/renameADVSIMDNOFMA.h_generated.dir/all' failed
make[4]: *** [src/libm/CMakeFiles/renameADVSIMDNOFMA.h_generated.dir/all] Error 2
make[5]: *** No rule to make target '/bin/mkrename', needed by 'include/sleef.h'.  Stop.
CMakeFiles/Makefile2:293: recipe for target 'src/libm/CMakeFiles/headers.dir/all' failed
make[4]: *** [src/libm/CMakeFiles/headers.dir/all] Error 2
make[5]: *** No rule to make target '/bin/mkrename', needed by 'src/libm/include/renamepurec_scalar.h'.  Stop.
CMakeFiles/Makefile2:401: recipe for target 'src/libm/CMakeFiles/renamePUREC_SCALAR.h_generated.dir/all' failed
make[4]: *** [src/libm/CMakeFiles/renamePUREC_SCALAR.h_generated.dir/all] Error 2
make[5]: *** No rule to make target '/bin/mkrename', needed by 'src/libm/include/renameadvsimd.h'.  Stop.
CMakeFiles/Makefile2:347: recipe for target 'src/libm/CMakeFiles/renameADVSIMD.h_generated.dir/all' failed
make[4]: *** [src/libm/CMakeFiles/renameADVSIMD.h_generated.dir/all] Error 2
[  2%] Building C object src/common/CMakeFiles/common.dir/common.c.o
[  2%] Built target common
Makefile:160: recipe for target 'all' failed
make[3]: *** [all] Error 2
CMakeFiles/libsleef.dir/build.make:131: recipe for target 'libsleef-prefix/src/libsleef-stamp/libsleef-build' failed
make[2]: *** [libsleef-prefix/src/libsleef-stamp/libsleef-build] Error 2
CMakeFiles/Makefile2:274: recipe for target 'CMakeFiles/libsleef.dir/all' failed
make[1]: *** [CMakeFiles/libsleef.dir/all] Error 2
Makefile:103: recipe for target 'all' failed
make: *** [all] Error 2

Without ${ANDROID_FLAGS} SLEEF builds successfully, but of course can't be used on Android.

@shibatch
Copy link
Owner

Hello,
Android is not directly supported at this point.
I think you can generate llvm bitcode on a linux computer, and bring it to Android.

@alexeyr
Copy link
Author

alexeyr commented May 15, 2020

Issue #249 seems related. I'll also try to adapt the script linked there...

@alexeyr
Copy link
Author

alexeyr commented Oct 26, 2020

The pure CMake approach is

set(SLEEF_SOURCE_DIR "${PROJECT_SOURCE_DIR}/thirdparty/sleef")
set(SLEEF_BINARY_DIR "${SLEEF_SOURCE_DIR}/build/${ICU_TARGET}")
file(MAKE_DIRECTORY ${SLEEF_BINARY_DIR})
set(SLEEF_COMMON_ARGS -DCMAKE_BUILD_TYPE=Release -DSLEEF_SHOW_CONFIG=false -DBUILD_SHARED_LIBS=false -DBUILD_DFT=false -DBUILD_GNUABI_LIBS=false -DBUILD_TESTS=false -DDISABLE_FLOAT128=true -DDISABLE_LONG_DOUBLE=true)
if (ANDROID)
  set(SLEEF_NATIVE_BINARY_DIR "${SLEEF_SOURCE_DIR}/build/native")
  file(MAKE_DIRECTORY ${SLEEF_NATIVE_BINARY_DIR})
  externalproject_add(sleef
      SOURCE_DIR ${SLEEF_SOURCE_DIR}
      BINARY_DIR ${SLEEF_BINARY_DIR}
      CONFIGURE_COMMAND ${CMAKE_COMMAND} -GNinja ${SLEEF_COMMON_ARGS} -S ${SLEEF_SOURCE_DIR} -B ${SLEEF_NATIVE_BINARY_DIR} && ${CMAKE_COMMAND} -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=true ${SLEEF_COMMON_ARGS} ${ANDROID_FLAGS} -DNATIVE_BUILD_DIR=${SLEEF_NATIVE_BINARY_DIR} -S ${SLEEF_SOURCE_DIR} -B ${SLEEF_BINARY_DIR}
      BUILD_COMMAND ${CMAKE_COMMAND} --build ${SLEEF_NATIVE_BINARY_DIR} --target mkrename && ${CMAKE_COMMAND} --build ${SLEEF_NATIVE_BINARY_DIR} --target mkdisp && ${CMAKE_COMMAND} --build ${SLEEF_NATIVE_BINARY_DIR} --target mkalias && ${CMAKE_COMMAND} --build ${SLEEF_NATIVE_BINARY_DIR} --target addSuffix && ${CMAKE_COMMAND} --build ${SLEEF_BINARY_DIR}
      INSTALL_COMMAND "")
else()
  externalproject_add(sleef
      SOURCE_DIR ${SLEEF_SOURCE_DIR}
      BINARY_DIR ${SLEEF_BINARY_DIR}
      CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} ${SLEEF_COMMON_ARGS}
      INSTALL_COMMAND "")
endif()
add_library(sleef_lib STATIC IMPORTED)
set_property(TARGET sleef_lib PROPERTY IMPORTED_LOCATION ${SLEEF_BINARY_DIR}/lib/libsleef.a)
add_dependencies(sleef_lib sleef)

@alexeyr alexeyr closed this as completed Oct 26, 2020
@alexeyr
Copy link
Author

alexeyr commented Oct 26, 2020

${CMAKE_COMMAND} --build ${SLEEF_NATIVE_BINARY_DIR} --target mkrename && ${CMAKE_COMMAND} --build ${SLEEF_NATIVE_BINARY_DIR} --target mkdisp && ${CMAKE_COMMAND} --build ${SLEEF_NATIVE_BINARY_DIR} --target mkalias && ${CMAKE_COMMAND} --build ${SLEEF_NATIVE_BINARY_DIR} --target addSuffix

can be simplified to

${CMAKE_COMMAND} --build ${SLEEF_NATIVE_BINARY_DIR} --target mkrename mkdisp mkalias addSuffix

but this requires CMake 3.15+, and NDK comes only with CMake 3.10.2 for now.

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