You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] r22 appears to break cmake compiler and OS detection on Windows #1427
Xamarin.Android has been using Android SDK's cmake for quite a while now and
until NDK r22 everything has worked as expected. With r22 the Unix (Linux and macOS) builds still work fine, however the Windows build breaks because cmake is not able to properly detect the C/C++ compilers (please see the attached error and output logs). Not only that, it appears that the WIN32 cmake variable is not set at all, instead MINGW is set.
We normally use cmake from the SDK (version 3.10.2), but I also tried with cmake 3.18 shipped with VS2019, to the same effect. Our CMakeLists.txt, PR to switch XA to NDK r22, and a sample invocation line:
Just a note regarding the command above. I do know that r22 doesn't have support for API16 (at least the runtime libs for it are absent, clang wrapper scripts are still there), but it's not relevant in this case - the error appears to be unrelated at least. However, for API21 build cmake still mis-detects the system as MINGW. Please see the logs attached below - the libraries mentioned in the error log are used only if MINGW is detected.
I think the error: unknown target CPU 'armv7-a' error is a red herring and that, ultimately, the problem is the misdetection of the system as MINGW. Looking further at the CMakeOutput.log attached in the OP, it gets the correct compiler options:
Detecting C compiler ABI info compiled with the following output:
Change Dir: C:/Users/Grendel/vc/xamarin-android/src/monodroid/obj/Debug/armeabi-v7a-Debug/CMakeFiles/CMakeTmp
Run Build Command:"C:\Users\Grendel\android-toolchain\sdk\cmake\3.10.2.4988404\bin\ninja" "cmTC_22a78"
[1/2] Building C object CMakeFiles/cmTC_22a78.dir/CMakeCCompilerABI.c.o
[2/2] Linking C executable cmTC_22a78
Android (6875598, based on r399163b) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)
Target: armv7-none-linux-android16
Thread model: posix
InstalledDir: C:\Users\Grendel\android-toolchain\ndk\toolchains\llvm\prebuilt\windows-x86_64\bin
Found candidate GCC installation: C:/Users/Grendel/android-toolchain/ndk/toolchains/llvm/prebuilt/windows-x86_64/lib/gcc/arm-linux-androideabi\4.9.x
Selected GCC installation: C:/Users/Grendel/android-toolchain/ndk/toolchains/llvm/prebuilt/windows-x86_64/lib/gcc/arm-linux-androideabi/4.9.x
Candidate multilib: thumb;@mthumb
Candidate multilib: armv7-a;@march=armv7-a
Candidate multilib: armv7-a/thumb;@march=armv7-a@mthumb
Candidate multilib: .;
Selected multilib: armv7-a/thumb;@march=armv7-a@mthumb
However, I added the following snippet to our CMakeLists.txt:
-- MINGW set
Called from: [1] src/monodroid/CMakeLists.txt
CMake Error at CMakeLists.txt:93 (message):
Please set the MINGW_DEPENDENCIES_ROOT_DIR variable on command line
(-DMINGW_DEPENDENCIES_ROOT_DIR=PATH)
Seems it is not trivial to build Xamarin.Android. Do you have a smaller repro case?
Also can you try to copy r21 android.toolchain.cmake to r22 to see how it does? One of the new changes in r22 is aosp/1413029. Maybe it affects compiler detection somehow?
CMake generates its files in subdirectories of src/monodroid/obj/{Debug,Release}, you can rerun cmake in any of those with the options needed
Also can you try to copy r21 android.toolchain.cmake to r22 to see how it does? One of the new changes in r22 is aosp/1413029. Maybe it affects compiler detection somehow?
I don't use Windows locally, but I'll try to test that ASAP.
Seems it is not trivial to build Xamarin.Android. Do you have a smaller repro case?
Also can you try to copy r21 android.toolchain.cmake to r22 to see how it does? One of the new changes in r22 is aosp/1413029. Maybe it affects compiler detection somehow?
The problem seems fixed after replacing android.toolchain.cmake file.
Seems it is not trivial to build Xamarin.Android. Do you have a smaller repro case?
Also can you try to copy r21 android.toolchain.cmake to r22 to see how it does? One of the new changes in r22 is aosp/1413029. Maybe it affects compiler detection somehow?
I've just tested it on CI and it does fix the detection
Update the NDK to 22.1? Yes, which is when the new build warnings begun to show up.
Update cmake? No, because cmake 3.10 is the latest version that is possible to use with the SDK/NDK. Which, then, is the very cause of this warning because the NDK 22.1 really wants cmake 3.19 or newer. You should make it possible to comply with the raised requirements before you raise them ☺
Yes, I know. But you seem to not have read my initial comment
here, which says: the fix now causes tons of build warnings
in every single project.
(Incidentally even in whose where 22.0 worked fine, e.g. on GNU/Linux.)
As for getting new versions of CMake into the SDK, you're talking to
the wrong people. We only maintain the NDK.
Doesn’t mean it’s right to release a new version of the NDK that
effectively requires something that’s not available yet.
bye,
//mirabilos
--
Sometimes they [people] care too much: pretty printers [and syntax highligh-
ting, d.A.] mechanically produce pretty output that accentuates irrelevant
detail in the program, which is as sensible as putting all the prepositions
in English text in bold font. -- Rob Pike in "Notes on Programming in C"
Yes, I know. But you seem to not have read my initial comment
here, which says: the fix now causes tons of build warnings
in every single project.
Oh! You didn't say the fix caused this, you just said "this", which I took to mean "this bug". That makes sense now.
Doesn’t mean it’s right to release a new version of the NDK that
effectively requires something that’s not available yet.
Nothing is being required here. It's a warning, not an error. That warning is there for a good reason. We used to have bugs filed often for things that happened as a result of compiler ID bypass. The warning is there to communicate "yeah, nothing the NDK can do about it, you need to use a newer version of CMake."
The change in r22b was to raise the minimum version of CMake that was required for using the built-in compiler ID behavior, because prior to 3.19 there were bugs (that's the original report here). We can't revert this to fix the warnings without breaking builds.
Activity
grendello commentedon Jan 11, 2021
Just a note regarding the command above. I do know that r22 doesn't have support for API16 (at least the runtime libs for it are absent, clang wrapper scripts are still there), but it's not relevant in this case - the error appears to be unrelated at least. However, for API21 build
cmakestill mis-detects the system as MINGW. Please see the logs attached below - the libraries mentioned in the error log are used only ifMINGWis detected.CMakeError.log.txt
CMakeOutput.log.txt
DanAlbert commentedon Jan 11, 2021
Looks like CMake hasn't set the
-targetfor Clang?Our QA will have tested Windows before we shipped though. We probably need a repro case here.
DanAlbert commentedon Jan 11, 2021
Assigning to hhb in case he has any ideas.
grendello commentedon Jan 12, 2021
It seems as if ARM support wasn't there at all, note this error:
And look at the list of supported CPUs, it contains only x86.
My bad, looked in a wrong directory (aarch64) :)
grendello commentedon Jan 12, 2021
I think the
error: unknown target CPU 'armv7-a'error is a red herring and that, ultimately, the problem is the misdetection of the system asMINGW. Looking further at theCMakeOutput.logattached in the OP, it gets the correct compiler options:However, I added the following snippet to our
CMakeLists.txt:And the output is:
fuchg3 commentedon Jan 13, 2021
It seems cmake 3.19.2 could detect the right platform. That's my temporary workaround.
hhb commentedon Jan 13, 2021
You probably are using cmake's NDK support instead of NDK toolchain file. In that case CMake >= 3.19 is required for NDK r22.
(I'm investing why MINGW is used there in this issue
hhb commentedon Jan 19, 2021
Seems it is not trivial to build Xamarin.Android. Do you have a smaller repro case?
Also can you try to copy r21
android.toolchain.cmaketo r22 to see how it does? One of the new changes in r22 is aosp/1413029. Maybe it affects compiler detection somehow?grendello commentedon Jan 20, 2021
You don't really need to build it all. On Windows (from VS prompt), after cloning and restoring submodules, you need the following steps:
msbuild /t:Prepare Xamarin.Android.slnsrc/monodroiddirectory and runmsbuild /bl(the/blwill create a detailed binary log,msbuild.binlog, which you can replay either withmsbuild /v:diag msbuild.binlogor with https://msbuildlog.com/)src/monodroid/obj/{Debug,Release}, you can rerun cmake in any of those with the options neededI don't use Windows locally, but I'll try to test that ASAP.
fuchg3 commentedon Jan 20, 2021
The problem seems fixed after replacing
android.toolchain.cmakefile.grendello commentedon Jan 20, 2021
@fuchg3 thanks, you saved me from a few hours of installing software :)
grendello commentedon Jan 20, 2021
I've just tested it on CI and it does fix the detection
[NDK] Locate and select only compatible NDK versions
10 remaining items
Update NDK to r22b
Bump to NDK r22b (#5780)
mirabilos commentedon Apr 8, 2021
This causes lots of warnings with every build now; cmake 3.10 is the latest the Android SDK/NDK offers.
DanAlbert commentedon Apr 8, 2021
Did you update? As far as we know this is fixed.
mirabilos commentedon Apr 8, 2021
Update what?
Update the NDK to 22.1? Yes, which is when the new build warnings begun to show up.
Update cmake? No, because cmake 3.10 is the latest version that is possible to use with the SDK/NDK. Which, then, is the very cause of this warning because the NDK 22.1 really wants cmake 3.19 or newer. You should make it possible to comply with the raised requirements before you raise them ☺
DanAlbert commentedon Apr 8, 2021
The fix does not require CMake 3.19. The fix was specifically to make this work with versions of CMake earlier than 3.19.
We do not have enough information to investigate further. We need a repro case.
As for getting new versions of CMake into the SDK, you're talking to the wrong people. We only maintain the NDK. File a bug against Studio.
enh-google commentedon Apr 8, 2021
https://issuetracker.google.com/177245495 seems to be the existing public bug. looks like they have 3.18 in the beta channel.
mirabilos commentedon Apr 8, 2021
DanAlbert commentedon Apr 8, 2021
Oh! You didn't say the fix caused this, you just said "this", which I took to mean "this bug". That makes sense now.
Nothing is being required here. It's a warning, not an error. That warning is there for a good reason. We used to have bugs filed often for things that happened as a result of compiler ID bypass. The warning is there to communicate "yeah, nothing the NDK can do about it, you need to use a newer version of CMake."
The change in r22b was to raise the minimum version of CMake that was required for using the built-in compiler ID behavior, because prior to 3.19 there were bugs (that's the original report here). We can't revert this to fix the warnings without breaking builds.
FWIW you don't need to wait for the SDK to get 3.20. You can use any version of CMake you want: https://developer.android.com/studio/projects/install-ndk#vanilla_cmake.
mirabilos commentedon Apr 10, 2021
[MonoVM] support building with Android NDK r22
[MonoVM] support building with Android NDK r22 (#51876)
mirabilos commentedon Jun 6, 2021
[NDK] Locate and select only compatible NDK versions (#103)