xgettext: D: Work around a gcc miscompilation bug.

* gettext-tools/build-aux/tree-sitter-d-optimization-bug.diff: New file.
* autopull.sh: Apply it.
This commit is contained in:
Bruno Haible 2025-05-03 03:51:49 +02:00
parent 76bfa2f87c
commit 5de2623883
2 changed files with 20 additions and 0 deletions

View File

@ -138,6 +138,7 @@ test -d gettext-tools/tree-sitter-typescript-$TREE_SITTER_TYPESCRIPT_VERSION ||
test -d gettext-tools/tree-sitter-d-$TREE_SITTER_D_VERSION || {
func_git_clone_shallow tree-sitter-d https://github.com/gdamore/tree-sitter-d.git v$TREE_SITTER_D_VERSION
(cd tree-sitter-d && patch -p1) < gettext-tools/build-aux/tree-sitter-d-portability.diff
(cd tree-sitter-d && patch -p1) < gettext-tools/build-aux/tree-sitter-d-optimization-bug.diff
mkdir gettext-tools/tree-sitter-d-$TREE_SITTER_D_VERSION
mv tree-sitter-d/LICENSE.txt gettext-tools/tree-sitter-d-$TREE_SITTER_D_VERSION/LICENSE
mv tree-sitter-d/src gettext-tools/tree-sitter-d-$TREE_SITTER_D_VERSION/src

View File

@ -0,0 +1,19 @@
diff --git a/src/parser.c b/src/parser.c
index 7ce433c..eda3381 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -1,3 +1,14 @@
+/* GCC miscompiles this compilation unit on i386 at the -O2 optimization level
+ on
+ - gcc 4.5.2 (Slackware 13.37)
+ - gcc 4.6.2 (openSUSE 12.1)
+ - gcc 4.7.1 (Slackware 14)
+ - gcc 4.7.2 (Debian GNU/kFreeBSD 7.11)
+ This works around it by reducing the optimization level. */
+#if __GNUC__ == 4 && __GNUC_MINOR__ >= 4 && __GNUC_MINOR__ < 8 && !defined __clang__ && defined __i386
+#pragma GCC optimize ("O0")
+#endif
+
#include "tree_sitter/parser.h"
#if defined(__GNUC__) || defined(__clang__)