openssl: Building for Android with clang fails: "-mandroid" unknown argument
OpenSSL sets -mandroid flag when compiling for Android, which breaks building with clang, as clang does not recognize this argument.
Starting with clang 3.4 unknown compiler flags were treated as an error. This caused problems on OS X (-> Xcode 5.1) with packages failing to compile.
For some time the behavior could be disabled with -Wno-error=unused-command-line-argument-hard-error-in-future, but this option has been removed (don’t know the exact version).
Problematic OpenSSL source code:
file: Configurations/10-main.conf
lines: 876 and 916
OpenSSL 1.1.0
Android NDK r12b
Android clang version 3.8.256229 (based on LLVM 3.8.256229)
Compilation target: armv7-a
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 6
- Comments: 28 (6 by maintainers)
Yes, there are no problems using GCC.
Why I am concerned about clang support (and have opened this issue) is that GCC is going to be deprecated in Android NDK in the future. See https://android.googlesource.com/platform/ndk.git/+/master/CHANGELOG.md
Sacha wrote:
This issue is closed but problem not rejected - see #2229 “Build for Android with Clang”
Actually, I just discovered, using NDK r20, its easy to build with clang:
@yan12125, is there any way to backport the fix to the LTS versions (and perhaps an official patch file workaround until then)? We have a dependency on the LTS versions of OpenSSL for our software, and talking to the team that actually makes the software, bumping up to the non-LTS versions AND a beta version carries a lot of risk and work. We cross-compile our software with multiple other platforms (iOS, Windows, Linux, Mac), and your suggested fix makes our Android build the odd man out with what the lead quotes is a “whacko” version of OpenSSL.
I’m currently trying to compile 1.0.2o with clang btw.
FYI: This is fixed since version 1.1.1-pre3 (#5613, #5589)
Can we have this issue re-opened? It was never resolved. The only workaround for now is to use linux-generic32/64 target instead of android or to follow the accepted solution of adding a new target.
The accepted solution looks like it was to create a new android-*-clang target but this was never put in to git and as such the issue still exists. I understand work is underway in #2229
So, this is still broken (tested 1.0.2k and 1.1.0e). Any ideas of a workaround or fix on the horizon?
All android* configure options will give gcc:-mandroid
https://github.com/openssl/openssl/blob/edd689efbfa26a657a5d8310f43a4f11d29a460e/Configurations/10-main.conf#L947
Finally I can run tests on Android for my clang build. I guess this indicates everything is fine?