Autotools packages are ignoring host profile and building for the build profile
Description
Hello, I'm trying to build some software for Android, but I've noticed that all of the autoconf packages are ignoring my host profile and just build for my build machine. This becomes apparent only when I try to link against the freshly built binary.
Here's a GitHub actions run illustrating the problem: https://github.com/ViliusSutkus89/conan-center-index/actions/runs/9534760342
CMake and Meson packages seem to be building fine, so it's just the Autotools
Package and Environment Details
- Package Name/Version: libiconv/1.17 libiconv/1.16 libiconv/1.15
- Operating System+version: Linux Ubuntu 22.04 Macos 13 Windows Server 2022
- Compiler+version: NDK 26.3.11579264
- Conan version: conan 2.4.1
- Python version: Python 3.12.3
Conan profile
Profile host: [settings] arch=armv8 build_type=Release compiler=clang compiler.cppstd=20 compiler.libcxx=c++_static compiler.version=17 os=Android os.api_level=23 [conf] tools.android:ndk_path=/usr/local/lib/android/sdk/ndk/26.3.11579264
Profile build: [settings] arch=x86_64 build_type=Release compiler=clang compiler.cppstd=17 compiler.libcxx=libstdc++11 compiler.version=15 os=Linux
Steps to reproduce
conan create recipes/libiconv/all/conanfile.py --version=1.17 --profile:host armv8
Logs
Click to expand log
======== Calling build() ========
conanfile.py (libiconv/1.17): Calling build()
conanfile.py (libiconv/1.17): RUN: "/home/runner/work/conan-center-index/conan-center-index/recipes/libiconv/all/src/configure" --disable-shared --enable-static --prefix=/ '--bindir=${prefix}/bin' '--sbindir=${prefix}/bin' '--libdir=${prefix}/lib' '--includedir=${prefix}/include' '--oldincludedir=${prefix}/include' --host=aarch64-linux-android --build=x86_64-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for aarch64-linux-android-strip... no
checking for strip... strip
configure: WARNING: using cross tools not prefixed with host triplet
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make sets $(MAKE)... (cached) yes
checking for aarch64-linux-android-gcc... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking whether the compiler is clang... no
checking for compiler option needed when checking for declarations... none
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... none
checking how to run the C preprocessor... gcc -E
checking for strip... /usr/bin/strip
checking for aarch64-linux-android-strip... /usr/bin/strip
checking build system type... x86_64-pc-linux-gnu
checking host system type... aarch64-unknown-linux-android
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for wchar.h... yes
checking for minix/config.h... no
checking for sys/param.h... yes
checking for sys/socket.h... yes
checking for limits.h... yes
checking for sys/time.h... yes
checking for features.h... yes
checking for crtdefs.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking whether _XOPEN_SOURCE should be defined... no
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for Minix Amsterdam compiler... no
checking for aarch64-linux-android-ar... no
checking for ar... ar
checking for aarch64-linux-android-ranlib... no
checking for ranlib... ranlib
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... no
checking for aarch64-linux-android-dumpbin... no
checking for aarch64-linux-android-link... no
checking for dumpbin... no
checking for link... link -dump
checking the name lister (nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 3145728
checking how to convert x86_64-pc-linux-gnu file names to aarch64-unknown-linux-android format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for aarch64-linux-android-file... no
checking for file... file
checking for aarch64-linux-android-objdump... no
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for aarch64-linux-android-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for aarch64-linux-android-ar... ar
checking for archiver @FILE support... @
checking for aarch64-linux-android-strip... (cached) /usr/bin/strip
checking for aarch64-linux-android-ranlib... ranlib
checking command to parse nm output from gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for aarch64-linux-android-mt... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... Android linker
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking for ld... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for shared library path variable... LD_LIBRARY_PATH
checking whether to activate relocatable installation... no
checking how to copy files... cp -p
checking how to make hard links... ln
checking whether ln -s works... yes
checking for aarch64-linux-android-windres... no
checking for windres... no
checking whether the -Werror option is usable... yes
checking for simple visibility declarations... yes
checking for shared library run path origin... done
checking 32-bit host C ABI... yes
checking for ELF binary format... yes
checking for the common suffixes of directories in the library search path... lib,lib32,lib
checking for iconv... yes
checking for working iconv... guessing yes
checking whether iconv is compatible with its POSIX signature... yes
checking whether NLS is requested... yes
checking for msgfmt... no
checking for gmsgfmt... :
checking for xgettext... no
checking for msgmerge... no
checking for CFPreferencesCopyAppValue... no
checking for CFLocaleCopyPreferredLanguages... no
checking for GNU gettext in libc... yes
checking whether to use NLS... yes
checking where the gettext function comes from... libc
checking for mbstate_t... yes
checking for wchar_t... yes
checking for getc_unlocked... yes
checking for mbrtowc... yes
checking for wcrtomb... yes
checking for mbsinit... yes
checking for setlocale... yes
checking whether <wchar.h> is standalone... yes
checking for memmove... yes
checking for nl_langinfo and CODESET... yes
checking for symlink... yes
checking for canonicalize_file_name... yes
checking for faccessat... yes
checking for realpath... yes
checking for lstat... yes
checking for readlinkat... yes
checking for _set_invalid_parameter_handler... no
checking for fcntl... yes
checking for getdtablesize... yes
checking for getprogname... no
checking for getexecname... no
checking for readlink... yes
checking for setenv... yes
checking for working fcntl.h... cross-compiling
checking for wchar.h... (cached) yes
checking for EILSEQ... yes
checking whether byte ordering is bigendian... no
checking for size_t... yes
checking for working alloca.h... yes
checking for alloca... yes
checking whether lstat correctly handles trailing slash... guessing yes
checking whether // is distinct from /... unknown, assuming no
checking whether realpath works... guessing no
checking for getcwd... yes
checking for C/C++ restrict keyword... __restrict__
checking if environ is properly declared... yes
checking whether the preprocessor supports include_next... yes
checking whether source code line length is unlimited... yes
checking for complete errno.h... yes
checking for gcc options needed to detect all undeclared functions... none needed
checking whether strerror_r is declared... yes
checking whether strerror_r returns char *... yes
checking whether ctype.h defines __header_inline... no
checking for pid_t... yes
checking for mode_t... yes
checking whether stat file-mode macros are broken... no
checking for nlink_t... yes
checking whether getdtablesize is declared... yes
checking whether limits.h has WORD_BIT, BOOL_WIDTH etc.... yes
checking for wint_t... yes
checking whether wint_t is large enough... yes
checking whether the compiler produces multi-arch binaries... no
checking whether stdint.h conforms to C99... guessing yes
checking whether stdint.h works without ISO C predefines... yes
checking whether stdint.h has UINTMAX_WIDTH etc.... yes
checking whether malloc is ptrdiff_t safe... yes
checking whether malloc, realloc, calloc set errno on failure... yes
checking whether malloc (0) returns nonnull... guessing no
checking whether <limits.h> defines MIN and MAX... no
checking whether <sys/param.h> defines MIN and MAX... yes
checking for O_CLOEXEC... yes
checking for promoted mode_t type... mode_t
checking for sigset_t... yes
checking for SIGPIPE... yes
checking whether setenv is declared... yes
checking for ssize_t... yes
checking for uid_t in sys/types.h... yes
checking for volatile sig_atomic_t... yes
checking for sighandler_t... yes
checking whether C symbols are prefixed with underscore at the linker level... no
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking for good max_align_t... yes
checking whether NULL can be used in arbitrary expressions... yes
checking whether fcloseall is declared... yes
checking which flavor of printf attribute matches inttypes macros... system
checking whether ecvt is declared... yes
checking whether fcvt is declared... yes
checking whether gcvt is declared... yes
checking whether strerror(0) succeeds... guessing no
checking for struct timespec in <time.h>... yes
checking for TIME_UTC in <time.h>... yes
checking whether execvpe is declared... yes
checking whether clearerr_unlocked is declared... yes
checking whether feof_unlocked is declared... yes
checking whether ferror_unlocked is declared... yes
checking whether fflush_unlocked is declared... yes
checking whether fgets_unlocked is declared... yes
checking whether fputc_unlocked is declared... yes
checking whether fputs_unlocked is declared... yes
checking whether fread_unlocked is declared... yes
checking whether fwrite_unlocked is declared... yes
checking whether getc_unlocked is declared... yes
checking whether getchar_unlocked is declared... yes
checking whether putc_unlocked is declared... yes
checking whether putchar_unlocked is declared... yes
checking whether <wchar.h> uses 'inline' correctly... yes
checking whether wcsdup is declared... yes
checking for C compiler option to allow warnings... -Wno-error
checking for __builtin_expect... yes
checking whether // is distinct from /... (cached) unknown, assuming no
checking whether dup2 works... guessing no
checking for setdtablesize... no
checking for error_at_line... yes
checking whether fcntl handles F_DUPFD correctly... guessing yes
checking whether fcntl understands F_DUPFD_CLOEXEC... guessing no
checking whether free is known to preserve errno... yes
checking whether getdtablesize works... guessing yes
checking whether program_invocation_name is declared... yes
checking whether program_invocation_short_name is declared... yes
checking whether __argv is declared... no
checking whether the -Werror option is usable... (cached) yes
checking for simple visibility declarations... (cached) yes
checking whether the compiler supports the __inline keyword... yes
checking for mbstate_t... (cached) yes
checking for mempcpy... yes
checking whether open recognizes a trailing slash... guessing yes
checking whether program_invocation_name is declared... (cached) yes
checking whether program_invocation_short_name is declared... (cached) yes
checking for raise... yes
checking for sigprocmask... yes
checking for rawmemchr... yes
checking whether readlink signature is correct... yes
checking whether readlink handles trailing slash correctly... guessing yes
checking whether readlink truncates results correctly... guessing yes
checking for getcwd... (cached) yes
checking whether free is known to preserve errno... (cached) yes
checking for mempcpy... (cached) yes
checking for rawmemchr... (cached) yes
checking for search.h... yes
checking for tsearch... yes
checking for sigprocmask... (cached) yes
checking for ssize_t... (cached) yes
checking whether stat handles trailing slashes on files... guessing yes
checking for struct stat.st_atim.tv_nsec... yes
checking whether struct stat.st_atim is of type struct timespec... yes
checking for struct stat.st_birthtimespec.tv_nsec... no
checking for struct stat.st_birthtimensec... no
checking for struct stat.st_birthtim.tv_nsec... no
checking for working stdalign.h... yes
checking for variable-length arrays... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating lib/Makefile
config.status: creating srclib/Makefile
config.status: creating src/Makefile
config.status: creating po/Makefile.in
config.status: creating man/Makefile
config.status: creating tests/Makefile
config.status: creating include/iconv.h
config.status: creating include/iconv.h.inst
config.status: creating config.h
config.status: creating lib/config.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing po-directories commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
=== configuring in libcharset (/home/runner/work/conan-center-index/conan-center-index/recipes/libiconv/all/build-release/libcharset)
configure: running /bin/bash /home/runner/work/conan-center-index/conan-center-index/recipes/libiconv/all/src/libcharset/configure --disable-option-checking '--prefix=/' '--disable-shared' '--enable-static' '--bindir=${prefix}/bin' '--sbindir=${prefix}/bin' '--libdir=${prefix}/lib' '--includedir=${prefix}/include' '--oldincludedir=${prefix}/include' '--host=aarch64-linux-android' '--build=x86_64-linux-gnu' 'build_alias=x86_64-linux-gnu' 'host_alias=aarch64-linux-android' 'CFLAGS= -fPIC -O3' 'LDFLAGS=' 'CPPFLAGS= -DNDEBUG' --cache-file=/dev/null --srcdir=/home/runner/work/conan-center-index/conan-center-index/recipes/libiconv/all/src/libcharset
checking whether make sets $(MAKE)... yes
checking for aarch64-linux-android-gcc... no
checking for gcc... gcc
configure: WARNING: using cross tools not prefixed with host triplet
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking how to run the C preprocessor... gcc -E
checking for a BSD-compatible install... /usr/bin/install -c
checking build system type... x86_64-pc-linux-gnu
checking host system type... aarch64-unknown-linux-android
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for wchar.h... yes
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking whether _XOPEN_SOURCE should be defined... no
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... no
checking for aarch64-linux-android-dumpbin... no
checking for aarch64-linux-android-link... no
checking for dumpbin... no
checking for link... link -dump
checking the name lister (nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 3145728
checking how to convert x86_64-pc-linux-gnu file names to aarch64-unknown-linux-android format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for aarch64-linux-android-file... no
checking for file... file
checking for aarch64-linux-android-objdump... no
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for aarch64-linux-android-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for aarch64-linux-android-ar... no
checking for ar... ar
checking for archiver @FILE support... @
checking for aarch64-linux-android-strip... no
checking for strip... strip
checking for aarch64-linux-android-ranlib... no
checking for ranlib... ranlib
checking for gawk... gawk
checking command to parse nm output from gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for aarch64-linux-android-mt... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... Android linker
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking for ld... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for shared library path variable... LD_LIBRARY_PATH
checking whether to activate relocatable installation... no
checking whether the -Werror option is usable... yes
checking for simple visibility declarations... yes
checking for nl_langinfo and CODESET... yes
checking for symlink... yes
checking for working fcntl.h... cross-compiling
checking for setlocale... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating lib/Makefile
config.status: creating include/libcharset.h
config.status: creating include/libcharset.h.inst
config.status: creating include/localcharset.h
config.status: creating include/localcharset.h.inst
config.status: creating config.h
config.status: executing libtool commands
[ COMPILE-LOG-WAS-HERE ]
GITHUB WON'T LET ME UPLOAD LOG FILE THIS BIG
[ COMPILE-LOG-WAS-HERE ]
======== Testing the package: Building ========
libiconv/1.17 (test package): Calling build()
libiconv/1.17 (test package): Running CMake.configure()
libiconv/1.17 (test package): RUN: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/runner/work/conan-center-index/conan-center-index/recipes/libiconv/all/test_package" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/runner/work/conan-center-index/conan-center-index/recipes/libiconv/all/test_package"
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.
-- Using Conan toolchain: /home/runner/work/conan-center-index/conan-center-index/recipes/libiconv/all/test_package/build/clang-17-armv8-20-release/generators/conan_toolchain.cmake
-- Conan toolchain: C++ Standard 20 with extensions OFF
-- The C compiler identification is Clang 17.0.2
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/local/lib/android/sdk/ndk/26.3.11579264/toolchains/llvm/prebuilt/linux-x86_64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Conan: Target declared 'Iconv::Iconv'
-- Configuring done (5.3s)
-- Generating done (0.0s)
-- Build files have been written to: /home/runner/work/conan-center-index/conan-center-index/recipes/libiconv/all/test_package/build/clang-17-armv8-20-release
libiconv/1.17 (test package): Running CMake.build()
libiconv/1.17 (test package): RUN: cmake --build "/home/runner/work/conan-center-index/conan-center-index/recipes/libiconv/all/test_package/build/clang-17-armv8-20-release" -- -j4
[ 50%] Building C object CMakeFiles/test_package.dir/test_package.c.o
[100%] Linking C executable test_package
ld.lld: error: /home/runner/.conan2/p/b/libic2b319285d49cd/p/lib/libiconv.a(iconv.o) is incompatible with aarch64linux
ld.lld: error: /home/runner/.conan2/p/b/libic2b319285d49cd/p/lib/libiconv.a(localcharset.o) is incompatible with aarch64linux
ld.lld: error: /home/runner/.conan2/p/b/libic2b319285d49cd/p/lib/libiconv.a(relocatable.o) is incompatible with aarch64linux
ld.lld: error: /home/runner/.conan2/p/b/libic2b319285d49cd/p/lib/libcharset.a(localcharset.o) is incompatible with aarch64linux
ld.lld: error: /home/runner/.conan2/p/b/libic2b319285d49cd/p/lib/libcharset.a(relocatable-stub.o) is incompatible with aarch64linux
clang: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [CMakeFiles/test_package.dir/build.make:99: test_package] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/test_package.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
ERROR: libiconv/1.17 (test package): Error in build() method, line 22
cmake.build()
ConanException: Error 2 while executing
##[error]Process completed with exit code 1.
I have a workaround in def generate(self): which sets the correct ENV vars for the toolchain, but it's not really fun applying that workaround to each affected package.
def generate(self):
tc = AutotoolsToolchain(self)
# ...
env = tc.environment()
if cross_building(self) and self.settings.os == "Android":
# NDK binary paths need to be supplied as posixpath, not os path, even on windows
# This means no backslashes, because scripts in NDK don't like backslashes
android_ndk_home = self.conf.get("tools.android:ndk_path").replace("\\", "/")
target_host_triple = {
"armv7": "armv7a-linux-androideabi",
"armv8": "aarch64-linux-android",
"x86": "i686-linux-android",
"x86_64": "x86_64-linux-android",
}[self.settings.get_safe("arch")]
api_level = self.settings.os.get_safe("api_level")
build_machine = "{}-x86_64".format({"Linux": "linux", "Macos": "darwin","Windows": "windows"}[str(self.settings_build.os)])
toolchain = posixpath.join(android_ndk_home, "toolchains", "llvm", "prebuilt", build_machine, "bin")
if self.settings_build.os == "Windows":
executable_suffix = ".exe"
else:
executable_suffix = ""
env.define("AR", posixpath.join(toolchain, "llvm-ar" + executable_suffix))
env.define("AS", posixpath.join(toolchain, "llvm-as" + executable_suffix))
env.define("RANLIB", posixpath.join(toolchain, "llvm-ranlib" + executable_suffix))
env.define("CC", posixpath.join(toolchain, "{}{}-clang".format(target_host_triple, api_level)))
env.define("CXX", posixpath.join(toolchain, "{}{}-clang++".format(target_host_triple, api_level)))
env.define("LD", posixpath.join(toolchain, "ld" + executable_suffix))
env.define("STRIP", posixpath.join(toolchain, "llvm-strip" + executable_suffix))
tc.generate(env)
Hi @ViliusSutkus89 thanks a lot for taking the time to report the issue, we appreciate it.
We'll take a look into this as soon as we can, you might be onto something :)
I've ran into more autotools packages that I want to use, so instead of patching every single one of them, I've added the toolchain to my host profile:
{% set android_home = os.getenv("ANDROID_HOME") %}
{% set ndk_version = "26.3.11579264" %}
{% set api_level = "21" %}
[settings]
os=Android
os.api_level={{api_level}}
arch=armv8
build_type=RelWithDebInfo
compiler=clang
compiler.version=17
compiler.cppstd=20
compiler.libcxx=c++_static
[conf]
tools.android:ndk_path={{android_home}}/ndk/{{ndk_version}}
[buildenv]
AR={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
AS={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as
RANLIB={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib
CC={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android{{api_level}}-clang
CXX={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android{{api_level}}-clang++
LD={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/ld
STRIP={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip
CC and CXX are different for each abi:
CC={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi{{api_level}}-clang
CXX={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi{{api_level}}-clang++
CC={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android{{api_level}}-clang
CXX={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android{{api_level}}-clang++
CC={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android{{api_level}}-clang
CXX={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android{{api_level}}-clang++
I still count this as a workaround, not a proper solution, because I would have to add it to host profiles of every downstream user of my Android libraries.
(Corrected armv7 CC and CXX values in the previous comment)
tools.android:ndk_path is not a silver bullet.
There is indeed some magic in CMakeToolchain & MesonToolchain when tools.android:ndk_path is set:
- For CMakeToolchain, the path of CMake toolchain of Android NDK is deduced and injected
- For MesonToolchain, paths to binaries are deduced in order to fill CC, CXX & AR
Except of that there is no magic, so your profile must provide these information. It's not really an issue for conancenter, but for conan client. The confusion comes from the fact that this micro-management of Android NDK details has been implemented in some conan helpers and not in others, so there is now an expectation from users that it should work out of the box irrespective of underlying build system.
Fully agree with the part that this is a conan client, not a conan center issue. Sorry about misfiling. Haven't looked much into conan client code yet, but I assume that it would be the correct place for a proper solution, not these profile workarounds.
moving this to conan client -!
Hi @ViliusSutkus89,
Thanks again for reporting this issue!
We wanted to let you know that PR #16502 was merged for Conan 2.5.0 and introduced improvements to AutotoolsToolchain that should address this problem. In particular, it makes the toolchain respect the tools.android:ndk_path configuration and properly set the variables needed for cross-compiling to Android.
I'm closing this as solved by https://github.com/conan-io/conan/pull/16502 but please feel free to reopen or open a new issue if you have any questions.