xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.49k stars 515 forks source link

Native linking fails for armv7s #7471

Closed praeclarum closed 5 years ago

praeclarum commented 5 years ago

My build is failing to link for arm7s.

I have reproduced this failure on my machine, Azure Dev Ops, and Bitrise. Any help would be greatly appreciated!

_CompileToNative:
  /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch @/Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/response-file.rsp 
  Compilation failed with code 1, command:
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++  -framework Security -framework SafariServices -framework StoreKit -framework OpenGLES -framework MessageUI -framework GLKit -framework CoreText -framework CoreLocation -framework CoreImage -framework CoreGraphics -framework QuartzCore -framework CloudKit -framework AudioToolbox -framework UIKit -framework Foundation -framework CoreVideo -framework AVFoundation -framework Accelerate -F /Library/Frameworks/Xamarin.iOS.framework/Versions/13.2.0.47/SDKs/MonoTouch.iphoneos.sdk/Frameworks -framework Mono -F /Library/Frameworks/Xamarin.iOS.framework/Versions/13.2.0.47/SDKs/MonoTouch.iphoneos.sdk/Frameworks -framework Xamarin -weak_framework CoreFoundation -weak_framework CFNetwork -weak_framework GSS -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/ /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/mscorlib.dll-llvm.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Drawing.Common.dll-llvm.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.dll-llvm.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/Mono.Security.dll-llvm.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Xml.dll-llvm.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Numerics.dll-llvm.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Core.dll-llvm.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/Xamarin.iOS.dll-llvm.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Net.Http.dll-llvm.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Data.dll-llvm.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Runtime.Serialization.dll-llvm.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Web.Services.dll-llvm.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Xml.Linq.dll-llvm.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/Microsoft.CSharp.dll-llvm.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/OpenTK-1.0.dll-llvm.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/mscorlib.dll.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Drawing.Common.dll.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.dll.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/Mono.Security.dll.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Xml.dll.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Numerics.dll.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Core.dll.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/Xamarin.iOS.dll.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Net.Http.dll.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Data.dll.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Runtime.Serialization.dll.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Web.Services.dll.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Xml.Linq.dll.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/Microsoft.CSharp.dll.o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/OpenTK-1.0.dll.o /Library/Frameworks/Xamarin.iOS.framework/Versions/13.2.0.47/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmono-native-compat.a -lz -liconv -gdwarf-2 -std=c++14 -I/Library/Frameworks/Xamarin.iOS.framework/Versions/13.2.0.47/SDKs/MonoTouch.iphoneos.sdk/usr/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.1.sdk -Qunused-arguments -miphoneos-version-min=9.0 -arch armv7s -shared -read_only_relocs suppress -install_name @rpath/Xamarin.Sdk.framework/Xamarin.Sdk -fapplication-extension -o /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/Xamarin.Sdk
ld : warning : ld: warning: ignoring file /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/mscorlib.dll-llvm.o, building for iOS-armv7s but attempting to link with file built for unknown-armv7 [/Users/runner/runners/2.160.1/work/1/s/CircuitTouch/iCircuit.csproj]
ld : warning : ignoring file /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.dll-llvm.o, building for iOS-armv7s but attempting to link with file built for unknown-armv7 [/Users/runner/runners/2.160.1/work/1/s/CircuitTouch/iCircuit.csproj]

...

  ignoring file /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Drawing.Common.dll-llvm.o, building for iOS-armv7s but attempting to link with file built for unknown-armv7
  Undefined symbols for architecture armv7s:
    "_Microsoft_CSharp_Microsoft_CSharp_RuntimeBinder_ArgumentObject__ctor_object_Microsoft_CSharp_RuntimeBinder_CSharpArgumentInfo_System_Type", referenced from:
        ut_1 in Microsoft.CSharp.dll.o
        _mono_aot_Microsoft_CSharpmethod_addresses in Microsoft.CSharp.dll.o
       (maybe you meant: _p_193_plt_Microsoft_CSharp_Microsoft_CSharp_RuntimeBinder_ArgumentObject__ctor_object_Microsoft_CSharp_RuntimeBinder_CSharpArgumentInfo_System_Type_llvm)
    "_Microsoft_CSharp_Microsoft_CSharp_RuntimeBinder_BinderHelper_Bind_Microsoft_CSharp_RuntimeBinder_ICSharpBinder_Microsoft_CSharp_RuntimeBinder_RuntimeBinder_System_Dynamic_DynamicMetaObject___System_Collections_Generic_IEnumerable_1_Microsoft_CSharp_RuntimeBinder_CSharpArgumentInfo_System_Dynamic_DynamicMetaObject", referenced from:
        _mono_aot_Microsoft_CSharpmethod_addresses in Microsoft.CSharp.dll.o
       (maybe you meant: _p_58_plt_Microsoft_CSharp_Microsoft_CSharp_RuntimeBinder_BinderHelper_Bind_Microsoft_CSharp_RuntimeBinder_ICSharpBinder_Microsoft_CSharp_RuntimeBinder_RuntimeBinder_System_Dynamic_DynamicMetaObject___System_Collections_Generic_IEnumerable_1_Microsoft_CSharp_RuntimeBinder_CSharpArgumentInfo_System_Dynamic_DynamicMetaObject_llvm)

....

MTOUCH : warning MT5108: The compiler output is too long, it's been limited to 1000 lines. [/Users/runner/runners/2.160.1/work/1/s/CircuitTouch/iCircuit.csproj]
MTOUCH : error MT5216: Native linking failed for '/Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/Xamarin.Sdk'. Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new [/Users/runner/runners/2.160.1/work/1/s/CircuitTouch/iCircuit.csproj]

Steps to Reproduce

  1. Build app using Azure Dev Ops

Expected Behavior

App builds

Actual Behavior

Fails to link native code

Environment

Build Logs

Armv7sBuildLog.txt

chamons commented 5 years ago

I suspect this is a duplicate of https://github.com/xamarin/xamarin-macios/issues/6787

chamons commented 5 years ago

Actually, somehow we are getting confused in archs?:

2019-11-19T23:03:59.1959500Z   ld : warning : ignoring file /Users/runner/runners/2.160.1/work/1/s/CircuitTouch/obj/iPhone/Release/mtouch-cache/armv7s/System.Xml.dll-llvm.o, building for iOS-armv7s but attempting to link with file built for unknown-armv7 [/Users/runner/runners/2.160.1/work/1/s/CircuitTouch/iCircuit.csproj]
praeclarum commented 5 years ago

@chamons Yeah that's the line that scares me too.

I should mention that the build time went up from 14mins to over 30mins. Not sure it's related however...

rolfbjarne commented 5 years ago

@praeclarum could I get access to the source code so I can try this myself?

praeclarum commented 5 years ago

@rolfbjarne I just gave you access to praeclarum/Circuit. There are submodules in External that you will need to check out. Please open iCircuit.iOS.sln

I wonder if you would consider choosing a closer milestone? This issue prevents me from updating my app.

chamons commented 5 years ago

@praeclarum - We don't use milestones in the traditional sense. "Future" just means triaged mostly, unless it is an Xcode release or require-breaking-changes.

Once we figure out what's going on, we can see if there is a work around and how impactful the fix is.

rolfbjarne commented 5 years ago

I can't reproduce, the solution builds fine for me.

@praeclarum can you enable verbose diagnostic build logs in VSMac, clean and rebuild, and attach the build output?

Verbose build log: https://docs.microsoft.com/en-us/xamarin/cross-platform/troubleshooting/questions/version-logs#verbose-build-output-logs (both the mtouch and the msbuild parts)

praeclarum commented 5 years ago

@rolfbjarne The same failure reproduces on 3 different build systems for me.

Please make sure you do a Release Device build.

I will work on a verbose build over here.

praeclarum commented 5 years ago

@rolfbjarne Here are the results of a verbose build (same error). This is on a 4th machine. I have also attached my versions and mtouch command line.

VerboseBuildLog.txt

response-file.rsp.txt

Versions.txt

rolfbjarne commented 5 years ago

It seems llc creates an armv7 object file when asked to create an armv7s object file.

Test case: https://github.com/rolfbjarne/TestApp (branch: issue-7471)

$ msbuild /p:Platform=iPhone /p:Configuration=Release /p:MtouchExtraArgs='-vvvvv' /verbosity:diag

Result:

error MT5209 : Native linking error : warning: ignoring file /Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/armv7s/testapp.exe-llvm.o, building for iOS-armv7s but attempting to link with file built for unknown-armv7 [/Users/rolf/Projects/TestApp/test-app/test-app.csproj]
error MT5209 : Native linking error : warning: ignoring file /Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/armv7s/mscorlib.dll-llvm.o, building for iOS-armv7s but attempting to link with file built for unknown-armv7 [/Users/rolf/Projects/TestApp/test-app/test-app.csproj]
error MT5209 : Native linking error : warning: ignoring file /Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/armv7s/Xamarin.iOS.dll-llvm.o, building for iOS-armv7s but attempting to link with file built for unknown-armv7 [/Users/rolf/Projects/TestApp/test-app/test-app.csproj]
error MT5209 : Native linking error : warning: ignoring file /Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/armv7s/System.dll-llvm.o, building for iOS-armv7s but attempting to link with file built for unknown-armv7 [/Users/rolf/Projects/TestApp/test-app/test-app.csproj]
MTOUCH : error MT5210: Native linking failed, undefined symbol: _mono_aot_Systeminit_method. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. [/Users/rolf/Projects/TestApp/test-app/test-app.csproj]
MTOUCH : error MT5210: Native linking failed, undefined symbol: _mono_aot_Systeminit_method_gshared_mrgctx. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. [/Users/rolf/Projects/TestApp/test-app/test-app.csproj]
MTOUCH : error MT5210: Native linking failed, undefined symbol: _mono_aot_Systeminit_method_gshared_this. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. [/Users/rolf/Projects/TestApp/test-app/test-app.csproj]
[...]

The interesting part is this:

$ MONO_PATH=/Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/3-Build /work/maccore/master/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/bin/arm-darwin-mono-sgen --debug --llvm -O=gsharedvt -O=-float32  --aot=mtriple=armv7s-ios,data-outfile=/Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/armv7s/testapp.aotdata.armv7s,static,asmonly,direct-icalls,full,nodebug,dwarfdebug,msym-dir=/Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/3-Build/Msym,llvm-path=/work/maccore/master/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/LLVM/bin/,outfile=/Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/armv7s/testapp.exe.s,llvm-outfile=/Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/armv7s/testapp.exe-llvm.o "/Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/3-Build/testapp.exe"
Mono Ahead of Time compiler - compiling assembly /Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/3-Build/testapp.exe
AOTID DBB8D53B-CA58-428E-49A5-A589A9B1B9FA
Executing opt: "/work/maccore/master/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/LLVM/bin/opt" -f -O2 -disable-tail-calls -place-safepoints -spp-all-backedges -o "/Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/armv7s/testapp.exe.s.opt.bc" "/Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/armv7s/testapp.exe.s.bc"
Executing llc: "/work/maccore/master/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/LLVM/bin/llc"  -march=arm -mattr=+v7 -exception-model=dwarf -disable-fp-elim -mattr=+vfp2,-neon,+d16 -asm-verbose=false -mtriple=armv7s-ios -disable-gnu-eh-frame -enable-mono-eh-frame -mono-eh-frame-symbol=_mono_aot_testapp_eh_frame -disable-tail-calls -relocation-model=pic -filetype=obj -o "/Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/armv7s/testapp.exe-llvm.o" "/Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/armv7s/testapp.exe.s.opt.bc"
Compiled: 25/25
Output file: '/Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/armv7s/testapp.exe.s'.
Linking symbol: '_mono_aot_module_testapp_info'.
LLVM output file: '/Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/armv7s/testapp.exe-llvm.o'.
JIT time: 2 ms, Generation time: 48 ms, Assembly+Link time: 0 ms.

$ file /Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/armv7s/testapp.exe-llvm.o
/Users/rolf/Projects/TestApp/test-app/obj/iPhone/Release/mtouch-cache/armv7s/testapp.exe-llvm.o: Mach-O object arm_v7
rolfbjarne commented 5 years ago

This regressed when we merged mono 2019-02 (https://github.com/xamarin/xamarin-macios/commit/7300cd7a2a77dc11f35a6639943de7d65fb85d05).

rolfbjarne commented 5 years ago

This issue was moved to mono/mono#17931