Index: gcc/builtins.cc
--- gcc/builtins.cc.orig
+++ gcc/builtins.cc
@@ -141,9 +141,11 @@ static rtx expand_builtin_memory_copy_args (tree dest,
 static rtx expand_builtin_memmove (tree, rtx);
 static rtx expand_builtin_mempcpy (tree, rtx);
 static rtx expand_builtin_mempcpy_args (tree, tree, tree, rtx, tree, memop_ret);
+#ifndef NO_UNSAFE_BUILTINS
 static rtx expand_builtin_strcpy (tree, rtx);
 static rtx expand_builtin_strcpy_args (tree, tree, tree, rtx);
 static rtx expand_builtin_stpcpy (tree, rtx, machine_mode);
+#endif
 static rtx expand_builtin_strncpy (tree, rtx);
 static rtx expand_builtin_memset_args (tree, tree, tree, rtx, machine_mode, tree);
 static rtx expand_builtin_bzero (tree);
@@ -3845,6 +3847,7 @@ expand_builtin_mempcpy_args (tree dest, tree src, tree
 					  retmode, false);
 }
 
+#ifndef NO_UNSAFE_BUILTINS
 /* Expand into a movstr instruction, if one is available.  Return NULL_RTX if
    we failed, the caller should emit a normal call, otherwise try to
    get the result in TARGET, if convenient.
@@ -4019,6 +4022,7 @@ expand_builtin_stpcpy (tree exp, rtx target, machine_m
 
   return NULL_RTX;
 }
+#endif
 
 /* Callback routine for store_by_pieces.  Read GET_MODE_BITSIZE (MODE)
    bytes from constant string DATA + OFFSET and return it as target
@@ -8227,9 +8231,11 @@ expand_builtin (tree exp, rtx target, rtx subtarget, m
       break;
 
     case BUILT_IN_STRCPY:
+#ifndef NO_UNSAFE_BUILTINS
       target = expand_builtin_strcpy (exp, target);
       if (target)
 	return target;
+#endif
       break;
 
     case BUILT_IN_STRNCPY:
@@ -8239,9 +8245,11 @@ expand_builtin (tree exp, rtx target, rtx subtarget, m
       break;
 
     case BUILT_IN_STPCPY:
+#ifndef NO_UNSAFE_BUILTINS
       target = expand_builtin_stpcpy (exp, target, mode);
       if (target)
 	return target;
+#endif
       break;
 
     case BUILT_IN_MEMCPY:
