<!DOCTYPE html>
<html lang='en'>
<head>
<title>pipewire-0.2.7-fno-common.patch « patches « packages « gnu - guix - Wojtek's customized Guix</title>
<meta name='generator' content='cgit v1.2.3'/>
<meta name='robots' content='noindex, nofollow'/>
<link rel='stylesheet' type='text/css' href='/cgit-static/cgit.css'/>
<link rel='stylesheet' type='text/css' href='/cgit-static/better-cgit-markdown-heading-color.css'/>
<link rel='shortcut icon' href='/cgit-static/favicon.ico'/>
<link rel='alternate' title='Atom feed' href='https://git.koszko.org/guix/atom/gnu/packages/patches/pipewire-0.2.7-fno-common.patch?h=koszko' type='application/atom+xml'/>
</head>
<body>
<div id='cgit'><table id='header'>
<tr>
<td class='logo' rowspan='2'><a href='/'><img src='https://git.koszko.org/cgit-static/cgit.png' alt='cgit logo'/></a></td>
<td class='main'><a href='/'>index</a> : <a href='/guix/'>guix</a></td><td class='form'><form method='get'>
<input type='hidden' name='id' value='cdbd81ce144f17644ceebd3d08723aa244696a05'/><select name='h' onchange='this.form.submit();'>
<option value='koszko' selected='selected'>koszko</option>
<option value='koszko-scripts'>koszko-scripts</option>
</select> <input type='</td></tr></table>
<table class='tabs'><tr><td>
<a class='active' href='/guix/about/'>about</a><a href='/guix/'>summary</a><a href='/guix/refs/?id=e45f9b4b1251df1a51a30e1d4a53fc2075abfcfe'>refs</a><a href='/guix/log/'>log</a><a href='/guix/tree/?id=e45f9b4b1251df1a51a30e1d4a53fc2075abfcfe'>tree</a><a href='/guix/commit/?id=e45f9b4b1251df1a51a30e1d4a53fc2075abfcfe'>commit</a><a href='/guix/diff/?id=e45f9b4b1251df1a51a30e1d4a53fc2075abfcfe'>diff</a></td><td class='form'><form class='right' method='get' action='/guix/log/'>
<input type='hidden' name='id' value='e45f9b4b1251df1a51a30e1d4a53fc2075abfcfe'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='content'><div id='summary'><pre>
Make sure that statements such as:

  strcpy (dst, &quot;/gnu/store/…&quot;);

or

  static const char str[] = &quot;/gnu/store/…&quot;;
  …
  strcpy (dst, str);

do not result in chunked /gnu/store strings that are undetectable by
Guix&apos;s GC and its grafting code.  See &lt;https://bugs.gnu.org/24703&gt;
and &lt;https://bugs.gnu.org/30395&gt;.


--- 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,58 @@ 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 &quot;/gnu/store&quot;.  */
+
+bool
+store_reference_p (tree str)
+{
+  if (getenv (&quot;GUIX_GCC_DEBUG&quot;) != NULL)
+    debug_tree (str);
+
+  if (TREE_CODE (str) == ADDR_EXPR)
+    str = TREE_OPERAND (str, 0);
+
+  if (TREE_CODE (str) == VAR_DECL
+      &amp;&amp; TREE_STATIC (str)
+      &amp;&amp; TREE_READONLY (str))
+    {
+      /* STR may be a &apos;static const&apos; variable whose initial value
+         is a string constant.  See &lt;https://bugs.gnu.org/30395&gt;.  */
+      str = DECL_INITIAL (str);
+      if (str == NULL_TREE)
+        return false;
+    }
+
+  if (TREE_CODE (str) != STRING_CST)
+    return false;
+
+  int len;
+  const char *store;
+
+  store = getenv (&quot;NIX_STORE&quot;) ? getenv (&quot;NIX_STORE&quot;) : &quot;/gnu/store&quot;;
+  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) &lt; len + hash_len)
+    return false;
+
+  /* We cannot use &apos;strstr&apos; because &apos;TREE_STRING_POINTER&apos; returns a string
+     that is not necessarily NUL-terminated.  */
+
+  for (int i = 0; i &lt; 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 &apos;movabs&apos; instruction on
+     x86_64, when SRC refers to store items.  That way, store references
+     remain visible to the Guix GC and grafting code.  See
+     &lt;https://bugs.gnu.org/24703&gt;.  */
+  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 &lt; TYPE_ALIGN (desttype)
</pre>
</div></div> <!-- class=content -->
                         <div class=footer>generated by
                             <a href="https://git.zx2c4.com/cgit/about/">
                                 cgit
                             </a>
                         </div>
                        </div> <!-- id=cgit -->
</body>
</html>
