dotnet / dotnet/macios

Native linker warnings when building without Xcode classic linker

Open
#24,045 1 comment 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
C#
Stars
2.9k
Forks
576
Avg merge
2d 13h
Merged PRs (30d)
96

Description

### Apple platform

iOS

### Framework version

net9.0-*

### Affected platform version

net9.0-ios workload version 26.0.9752

### Description

When building a project with the new Xcode linker (not the classic linker), there are some `mixed ObjC` warnings that occur during the `LinkNativeCode` phase.

### Steps to Reproduce

1. `dotnet new ios -o LinkerWarnings`
2. `dotnet build LinkerWarnings.csproj -c Debug -f net9.0-ios -r iossimulator-arm64 --self-contained -v d`

Note the following build warnings:

```
ld: warning: ignoring duplicate libraries: '-lSystem.Globalization.Native', '-lSystem.IO.Compression.Native', '-lSystem.Native', '-lSystem.Net.Security.Native', '-lSystem.Security.Cryptography.Native.Apple', '-lcompression', '-lmono-component-debugger', '-lmono-component-diagnostics_tracing', '-lmono-component-hot_reload', '-lmono-component-marshal-ilgen', '-lmonosgen-2.0', '-lxamarin-dotnet-debug'
ld: warning: mixed ObjC ABI, /usr/local/share/dotnet/packs/Microsoft.iOS.Runtime.iossimulator-arm64.net9.0_26.0/26.0.9752/runtimes/iossimulator-arm64/native/Microsoft.iOS.registrar.a compiled with category class properties
ld: warning: mixed ObjC ABI, /Users/todd.diehl/code/LinkerWarnings/LinkerWarnings/obj/Debug/net9.0-ios/iossimulator-arm64/nativelibraries/main.arm64.o compiled with category class properties
```

Minimal repro: https://github.com/tdiehl/LinkerWarning

### Did you find any workaround?

Build with the classic linker by adding the following to the `.csproj` file.

```

$(MtouchExtraArgs) -gcc_flags "-Xlinker -ld_classic"


<_MainLinkerFlags Include="-ld_classic" />

```

### Build logs

[msbuild.binlog.zip](https://github.com/user-attachments/files/22980775/msbuild.binlog.zip)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.