Fix linking errors when doing full debug build with ASAN: Disable ASAN for extern. #113891

Merged
Bastien Montagne merged 3 commits from mont29/blender:tmp-fix-linking-with-asan into main 2023-10-19 11:07:15 +02:00

With current main code, trying to build a full debug build with ASAN
enabled will fail at linking, due to out-of-bound memory references
within the binary file, e.g.:

  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 commit works around the issue by disabling ASAN by default for the
extern dependencies. A new WITH_EXTERN_ASAN CMake option is added to
enable it if needed - some components need to be disabled then.


NOTE: This is submitted primarily as a base for discussions regarding #113892

With current main code, trying to build a full debug build with ASAN enabled will fail at linking, due to out-of-bound memory references within the binary file, e.g.: ``` 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 commit works around the issue by disabling ASAN by default for the `extern` dependencies. A new `WITH_EXTERN_ASAN` CMake option is added to enable it if needed - some components need to be disabled then. ------------------- NOTE: This is submitted primarily as a base for discussions regarding #113892
Author
Owner
@brecht @Sergey @Jeroen-Bakker @ideasman42 for visibility.
Sergey Sharybin reviewed 2023-10-18 18:35:33 +02:00
@ -22,1 +22,4 @@
if(WITH_COMPILER_ASAN AND NOT WITH_EXTERN_ASAN)
# Disable ASAN for extern dependencies, as it can lead to linking issues due to too large binaries.
string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -fno-sanitize=all")

Should this also be done for C? Otherwise it feels inconsistent with what the options qadvertizes.

Should this also be done for C? Otherwise it feels inconsistent with what the options qadvertizes.
Author
Owner

Indeed, will do

Indeed, will do
mont29 marked this conversation as resolved
Bastien Montagne force-pushed tmp-fix-linking-with-asan from ba55b8973c to 93cd999d0c 2023-10-18 19:11:51 +02:00 Compare
Author
Owner

@blender-bot build

@blender-bot build
Sergey Sharybin approved these changes 2023-10-18 19:23:18 +02:00
Sergey Sharybin left a comment
Owner

On a code side seems fine.

On a code side seems fine.
Campbell Barton approved these changes 2023-10-19 09:47:05 +02:00
CMakeLists.txt Outdated
@ -846,6 +846,12 @@ Build and link against address sanitizer (only for Debug & RelWithDebInfo target
OFF
)
mark_as_advanced(WITH_COMPILER_ASAN)
option(WITH_EXTERN_ASAN "\

picky could this be called WITH_COMPILER_ASAN_EXTERN ? (or similar suffix) otherwise these options aren't ordered usefully.

*picky* could this be called `WITH_COMPILER_ASAN_EXTERN` ? (or similar suffix) otherwise these options aren't ordered usefully.
Bastien Montagne force-pushed tmp-fix-linking-with-asan from 93cd999d0c to 09715108dc 2023-10-19 10:55:44 +02:00 Compare
Bastien Montagne merged commit ab91c18995 into main 2023-10-19 11:07:15 +02:00
Bastien Montagne deleted branch tmp-fix-linking-with-asan 2023-10-19 11:07:17 +02:00
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#113891
No description provided.