Bug 51634

Summary: watchOS: enabling LLVM and disabling bitcode causes native link failure
Product: iOS Reporter: Rolf Bjarne Kvinge [MSFT] <rolf>
Component: Mono runtime / AOT compilerAssignee: Zoltan Varga <vargaz>
Status: RESOLVED INVALID    
Severity: normal CC: kumpera, mono-bugs+monotouch
Priority: ---    
Version: master   
Target Milestone: (C10)   
Hardware: PC   
OS: Mac OS   
Related Links: https://bugzilla.xamarin.com/show_bug.cgi?id=52241
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: build.log

Description Rolf Bjarne Kvinge [MSFT] 2017-01-19 13:11:58 UTC
Created attachment 19395 [details]
build.log

Test case:

* Use any watchOS extension project.
* Select a release/device configuration.
* Add --bitcode=marker to the additional mtouch arguments.
* Build

Results in:

> Undefined symbols for architecture armv7k:
>   "___sync_lock_test_and_set_4", referenced from:
>       _mscorlib_System_Threading_SpinLock_ExitSlowPath_bool in mscorlib.dll.armv7k-llvm.o
>       _mscorlib_System_Threading_Tasks_Task_1_TResult_REF_TrySetResult_TResult_REF in mscorlib.dll.armv7k-llvm.o
>       _mscorlib_System_Threading_Tasks_Task_FinishStageTwo in mscorlib.dll.armv7k-llvm.o
>       _mscorlib_System_Threading_Tasks_Task_ExecuteEntry_bool in mscorlib.dll.armv7k-llvm.o
>       _mscorlib_System_Threading_Tasks_Task_CancellationCleanupLogic in mscorlib.dll.armv7k-llvm.o
>       _mscorlib_System_Threading_Tasks_Task_1_TResult_INT_TrySetResult_TResult_INT in mscorlib.dll.armv7k-llvm.o
>       _mscorlib_System_Threading_Tasks_Task_1_TResult_BOOL_TrySetResult_TResult_BOOL in mscorlib.dll.armv7k-llvm.o
>       ...
>   "___sync_fetch_and_add_4", referenced from:
>       _Xamarin_WatchOS_ObjCRuntime_BlockLiteral_CleanupBlock in Xamarin.WatchOS.dll.armv7k-llvm.o
>       _mscorlib_System_Threading_SpinLock_ContinueTryEnter_int_bool_ in mscorlib.dll.armv7k-llvm.o
>       _mscorlib_System_Threading_SpinLock_ExitSlowPath_bool in mscorlib.dll.armv7k-llvm.o
>       _mscorlib_System_Threading_Tasks_Task_AddNewChild in mscorlib.dll.armv7k-llvm.o
>       _mscorlib_System_Threading_Tasks_Task_DisregardChild in mscorlib.dll.armv7k-llvm.o
>       _mscorlib_System_Threading_Tasks_Task_NewId in mscorlib.dll.armv7k-llvm.o
>       _mscorlib_System_Threading_Tasks_Task_Finish_bool in mscorlib.dll.armv7k-llvm.o
>       ...
>   "___sync_synchronize", referenced from:
>       _Xamarin_WatchOS_ObjCRuntime_BlockLiteral_SetupBlock_System_Delegate_System_Delegate in Xamarin.WatchOS.dll.armv7k-llvm.o
>       _Xamarin_WatchOS_System_Collections_Generic_EqualityComparer_1_ObjCRuntime_MethodDescription_get_Default in Xamarin.WatchOS.dll.armv7k-llvm.o
>       _Xamarin_WatchOS_System_Collections_Generic_EqualityComparer_1_T_INTPTR_get_Default in Xamarin.WatchOS.dll.armv7k-llvm.o
>       _Xamarin_WatchOS_System_Collections_Generic_EqualityComparer_1_T_REF_get_Default in Xamarin.WatchOS.dll.armv7k-llvm.o
>       _Xamarin_WatchOS_System_Collections_Generic_EqualityComparer_1_T_INT_get_Default in Xamarin.WatchOS.dll.armv7k-llvm.o
>       _mscorlib_System_ArgumentOutOfRangeException_get_RangeMessage in mscorlib.dll.armv7k-llvm.o
>       _mscorlib_System_Collections_Generic_Comparer_1_T_REF_get_Default in mscorlib.dll.armv7k-llvm.o
>       ...
>   "___sync_val_compare_and_swap_4", referenced from:
>       _Xamarin_WatchOS_Registrar_DynamicRegistrar__GetProtocolMemberAttributesc__Iterator0_System_Collections_Generic_IEnumerable_Foundation_ProtocolMemberAttribute_GetEnumerator in Xamarin.WatchOS.dll.armv7k-llvm.o
>       _mscorlib_System_Collections_Hashtable_get_SyncRoot in mscorlib.dll.armv7k-llvm.o
>       _mscorlib_System_Globalization_CompareInfo_GetCollator in mscorlib.dll.armv7k-llvm.o
>       _mscorlib_System_Text_InternalDecoderBestFitFallbackBuffer_get_InternalSyncObject in mscorlib.dll.armv7k-llvm.o
>       _mscorlib_System_Text_DecoderFallback_get_InternalSyncObject in mscorlib.dll.armv7k-llvm.o
>       _mscorlib_System_Text_InternalEncoderBestFitFallbackBuffer_get_InternalSyncObject in mscorlib.dll.armv7k-llvm.o
>       _mscorlib_System_Text_EncoderFallback_get_InternalSyncObject in mscorlib.dll.armv7k-llvm.o
Comment 1 Zoltan Varga 2017-02-01 21:13:33 UTC
The problem seems to be that when we use --bitcode=marker, we are using our internal llvm to compile the .bc files instead of clang, and the generated code doesn't seem to link.
Comment 2 Zoltan Varga 2017-02-01 21:22:06 UTC
I.e. we are still using the our 2014 fork of llvm which might not be able to generate code which really works on watchos.
Comment 3 Zoltan Varga 2017-02-02 17:47:48 UTC
So I don't think we should/could support this currently.
Comment 4 Rodrigo Kumpera 2017-02-07 18:44:05 UTC
As Zoltan said, we won't support that configuration