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

Fix FreeType crashing in GCC + LTO builds. #61805

Merged
merged 1 commit into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions thirdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ Files extracted from upstream source:
- `include/` folder, minus the `dlg` subfolder
- `LICENSE.TXT` and `docs/FTL.TXT`

Some changes have been made in order to prevent LTO from removing code.
They are marked with `// -- GODOT start --` and `// -- GODOT end --`
comments. Apply the patches in the `patches/` folder when syncing on newer upstream
commits.


## glslang

Expand Down
34 changes: 34 additions & 0 deletions thirdparty/freetype/patches/fix_gcc_lto_build.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
diff --git a/thirdparty/freetype/src/smooth/ftgrays.c b/thirdparty/freetype/src/smooth/ftgrays.c
index 622035aa79..5d9e1600b7 100644
--- a/thirdparty/freetype/src/smooth/ftgrays.c
+++ b/thirdparty/freetype/src/smooth/ftgrays.c
@@ -1907,6 +1907,9 @@ typedef ptrdiff_t FT_PtrDist;
0 /* delta */
)

+// -- GODOT start --
+ static volatile int _lto_dummy = 0;
+// -- GODOT end --

static int
gray_convert_glyph_inner( RAS_ARG,
@@ -1928,6 +1931,9 @@ typedef ptrdiff_t FT_PtrDist;
ras.max_ey,
ras.cell_null - ras.cell_free,
ras.cell_null - ras.cell_free == 1 ? "" : "s" ));
+// -- GODOT start --
+ _lto_dummy = error; // Prevents LTO from removing this branch.
+// -- GODOT end --
}
else
{
@@ -1935,6 +1941,9 @@ typedef ptrdiff_t FT_PtrDist;

FT_TRACE7(( "band [%d..%d]: to be bisected\n",
ras.min_ey, ras.max_ey ));
+// -- GODOT start --
+ _lto_dummy = error; // Prevents LTO from removing this branch.
+// -- GODOT end --
}

return error;
9 changes: 9 additions & 0 deletions thirdparty/freetype/src/smooth/ftgrays.c
Original file line number Diff line number Diff line change
Expand Up @@ -1907,6 +1907,9 @@ typedef ptrdiff_t FT_PtrDist;
0 /* delta */
)

// -- GODOT start --
static volatile int _lto_dummy = 0;
// -- GODOT end --

static int
gray_convert_glyph_inner( RAS_ARG,
Expand All @@ -1928,13 +1931,19 @@ typedef ptrdiff_t FT_PtrDist;
ras.max_ey,
ras.cell_null - ras.cell_free,
ras.cell_null - ras.cell_free == 1 ? "" : "s" ));
// -- GODOT start --
_lto_dummy = error; // Prevents LTO from removing this branch.
// -- GODOT end --
}
else
{
error = FT_THROW( Raster_Overflow );

FT_TRACE7(( "band [%d..%d]: to be bisected\n",
ras.min_ey, ras.max_ey ));
// -- GODOT start --
_lto_dummy = error; // Prevents LTO from removing this branch.
// -- GODOT end --
}

return error;
Expand Down