Blender Binary is getting to big - linking error due to out-of-range addresses #113892

Open
opened 2023-10-18 15:57:10 +02:00 by Bastien Montagne · 5 comments

Currently when trying to build main in DEBUG with ASAN enabled and most features enabled, one will run into this type of errors when linking final binary:

mold: error: /usr/lib/gcc/x86_64-linux-gnu/13/crtbegin.o:(.text): relocation R_X86_64_32S against .tm_clone_table out of range: 2147741344 is not in [-2147483648, 2147483648)

This blog post seems to give a good comprehensive overview of the issue.

There are at least three ways to address this issue.

1. Reduce binary size - disabling ASAN

Disabling ASAN for parts of the code makes building successful again. E.g. in !113891, ASAN is disabled by default for all of our extern libraries.

2. Reduce binary size - Move some dependencies to shared libraries.

We are still linking statically against many pre-compiled libraries (from lib/linux_x86_64_glibc_228/), moving more of these to dynamic linking would likely help.

Some libraries from our extern source-code folder could also potentially be built and linked as shared libraries.

3. Embrace the binary size - move to medium or large.

In theory, there are options (like the -mcmodel for GCC) to build binaries supporting larger address range than the one allowed by int32. I could not get neither medium nor large data model to work from quick testing, but I suspect it's because pre-compiled libraries would also need to be built with these settings.

Don't think we should consider this option unless the first two ones cannot solve well enough the issue though.

Currently when trying to build main in DEBUG with ASAN enabled and most features enabled, one will run into this type of errors when linking final binary: ``` mold: error: /usr/lib/gcc/x86_64-linux-gnu/13/crtbegin.o:(.text): relocation R_X86_64_32S against .tm_clone_table out of range: 2147741344 is not in [-2147483648, 2147483648) ``` [This blog post](https://maskray.me/blog/2023-05-14-relocation-overflow-and-code-models) seems to give a good comprehensive overview of the issue. There are at least three ways to address this issue. ### 1. Reduce binary size - disabling ASAN Disabling ASAN for parts of the code makes building successful again. E.g. in !113891, ASAN is disabled by default for all of our `extern` libraries. ### 2. Reduce binary size - Move some dependencies to shared libraries. We are still linking statically against many pre-compiled libraries (from `lib/linux_x86_64_glibc_228/`), moving more of these to dynamic linking would likely help. Some libraries from our `extern` source-code folder could also potentially be built and linked as shared libraries. ### 3. Embrace the binary size - move to `medium` or `large`. In theory, there are options (like the `-mcmodel` for GCC) to build binaries supporting larger address range than the one allowed by `int32`. I could not get neither `medium` nor `large` data model to work from quick testing, but I suspect it's because pre-compiled libraries would also need to be built with these settings. Don't think we should consider this option unless the first two ones cannot solve well enough the issue though.
Bastien Montagne added the
Type
Design
label 2023-10-18 15:57:10 +02:00
Bastien Montagne added the
Module
Platforms, Builds & Tests
Interest
Core
labels 2023-10-18 15:57:58 +02:00
Author
Owner
@brecht @Sergey @Jeroen-Bakker @ideasman42 for visibility.

We can make more libraries dynamic. I think the main candidates would be:

  • OpenShadingLanguage, with LLVM statically linked into it.
  • FFmpeg
  • OpenImageDenoise
  • OpenCollada

CC @LazyDodo.

We can make more libraries dynamic. I think the main candidates would be: * OpenShadingLanguage, with LLVM statically linked into it. * FFmpeg * OpenImageDenoise * OpenCollada CC @LazyDodo.
Member

Certainly an option, dynamic will likely cause the distro size to increase since dead code elimination is less successful on shared libs compared to statically linking, then again, with the cycles kernels adding as much as they do, i guess this is no longer really a huge concern.

  • FFmpeg probably be highest on my list, it has a lot of deps that drag in a lot of stuff, already dynamic on windows.

  • OSL - llvm enough said, llvm itself doesn't link dynamically on windows, so if we ever get something else that needs it there will be some code bloat by double linking it into stuff.

  • Opencollada smaller hence lower on prio list, think last we discussed collada, the last big user of it (linden labs) was looking at transitioning to gltf or usd (don't remember the exact details) so we'd be able to drop it at one point. I'd probably leave this alone if ffmpeg+osl give us the relief we need.

  • OIDN is big, but most of it are const data tables, there isn't all that much code in there, i don't see it helping, however afaik will turn dynamic in the 2.x update anyhow, so this problem solves it self.

It be interesting to pick a part an elf that does still link to see who/what the main offenders/contributors are to the blender binary size.

Certainly an option, dynamic will likely cause the distro size to increase since dead code elimination is less successful on shared libs compared to statically linking, then again, with the cycles kernels adding as much as they do, i guess this is no longer really a huge concern. - FFmpeg probably be highest on my list, it has a lot of deps that drag in a lot of stuff, already dynamic on windows. - OSL - llvm enough said, llvm itself doesn't link dynamically on windows, so if we ever get something else that needs it there will be some code bloat by double linking it into stuff. - Opencollada smaller hence lower on prio list, think last we discussed collada, the last big user of it (linden labs) was looking at transitioning to gltf or usd (don't remember the exact details) so we'd be able to drop it at one point. I'd probably leave this alone if ffmpeg+osl give us the relief we need. - OIDN is big, but most of it are const data tables, there isn't all that much code in there, i don't see it helping, however afaik will turn dynamic in the 2.x update anyhow, so this problem solves it self. It be interesting to pick a part an elf that does still link to see who/what the main offenders/contributors are to the blender binary size.

I believe this should be fixed by moving OSL/LLVM and OIDN into a shared library, but I have never been able to reproduce this myself so don't know.

@mont29, can you check?

I believe this should be fixed by moving OSL/LLVM and OIDN into a shared library, but I have never been able to reproduce this myself so don't know. @mont29, can you check?
Author
Owner

@brecht I still cannot link full ASAN debug build when enabling ASAN for extern libraries.

This time, mold fails with errors when handling libopenal.a...

@brecht I still cannot link full ASAN debug build when enabling ASAN for extern libraries. This time, mold fails with errors when handling `libopenal.a`...
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#113892
No description provided.