From: Carl Dong <contact@carldong.me>
To: "35568@debbugs.gnu.org" <35568@debbugs.gnu.org>
Subject: [bug#35568] [PATCH v2 1/3] gnu: gcc: Add 9.1.0.
Date: Sun, 05 May 2019 14:32:57 +0000 [thread overview]
Message-ID: <Poy21kSKSwjfsVT59wI2Cpu315xHOKL0-IYhxCoZuJGx7nhx6umCaKCKoYAmHSXUq9RolPjakRhMpjEF8us51g71J2KRIOvEMUnkcNYKaz4=@carldong.me> (raw)
In-Reply-To: <Sp0n8et-tEc1rgjshnbTToUmZAlfyr9WboL2HT50MEzzphMgrXMbdT5QRm6pU38hY9s9jmqiQ8E2bHUgoW7C85s4btH3N3ieTpCca9Y0i8s=@carldong.me>
* gnu/packages/gcc.scm (gcc-9): New variable.
* gnu/packages/commencement.scm (gcc-toolchain-9): New variable.
* gnu/packages/patches/gcc-9-strmov-store-file-names.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add the patch.
---
gnu/local.mk | 1 +
gnu/packages/commencement.scm | 3 +
gnu/packages/gcc.scm | 14 +++
.../gcc-9-strmov-store-file-names.patch | 114 ++++++++++++++++++
4 files changed, 132 insertions(+)
create mode 100644 gnu/packages/patches/gcc-9-strmov-store-file-names.patch
diff --git a/gnu/local.mk b/gnu/local.mk
index a0f40d13ae..7363655f38 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -814,6 +814,7 @@ dist_patch_DATA = \
%D%/packages/patches/gcc-6-source-date-epoch-1.patch \
%D%/packages/patches/gcc-6-source-date-epoch-2.patch \
%D%/packages/patches/gcc-8-strmov-store-file-names.patch \
+ %D%/packages/patches/gcc-9-strmov-store-file-names.patch \
%D%/packages/patches/gd-CVE-2018-5711.patch \
%D%/packages/patches/gd-CVE-2018-1000222.patch \
%D%/packages/patches/gd-CVE-2019-6977.patch \
diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index b07630a54d..a8ec677cee 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -1085,4 +1085,7 @@ and binaries, plus debugging symbols in the @code{debug} output), and Binutils."
(define-public gcc-toolchain-8
(make-gcc-toolchain gcc-8))
+(define-public gcc-toolchain-9
+ (make-gcc-toolchain gcc-9))
+
;;; commencement.scm ends here
diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm
index b9a9583410..eefce2737b 100644
--- a/gnu/packages/gcc.scm
+++ b/gnu/packages/gcc.scm
@@ -519,6 +519,20 @@ It also includes runtime support libraries for these languages.")))
(patches (search-patches "gcc-8-strmov-store-file-names.patch"
"gcc-5.0-libvtv-runpath.patch"))))))
+(define-public gcc-9
+ (package
+ (inherit gcc-8)
+ (version "9.1.0")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "mirror://gnu/gcc/gcc-"
+ version "/gcc-" version ".tar.xz"))
+ (sha256
+ (base32
+ "1817nc2bqdc251k0lpc51cimna7v68xjrnvqzvc50q3ax4s6i9kr"))
+ (patches (search-patches "gcc-9-strmov-store-file-names.patch"
+ "gcc-5.0-libvtv-runpath.patch"))))))
+
;; Note: When changing the default gcc version, update
;; the gcc-toolchain-* definitions and the gfortran definition
;; accordingly.
diff --git a/gnu/packages/patches/gcc-9-strmov-store-file-names.patch b/gnu/packages/patches/gcc-9-strmov-store-file-names.patch
new file mode 100644
index 0000000000..0c5d70491a
--- /dev/null
+++ b/gnu/packages/patches/gcc-9-strmov-store-file-names.patch
@@ -0,0 +1,114 @@
+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 <https://bugs.gnu.org/24703>
+and <https://bugs.gnu.org/30395>.
+
+diff --git a/gcc/builtins.c b/gcc/builtins.c
+index d37d73fc4a0..dac33d9d29a 100644
+--- a/gcc/builtins.c
++++ b/gcc/builtins.c
+@@ -3282,6 +3282,58 @@ determine_block_size (tree len, rtx len_rtx,
+ GET_MODE_MASK (GET_MODE (len_rtx)));
+ }
+
++extern void debug_tree (tree);
++
++/* Return true if STR contains the string "/gnu/store". */
++
++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 (str == NULL_TREE)
++ return false;
++ }
++
++ 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;
++}
++
+ /* Try to verify that the sizes and lengths of the arguments to a string
+ manipulation function given by EXP are within valid bounds and that
+ the operation does not lead to buffer overflow or read past the end.
+@@ -3839,6 +3891,13 @@ expand_builtin_memory_copy_args (tree dest, tree src, tree len,
+ 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
++ <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;
+diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
+index f30818042ee..56b592f9335 100644
+--- a/gcc/gimple-fold.c
++++ b/gcc/gimple-fold.c
+@@ -656,6 +656,8 @@ var_decl_component_p (tree var)
+ && TREE_CODE (TREE_OPERAND (inner, 0)) == ADDR_EXPR));
+ }
+
++extern bool store_reference_p (tree);
++
+ /* Return TRUE if the SIZE argument, representing the size of an
+ object, is in a range of values of which exactly zero is valid. */
+
+@@ -748,6 +750,9 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi,
+ off0 = build_int_cst (build_pointer_type_for_mode (char_type_node,
+ ptr_mode, true), 0);
+
++ if (store_reference_p (src))
++ return false;
++
+ /* If we can perform the copy efficiently with first doing all loads
+ and then all stores inline it that way. Currently efficiently
+ means that we can load all the memory into a single integer
--
2.21.0
next prev parent reply other threads:[~2019-05-05 14:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-04 22:02 [bug#35568] [PATCH] gnu: gcc: Add 9.1.0 Carl Dong
2019-05-05 14:32 ` Carl Dong [this message]
2019-05-05 14:33 ` [bug#35568] [PATCH v2 2/3] gnu: cross-base: Apply gcc 8 patch to gcc >= 8 Carl Dong
2019-05-05 14:35 ` [bug#35568] [PATCH v2 3/3] gnu: gcc@9: Fix limits.h include for cross builds Carl Dong
2019-05-06 9:13 ` bug#35568: [PATCH] gnu: gcc: Add 9.1.0 Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='Poy21kSKSwjfsVT59wI2Cpu315xHOKL0-IYhxCoZuJGx7nhx6umCaKCKoYAmHSXUq9RolPjakRhMpjEF8us51g71J2KRIOvEMUnkcNYKaz4=@carldong.me' \
--to=contact@carldong.me \
--cc=35568@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).