Fix FreeType crashing in GCC + LTO builds.

This commit is contained in:
bruvzg 2022-06-08 13:31:02 +03:00 committed by Relintai
parent 1b52408dc0
commit a580bd094e
3 changed files with 48 additions and 0 deletions

View File

@ -107,6 +107,11 @@ Files extracted from upstream source:
- `include/` folder, minus the `dlg` subfolder - `include/` folder, minus the `dlg` subfolder
- `LICENSE.TXT` and `docs/FTL.TXT` - `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.
## glad ## glad

View File

@ -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;

View File

@ -1907,6 +1907,9 @@ typedef ptrdiff_t FT_PtrDist;
0 /* delta */ 0 /* delta */
) )
// -- GODOT start --
static volatile int _lto_dummy = 0;
// -- GODOT end --
static int static int
gray_convert_glyph_inner( RAS_ARG, gray_convert_glyph_inner( RAS_ARG,
@ -1928,6 +1931,9 @@ typedef ptrdiff_t FT_PtrDist;
ras.max_ey, ras.max_ey,
ras.cell_null - ras.cell_free, ras.cell_null - ras.cell_free,
ras.cell_null - ras.cell_free == 1 ? "" : "s" )); ras.cell_null - ras.cell_free == 1 ? "" : "s" ));
// -- GODOT start --
_lto_dummy = error; // Prevents LTO from removing this branch.
// -- GODOT end --
} }
else else
{ {
@ -1935,6 +1941,9 @@ typedef ptrdiff_t FT_PtrDist;
FT_TRACE7(( "band [%d..%d]: to be bisected\n", FT_TRACE7(( "band [%d..%d]: to be bisected\n",
ras.min_ey, ras.max_ey )); ras.min_ey, ras.max_ey ));
// -- GODOT start --
_lto_dummy = error; // Prevents LTO from removing this branch.
// -- GODOT end --
} }
return error; return error;