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

Build fails with 'can not encode offset '0x........' in resulting scattered relocation' #6787

Closed
rolfbjarne opened this issue Aug 16, 2019 · 6 comments
Labels
documentation The issue or pull request is about documentation iOS Issues affecting Xamarin.iOS
Milestone

Comments

@rolfbjarne
Copy link
Member

rolfbjarne commented Aug 16, 2019

Symptom

Thousands of build errors like this:

error GDC116A36: can not encode offset '0x100018C' in resulting scattered relocation.

Another variation is that the build never seem to finish (due to the thousands of build errors overloading various parts of the build).

Cause

This can occur when building for 32-bit arm architectures (armv7 and/or armv7s), and the AOT compiler produces native code that's too big for the 32-bit Mach-O file format to handle.

Potential workarounds

  • Only build for ARM64. This can be changed in the project's iOS Build options, and it's by far the easiest solution. Apple is on its way to removing the 32-bit ARM architectures, so this will eventually be the final solution too.
  • Enable the linker for all assemblies (or review any custom linker arguments, such as linker definition files, to avoid skipping the linker). The idea is for the linker to remove more unused code, and if enough unused code is removed, then the size limit won't be reached.
  • Disable debugging. Debugging support makes the AOT compiler produce more code, which can be enough to hit the limit. This can be changed in the project's iOS Debug options (but the downside is of course that debugging won't work).
  • Enable LLVM. The LLVM compiler can sometimes produce smaller code, which can be enough to get below the size limit. The downside is that debugging won't work, and the build will be much slower.
  • There's usually a particularly big assembly that's causing problems; sometimes it can help to split such assemblies into smaller assemblies. This can be a significant amount of work though, and there's no guarantee it would eventually work.
  • Remove code from the app that isn't needed/used.

References

#6125, #5815, #5810, #5512, #6345, #6526
https://bugzilla.xamarin.com/show_bug.cgi?id=1102

@rolfbjarne rolfbjarne added iOS Issues affecting Xamarin.iOS documentation The issue or pull request is about documentation labels Aug 16, 2019
@rolfbjarne rolfbjarne added this to the Future milestone Aug 16, 2019
@spouliot
Copy link
Contributor

There are a few recent issue like https://developercommunity.visualstudio.com/content/problem/683945/mtouch-hangs-after-upgrading-to-ios-12140114.html where the 32bits part of the build looks hung - but, if very patient, we see 25k+ errors from Apple's ld linker.

That looks like a new twist on this old issue.

@taublast
Copy link

Why this HAS to be fixed: App working fine on simulator iphone 5 ios 10.3. Appl crashes on real iphone 5 ios 10.3. Trying to build to debug on real device?.. Nah, error GDC116A36: can not encode offset '0xBlaBla' in resulting scattered relocation.

@EvoPulseGaming
Copy link

I second this, not sure why this was closed as the referenced topic is misleading as if you wait it will provide this error

@wislon
Copy link

wislon commented Mar 24, 2020

Still an issue on VS 2019 16.5 with all the latest versions of everything (paired to a mac).

Builds fine on (the same) mac tho, with all the latest VS for mac 8.5 goodies.

So... not a 32-bit issue then?

@qmark
Copy link

qmark commented May 27, 2020

Still an issue, VS for Mac 8.6.1 build 26 (just updated, had it on previous version too), iPhone 4s, iOS 9.3.6, ARMv7. "Link all" or "Link Framework SDKs only" work as a workaround

@rolfbjarne
Copy link
Member Author

This will not be an issue in .NET 8 (we're dropping 32-bit support).

@rolfbjarne rolfbjarne closed this as not planned Won't fix, can't repro, duplicate, stale Sep 27, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Oct 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation The issue or pull request is about documentation iOS Issues affecting Xamarin.iOS
Projects
None yet
Development

No branches or pull requests

6 participants