aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/gcc-strmov-store-file-names.patch
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages/patches/gcc-strmov-store-file-names.patch')
-rw-r--r--gnu/packages/patches/gcc-strmov-store-file-names.patch50
1 files changed, 46 insertions, 4 deletions
diff --git a/gnu/packages/patches/gcc-strmov-store-file-names.patch b/gnu/packages/patches/gcc-strmov-store-file-names.patch
index 7951b87616..9f9162855d 100644
--- a/gnu/packages/patches/gcc-strmov-store-file-names.patch
+++ b/gnu/packages/patches/gcc-strmov-store-file-names.patch
@@ -2,23 +2,43 @@ Make sure that statements such as:
strcpy (dst, "/gnu/store/…");
+or
+
+ static const char str[] = "/gnu/store/…";
+ …
+ strcpy (dst, str);
+
do not result in chunked /gnu/store strings that are undetectable by
-Guix's GC and its grafting code. See <http://bugs.gnu.org/24703>.
+Guix's GC and its grafting code. See <https://bugs.gnu.org/24703>
+and <https://bugs.gnu.org/30395>.
+
--- gcc-5.3.0/gcc/builtins.c 2016-10-18 10:50:46.080616285 +0200
+++ gcc-5.3.0/gcc/builtins.c 2016-11-09 15:26:43.693042737 +0100
-@@ -3192,6 +3192,42 @@ determine_block_size (tree len, rtx len_
+@@ -3192,6 +3192,54 @@ determine_block_size (tree len, rtx len_
GET_MODE_MASK (GET_MODE (len_rtx)));
}
++extern void debug_tree (tree);
++
+/* Return true if STR contains the string "/gnu/store". */
+
-+static bool
++bool
+store_reference_p (tree str)
+{
++ if (getenv ("GUIX_GCC_DEBUG") != NULL)
++ debug_tree (str);
++
+ if (TREE_CODE (str) == ADDR_EXPR)
+ str = TREE_OPERAND (str, 0);
+
++ if (TREE_CODE (str) == VAR_DECL
++ && TREE_STATIC (str)
++ && TREE_READONLY (str))
++ /* STR may be a 'static const' variable whose initial value
++ is a string constant. See <https://bugs.gnu.org/30395>. */
++ str = DECL_INITIAL (str);
++
+ if (TREE_CODE (str) != STRING_CST)
+ return false;
+
@@ -57,10 +77,32 @@ Guix's GC and its grafting code. See <http://bugs.gnu.org/24703>.
+ /* Do not emit block moves, which translate to the 'movabs' instruction on
+ x86_64, when SRC refers to store items. That way, store references
+ remain visible to the Guix GC and grafting code. See
-+ <http://bugs.gnu.org/24703>. */
++ <https://bugs.gnu.org/24703>. */
+ if (store_reference_p (src))
+ return NULL_RTX;
+
/* If DEST is not a pointer type, call the normal function. */
if (dest_align == 0)
return NULL_RTX;
+
+--- gcc-5.5.0/gcc/gimple-fold.c 2018-03-20 11:36:16.709442004 +0100
++++ gcc-5.5.0/gcc/gimple-fold.c 2018-03-20 11:46:43.838487065 +0100
+@@ -769,6 +769,8 @@ var_decl_component_p (tree var)
+ return SSA_VAR_P (inner);
+ }
+
++extern bool store_reference_p (tree);
++
+ /* Fold function call to builtin mem{{,p}cpy,move}. Return
+ false if no simplification can be made.
+ If ENDP is 0, return DEST (like memcpy).
+@@ -1099,6 +1101,9 @@ gimple_fold_builtin_memory_op (gimple_st
+ if (!srctype)
+ return false;
+
++ if (store_reference_p (src))
++ return false;
++
+ src_align = get_pointer_alignment (src);
+ dest_align = get_pointer_alignment (dest);
+ if (dest_align < TYPE_ALIGN (desttype)