Skip to content

.NET 8 RC1 fails to NativeAOT compile when targeting ios-arm64 #91997

@lemonmojo

Description

@lemonmojo

Description

Up until .NET RC1, NativeAOT compilation worked out of the box when targeting ios-arm64.
This requires adding <PublishAotUsingRuntimePack>true</PublishAotUsingRuntimePack> and <LinkerArg Include="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk" /> to the csproj.
Everything else is pretty much standard fare.

Now, since RC1, dotnet publish fails because of linking errors in libicuuc.a related to C++.

As a workaround, one can add <LinkerArg Include="-lc++" /> to the csproj like in the example below.

Reproduction Steps

Running dotnet publish against the following example csproj works fine because -lc++ was re-added using a LinkerArg flag. Removing this line makes the build fail.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
    <PublishAOT>true</PublishAOT>

    <!-- TODO: Temporary workaround for iOS/iOS Simulator support -->
    <PublishAotUsingRuntimePack>true</PublishAotUsingRuntimePack>
  </PropertyGroup>

  <ItemGroup>
    <!-- TODO: Temporary workaround for iOS support -->
    <LinkerArg Include="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk" />

    <!-- TODO: Temporary workaround for .NET 8 RC1 which seems to have removed -lc++ from its linker flags -->
    <LinkerArg Include="-lc++" />
  </ItemGroup>
</Project>

Expected behavior

Compiles out of the box.

Actual behavior

Does not compile without adding <LinkerArg Include="-lc++" />.

Regression?

It did work in all .NET 8 previews until RC1.

Known Workarounds

Adding <LinkerArg Include="-lc++" /> to the csproj.

Configuration

.NET 8.0.100-rc.1.23455.8

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions