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
[Android] Building fails with Android NDK r22 on OSX? #55412
EXEC : error : /Applications/Xcode_12.5.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/alklig/work/dotnet-runtime/runtime-bugs/src/libraries/Native/build-native.proj]
EXEC : error : /Applications/Xcode_12.5.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/alklig/work/dotnet-runtime/runtime-bugs/src/libraries/Native/build-native.proj]
EXEC : error : /Applications/Xcode_12.5.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/alklig/work/dotnet-runtime/runtime-bugs/src/libraries/Native/build-native.proj]
Build fails while linking libSystem.Native.a with:
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.
Have not tried the latest r22b 22.1.7171670 at this time.
I tried it on BigSur 11.2.3 using the 22.1.7171670 NDK 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]
@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 -
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
Activity
lambdageek commentedon Jul 9, 2021
/cc @akoeplinger @steveisok
MaximLipnin commentedon Jul 15, 2021
I tried it on BigSur 11.2.3 using the
22.1.7171670NDK version, which came with Android Studio, and got similar error:MaximLipnin commentedon Jul 15, 2021
@grendello Do you happen to know how to address this issue?
grendello commentedon Jul 15, 2021
@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.lambdageek commentedon Jul 15, 2021
@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 -
runtime/src/libraries/Native/build-native.sh
Line 92 in 385b6f3
grendello commentedon Jul 15, 2021
huh, that IS weird
[-][Android] Building fails with Android NDK r22 (on OSX?)[/-][+][Android] Building fails with Android NDK r22 on OSX?[/+]Check for CMAKE_C_COMPILER_ID not CXX
directhex commentedon Jan 24, 2022
PR to fix this is linked above.
r23 patch (tested on Linux and macOS):
Check for CMAKE_C_COMPILER_ID not CXX (#64226)