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

[suggestion] AutotoolsToolchain should avoid Android CMD compiler wrapper scripts #17441

Closed
1 task done
mhthies opened this issue Dec 10, 2024 · 1 comment · Fixed by #17470
Closed
1 task done

[suggestion] AutotoolsToolchain should avoid Android CMD compiler wrapper scripts #17441

mhthies opened this issue Dec 10, 2024 · 1 comment · Fixed by #17470
Assignees
Milestone

Comments

@mhthies
Copy link

mhthies commented Dec 10, 2024

What is your suggestion?

The AutotoolsToolchain in Conan 2.x automatically choses compilers when crossbuilding on Windows for Android, based on the tools.android:ndk_path conf variable:

"CC": os.path.join(ndk_bin, f"{android_target}{android_api_level}-clang{ext}"),

See also #13443.
This overrides the CC, CXX, etc. environment variables set in the [buildenv] of the Conan profile.

However, this automatism uses the .cmd wrapper scripts, provided by Android NDK, for the compiler, e.g. .../toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android31-clang.cmd. These CMD scripts cause errors when building certain packages.
For example, building openssl/1.1.1 using the recipe from conan-center-index fails in the linking stage with a "command line to long" error due to CMD's low command line length limit.

This could be avoided by using the bash wrapper script, which is also included in the Android NDK, instead of the CMD wrapper script for the compiler. Note, that this can only be reliably used on Windows when a Conan package that is build in a bash shell, i.e. the package recipe declares win_bash = True.

Still, I assume that this applies to many Conan packages which are built with Autotools and thus I propose to chose the compiler file extension based on this flag on Windows.

As an alternative, the compiler variables could be set to the bare clang.exe/clang++.exe executables and the --target parameter, which is otherwise added by the CMD/bash wrapper script, be added to the cflags and cxxflags, instead.

At our company, we have currently added a workaround in the openssl/1.x.x recipe to replace the compiler in the AutotoolsToolchain environment variables in order to make the build work.

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded
Copy link
Member

This has been closed by #17470, that will prioritize Conan defined buildenv (from profiles or from tool-requires). So if the environment define CC/CXX/... variables, then the AutotoolsToolchain will not automatically deduce and define it from the ndk_path. This will be part of Conan 2.11 to be released asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants