Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker warnings on OSX #956

Closed
MichalStrehovsky opened this issue Apr 13, 2021 · 6 comments
Closed

Linker warnings on OSX #956

MichalStrehovsky opened this issue Apr 13, 2021 · 6 comments
Labels
area-NativeAOT-coreclr .NET runtime optimized for ahead of time compilation help wanted Extra attention is needed

Comments

@MichalStrehovsky
Copy link
Member

We get 3 kinds of warnings:

ld : error : could not create compact unwind for _System_Net_Http_System_Net_Http_Headers_QPackStaticTable___cctor: stack subq instruction is too different from dwarf stack size [/Users/runner/work/1/s/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj]
ld : error : can't parse dwarf compilation unit info in /Users/runner/work/1/s/artifacts/obj/System.Runtime.Tests/net6.0-Unix-Release/native/System.Runtime.Tests.o [/Users/runner/work/1/s/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj]
ld : error : linker symbol '$ld$hide$os10.4$__Unwind_Backtrace' hides a non-existent symbol '__Unwind_Backtrace' [/Users/runner/work/1/s/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj]
  1. My theory was that disabling compact unwind generation in the linker would fix the first. It broke exception handling. There's an option to keep dwarf unwind. Maybe we need to set that.
  2. My theory based on seeing lld64 source code was that we're generating DWARF that is too new (Apple is typically a decade in the past when it comes to computer standards and seem to only support DWARF 3)
  3. __Unwind_Backtrace should have been defined by libSystem that we drag in because of the dependency on libm. But maybe not?

Anyways, I burned too much time on this and I personally do not care about Apple. This is up for grabs.

@MichalStrehovsky MichalStrehovsky added help wanted Extra attention is needed area-NativeAOT-coreclr .NET runtime optimized for ahead of time compilation labels Apr 13, 2021
@kant2002
Copy link
Contributor

Where this is happens ?

@MichalStrehovsky
Copy link
Member Author

Where this is happens ?

On macOS. I think even a hello world will hit a bunch of these.

@miried
Copy link

miried commented Sep 9, 2021

I can confirm these warnings on macos, triggered by any F# app that I compile. Even a standard "hello world". The same code will compile fine on linux.

@filipnavara
Copy link
Member

filipnavara commented Sep 10, 2022

can't parse dwarf compilation unit info

There's a bug in the LLVM MC code for the implicit DWARF generation. The debug information should use section relative offsets with no relocations. The Mach-O backend ensures that in the relocation emitting code by looking up MCFragment and then its atom to find the section defining symbol which is then used as the relocation target. However, due to the way the Finish call sequence is structured in regards to the DWARF info generation it happens that the step where atoms are assigned to fragments is run before the DWARF generation. The relocation code then fails to lookup the section defining symbols and emits absolute addresses instead of relative ones.

Long story short, dotnet/llvm-project#269 switched objwriter to fully custom DWARF generation that doesn't suffer from the same problem. It no longer calls OutContext->setGenDwarfForAssembly(true); so the implicit DWARF generation doesn't take place and offsets in the object file are now correct.

@filipnavara
Copy link
Member

ld : error : could not create compact unwind for _System_Net_Http_System_Net_Http_Headers_QPackStaticTable___cctor: stack subq instruction is too different from dwarf stack size

This is likely solved now by switch to DWARF CFI across the board. The ld64 and LLVM algorithm for generating compact unwinding codes cannot convert prologs that do __chkstk pattern.

@filipnavara
Copy link
Member

Should we close this now? macOS support works as of .NET 8 RTM.

@jkotas jkotas closed this as completed Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NativeAOT-coreclr .NET runtime optimized for ahead of time compilation help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants