Repository navigation
[Android] Building fails with Android NDK r22 on OSX? #55412
Description
Activity
- ghost addeduntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on Jul 9, 2021 - removeduntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on Jul 9, 2021 Have not tried the latest r22b 22.1.7171670 at this time.
I tried it on BigSur 11.2.3 using the
22.1.7171670NDK version, which came with Android Studio, and got similar error:EXEC : error : /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: archive library: libSystem.Native.a the table of contents is empty (no object file members in the library define global symbols) [/Users/maxim/dev/runtime/src/libraries/Native/build-native.proj] EXEC : error : /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: archive library: libSystem.Security.Cryptography.Native.Android.a the table of contents is empty (no object file members in the library define global symbols) [/Users/maxim/dev/runtime/src/libraries/Native/build-native.proj] EXEC : error : /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: archive library: libSystem.IO.Compression.Native.a the table of contents is empty (no object file members in the library define global symbols) [/Users/maxim/dev/runtime/src/libraries/Native/build-native.proj] resource ILLink.Descriptors.xml in System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e(545,6): error IL2008: Could not resolve type 'System.Threading.AutoreleasePool' [/Users/maxim/dev/runtime/src/libraries/src.proj]@grendello Do you happen to know how to address this issue?
@MaximLipnin r22 moved stuff around. Also, if the build uses generated toolchains, they won't work. Build must use the toolchain found in
[NDK_ROOT]/toolchains/llvm/prebuilt/[HOST_OS-ARCH]/bin. If cmake is used, then it's best to use the Android cmake toolchain from[NDK_ROOT]/build/cmake/android.toolchain. Xcode linker won't find anything in the archive that it knows, since the object files there will be in ELF format (since they're for Linux/Android) and not the macOS Mach format. You can see how Xamarin.Android does it here and here.@grendello The weird thing is that the build of libmono works, but System.Native ends up using Xcode's ranlib. And they both use the android.toolchain.cmake file - here's System.Native, I think -
__CMakeArgs="-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_STL=none -DANDROID_NATIVE_API_LEVEL=21 $__CMakeArgs" huh, that IS weird
- changed the title
[-][Android] Building fails with Android NDK r22 (on OSX?)[/-][+][Android] Building fails with Android NDK r22 on OSX?[/+]on Jan 24, 2022 - added a commit that references this issue
on Jan 24, 2022 - ghost addedin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
on Jan 24, 2022 PR to fix this is linked above.
r23 patch (tested on Linux and macOS):
diff --git a/src/mono/mono.proj b/src/mono/mono.proj index c7febf933f5..cf0e09dff2d 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -518,7 +518,7 @@ <_Objcopy Condition="'$(Platform)' == 's390x'">s390x-linux-$(_LinuxAbi)-$(_Objcopy)</_Objcopy> <_Objcopy Condition="'$(Platform)' == 'x64'">x86_64-linux-$(_LinuxAbi)-$(_Objcopy)</_Objcopy> <_Objcopy Condition="'$(Platform)' == 'x86'">i686-linux-$(_LinuxAbi)-$(_Objcopy)</_Objcopy> - <_Objcopy Condition="'$(TargetsAndroid)' == 'true'">$(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/$(MonoToolchainPrebuiltOS)/bin/$(_Objcopy)</_Objcopy> + <_Objcopy Condition="'$(TargetsAndroid)' == 'true'">$(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/$(MonoToolchainPrebuiltOS)/bin/llvm-objcopy</_Objcopy> </PropertyGroup> <!-- test viability of objcopy command --> <Exec Condition="'$(BuildMonoAOTCrossCompilerOnly)' != 'true' and ('$(TargetsLinux)' == 'true' or '$(TargetsAndroid)' == 'true')" Command="$(_Objcopy) -V" IgnoreStandardErrorWarningFormat="true" ContinueOnError="WarnAndContinue" IgnoreExitCode="true" EchoOff="true" ConsoleToMsBuild="true">- added a commit that references this issue
on Jan 28, 2022 - ghost removedin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
on Jan 28, 2022 - ghost locked as resolved and limited conversation to collaborators
on Feb 28, 2022
export ANDROID_NDK_ROOT=/path/to/android-ndk-r22 ./build.sh --os android --arch x64 -c ReleaseExpected:
Build succeeds
Actual:
Build fails while linking
libSystem.Native.awith:Note that it's Xcode's linker that is complaining. So something about the toolchain detection is not picking up the linker from the NDK and falling back to whatever it finds on the PATH.
Possibly see #51876 which attempted to support r22 apparently did not get everything.
I have this in
ndk/source.propertiesHave not tried the latest r22b 22.1.7171670 at this time.