-
Notifications
You must be signed in to change notification settings - Fork 257
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
[Bug]: WSL1 NDK r25 clang-14: cannot execute binary file: Exec format error #1755
Comments
Adding @kongy since I believe this is due to our use of BOLT to optimize the Linux binaries. There is an incompatibility with WSL1, however our BOLT-ed binaries have been confirmed to work previously with WSL2. Can you switch to WSL2 instead? While we don't officially support either of the WSL implementations, we will try to help as much as we can, but I don't think that we can force Microsoft to fix this breakage on WSL1. We also would not want to deoptimize our actual supported Linux binaries, so I unfortunately don't know that there is much more Android can do for this case. |
But while we have you here, I'm curious to know why you're using the Linux NDK via WSL instead of just using the Windows NDK, or the Linux NDK on Linux. We don't support that use case because we don't have the resources to do so, but I've also never argued that we should have those resources (not that that would necessarily change anything) because we haven't understood the motivation for doing so. AIUI the main reason to use WSL is for when there is no native Windows option. |
Cons of Windows NDK:
I still think it's a major oversight it's not listed anywhere in the changelog or README that it doesn't officially support (or in this case breaks in) WSL given its relative popularity and its flexibility than a Linux VM. Let's see if I can persuade my IT dept to enable WSL2. Not sure if it interferes with some of the IT policies. I think it's fine to have a discussion every now and then on WSL usage here. Otherwise its a ghost town over at Microsoft's thread and users have to fend for themselves. 😅 |
Huh. I would've expected the NDK's clang to work in either WSL1 or WSL2. The repro steps from microsoft/WSL#8681 are:
Maybe try extracting the NDK into |
Seems like a really widespread issue: microsoft/WSL#8219 Interestingly per microsoft/WSL#8219 (comment), doing this works: $ /lib64/ld-linux-x86-64.so.2 android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/clang-14 -v
Android (8490178, based on r450784d) clang version 14.0.6 (https://android.googlesource.com/toolchain/llvm-project 4c603efb0cca074e9238af8b4106c30add4418f6)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/jylo/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin |
Why not just use Linux? |
clang-14 has a PT_LOAD segment with a 2MiB p_align (it's the unusual one second from the last). It looks like it was produced by BOLT?
|
probably for transparent huge pages? looks like there's a |
build boost and openssl use wsl1 is simple and fast; like build openssl, just: ./Configure android-arm64 -D__ANDROID_API__=26 --prefix="/mnt/c/cpps/libs/openssl/openssl-3.0.5/android/arm64-v8a" --openssldir="/mnt/c/cpps/libs/openssl/openssl-3.0.5/android/arm64-v8a" && make -j4 && make install make clean && ./Configure android-arm -D__ANDROID_API__=26 --prefix="/mnt/c/cpps/libs/openssl/openssl-3.0.5/android/armeabi-v7a" --openssldir="/mnt/c/cpps/libs/openssl/openssl-3.0.5/android/armeabi-v7a" && make -j4 && make install make clean && ./Configure android-x86 -D__ANDROID_API__=26 --prefix="/mnt/c/cpps/libs/openssl/openssl-3.0.5/android/x86" --openssldir="/mnt/c/cpps/libs/openssl/openssl-3.0.5/android/x86" && make -j4 && make install make clean && ./Configure android-x86_64 -D__ANDROID_API__=26 --prefix="/mnt/c/cpps/libs/openssl/openssl-3.0.5/android/x86_64" --openssldir="/mnt/c/cpps/libs/openssl/openssl-3.0.5/android/x86_64" && make -j4 && make install other cases, like build ffmpeg also use wsl1: wsl1 yes.... |
Okay but why not just use Linux? |
emmm, normal times: window; |
My question was why? A subset of the options for you are:
1, 2, and 5 are supported. I'm asking why 3 is your preferred option. 2 seems like the easiest option to me. If you really need WSL, why not option 4? 4 is also not supported by us, but MS supports it better aiui. Why am I asking? Because each new host environment is very expensive for us to support. If you want us to support WSL1 officially, I need to be able to tell leadership why that use case is more deserving of headcount than, say, linux/arm64. |
https://maven.google.com/web/index.html?q=openssl#com.android.ndk.thirdparty:openssl is a prebuilt openssl, btw. That is option 5. |
https://developer.android.com/studio/build/dependencies#native-dependencies-with-agp has the docs for how to use that if you're using AGP. If you're not using AGP, it's a bit of a wild ride atm, but it should be quite easy to integrate into whatever build system you're using: https://google.github.io/prefab/example-workflow.html |
Forgot to close this. As mentioned, this is not a supported configuration. We're still here to answer questions but a fix is not something that's being tracked. |
FWIW, the discussion of "should we support WSL[12]?" is still ongoing internally. If the answer to that is yes, it'll probably a lower tier of support than can be expected of linux/darwin/windows (wouldn't block a release, but we'd fix issues going forward and have QA do some rudimentary testing so we'd know to add a warning to the changelog), but would mean that things like this get fixed. The things I need to know to make that happen are the questions I've asked above:
As I said above, supporting additional platforms comes at a pretty high cost to us and we're already spread quite thin, so before we can support a new platform we need to be sure we understand what the benefits are as compared to its alternatives. |
I created this issue mainly to make NDK folks aware that there are people have this kind of use case in the public. I leave it to others to defend their use of WSL1. You may also want to change https://developer.android.com/ndk/guides/other_build_systems#autoconf to explicitly say WSL2 and not the vaguely WSL or maybe outright remove it. Better yet have a NDK release note that specifically mentions "WSL1 and WSL2 are not officially supported" and not for others to Google Search their way and end up here. |
Yes, we saw yesterday that that was worded poorly. It very much reads like "we recommend WSL", whereas it ought to read "if it's literally your only option, try WSL, but YMMV". I'll hopefully find some time to update that soon, but I'm not optimistic. |
I'm just stumped as to how to enumerate all the environments we don't support, because I don't even know how to enumerate all environments. We support exactly 3: GNU/Linux, Windows, and macOS. Everything not in the list on our download page is not supported. |
not must support, just support is happy; i build boost for android use my script: https://github.com/gamefunc/Simple_Build_Android_Boost so if not support, i wiil use vmware or 2; build gradle i use, but just set : buildToolsVersion, ndkVersion, ndk{abiFilters}, externalNativeBuild{cmake{version}}; i main cpp/python3/js, java not good so just code a gui and button listen ; private FrameLayout main_window; private widgets; get_display_width_height() / n to set main_win \ widget x/y/h/w; other in cpp, cmake: if(ANDROID) xx elseif(WIN32) xxx elseif(UNIX) xxx endif(); cpp20 very python3, i like it; i code in vscode, android_studio just build a app; |
Fine by me. My daily job as a tester is to get a black and white written statement on what is supported and what is not supported (and not deduce from what is supported) from devs so that we all agree on the scope. Here are some of my perspective on Windows and WSL (maybe untrue): However if you search https://github.com/microsoft/WSL/issues, you will definitely see some unhappy users switching from WSL2 back to WSL1 and their reasonings |
i've sent out https://critique.corp.google.com/cl/471265875 (internal URL for googlers only) to improve the text on https://developer.android.com/ndk/guides/other_build_systems#autoconf . |
workaround: |
It runs but I get the following error:
|
Description
microsoft/WSL#8681
This is a regression in NDK r25. It is still reproducible with NDK r25b.
I have not tested NDK r24.
NDK r23c works fine on WSL1.
Upstream bug
No response
Commit to cherry-pick
No response
Affected versions
r25
Canary version
No response
Host OS
Windows
Host OS version
Windows 10 version 21H2
Affected ABIs
armeabi-v7a, arm64-v8a, x86, x86_64
The text was updated successfully, but these errors were encountered: