aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/gcc-strmov-store-file-names.patch
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-11-09 21:20:00 +0100
committerLudovic Courtès <ludo@gnu.org>2016-11-09 21:24:44 +0100
commit8033772363b287ca529461e575ceb4a69d7af942 (patch)
tree696c581a27ea02b53c2599f616fecaa0b8865626 /gnu/packages/patches/gcc-strmov-store-file-names.patch
parentc169d91e5a0be92b6bd48a8fd98c43078d2a12ef (diff)
downloadguix-8033772363b287ca529461e575ceb4a69d7af942.tar
guix-8033772363b287ca529461e575ceb4a69d7af942.tar.gz
gnu: gcc@5, gcc@6: Work around use of 'movabs' for /gnu/store strings.
Partly addresses <http://bugs.gnu.org/24703>. Reported by Mark H Weaver <mhw@netris.org>. * gnu/packages/patches/gcc-strmov-store-file-names.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/gcc.scm (gcc-5)[sources](patches): Add it. (gcc-6)[sources](patches): Add it.
Diffstat (limited to 'gnu/packages/patches/gcc-strmov-store-file-names.patch')
-rw-r--r--gnu/packages/patches/gcc-strmov-store-file-names.patch66
1 files changed, 66 insertions, 0 deletions
diff --git a/gnu/packages/patches/gcc-strmov-store-file-names.patch b/gnu/packages/patches/gcc-strmov-store-file-names.patch
new file mode 100644
index 0000000000..7951b87616
--- /dev/null
+++ b/gnu/packages/patches/gcc-strmov-store-file-names.patch
@@ -0,0 +1,66 @@
+Make sure that statements such as:
+
+ strcpy (dst, "/gnu/store/…");
+
+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>.
+
+--- 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_
+ GET_MODE_MASK (GET_MODE (len_rtx)));
+ }
+
++/* Return true if STR contains the string "/gnu/store". */
++
++static bool
++store_reference_p (tree str)
++{
++ if (TREE_CODE (str) == ADDR_EXPR)
++ str = TREE_OPERAND (str, 0);
++
++ if (TREE_CODE (str) != STRING_CST)
++ return false;
++
++ int len;
++ const char *store;
++
++ store = getenv ("NIX_STORE") ? getenv ("NIX_STORE") : "/gnu/store";
++ len = strlen (store);
++
++ /* Size of the hash part of store file names, including leading slash and
++ trailing hyphen. */
++ const int hash_len = 34;
++
++ if (TREE_STRING_LENGTH (str) < len + hash_len)
++ return false;
++
++ /* We cannot use 'strstr' because 'TREE_STRING_POINTER' returns a string
++ that is not necessarily NUL-terminated. */
++
++ for (int i = 0; i < TREE_STRING_LENGTH (str) - (len + hash_len); i++)
++ {
++ if (strncmp (TREE_STRING_POINTER (str) + i, store, len) == 0)
++ return true;
++ }
++
++ return false;
++}
++
+ /* Helper function to do the actual work for expand_builtin_memcpy. */
+
+ static rtx
+@@ -3207,6 +3243,13 @@ expand_builtin_memcpy_args (tree dest, t
+ unsigned HOST_WIDE_INT max_size;
+ unsigned HOST_WIDE_INT probable_max_size;
+
++ /* 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>. */
++ 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;