microsoftgraph / msgraph-sdk-dotnet

Microsoft Graph Client Library for .NET!
https://graph.microsoft.com
Other
690 stars 246 forks source link

`clang` error compiling for iOS #2617

Open MartinZikmund opened 1 month ago

MartinZikmund commented 1 month ago

Describe the bug

Trying to build an iOS app using Microsoft.Graph library fails with the following:

clang exited with code 1:
/Users/mzikmund/Library/Caches/Xamarin/mtbs/builds/iOSTabbedApp3/c545e9e939b879654bbf76c0344987a782d645ee60de988037adf42061544d17/obj/Debug/net8.0-ios/iossimulator-arm64/nativelibraries/aot-output/arm64/Microsoft.Graph.dll.s:73678288:1: error: addend too big for relocation
adrp x16, mono_aot_Microsoft_Graph_got@PAGE+8388608
^
/Users/mzikmund/Library/Caches/Xamarin/mtbs/builds/iOSTabbedApp3/c545e9e939b879654bbf76c0344987a782d645ee60de988037adf42061544d17/obj/Debug/net8.0-ios/iossimulator-arm64/nativelibraries/aot-output/arm64/Microsoft.Graph.dll.s:73678293:1: error: addend too big for relocation
adrp x16, mono_aot_Microsoft_Graph_got@PAGE+8388608
^
/Users/mzikmund/Library/Caches/Xamarin/mtbs/builds/iOSTabbedApp3/c545e9e939b879654bbf76c0344987a782d645ee60de988037adf42061544d17/obj/Debug/net8.0-ios/iossimulator-arm64/nativelibraries/aot-output/arm64/Microsoft.Graph.dll.s:73678332:1: error: addend too big for relocation
adrp x16, mono_aot_Microsoft_Graph_got@PAGE+8388608
^

Expected behavior

Should not error out.

How to reproduce

Can be easily reproduced on a blank iOS app that references and uses Microsoft Graph - see this repro:

iOSTabbedApp3.zip

  1. Open the .sln in VS2022
  2. Connect to remote Mac (mine is a M2-based Mac)
  3. Try to run the on an iOS Simulator

SDK Version

5.56.0

Latest version known to work for scenario above?

N/A

Known Workarounds

None

Debug output

Click to expand log ``` ```

Configuration

Microsoft Visual Studio Enterprise 2022 Version 17.11.0 VisualStudio.17.Release/17.11.0+35208.52

Windows 11 26120 macOS Sonoma 14.5 9 (Apple M2)

Other information

No response

andrueastman commented 1 month ago

Thanks for raising this @MartinZikmund

I notice in you csproj you have

<TrimMode Condition="'$(Configuration)' == 'Release'">full</TrimMode>

Any chance you can confirm if the issue still occurs in release mode as well?

MartinZikmund commented 2 weeks ago

@andrueastman Sorry for the delay, had other unrelated iOS build issues. I can confirm that in Release mode the app builds without errors. Still, the Debug mode fails with the error above. Can you please reopen the issue to keep it tracked?

andrueastman commented 2 weeks ago

To confirm here, is there a reason not to enable the trim mode in debug as well?

<TrimMode">full</TrimMode>

The alternative would be to use partial trimming and opt in the graph lib. https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options?pivots=dotnet-8-0#trimming-granularity

Due to the large surface of API and SDK enabling trimming will give a smaller binary for your scenario focussing on the paths you are calling/using.

MartinZikmund commented 2 weeks ago

There is no reason in particular, just that by default the iOS app/MAUI app csproj will not have it enabled for Debug, which means when user installs MS Graph library they will need to know to make this additional step. We offer MS Graph as part of our addons in Uno Platform and this would mean we need to provide additional documentation for users, as they will otherwise hit this error and will most likely assume the problem is caused by our framework rather by this. In this manner it would be more user friendly if there was no error out of the box