From patchwork Sat May 4 22:02:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Carl Dong X-Patchwork-Id: 13893 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 2A44516F9B; Sat, 4 May 2019 23:03:09 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 9B55316F98 for ; Sat, 4 May 2019 23:03:08 +0100 (BST) Received: from localhost ([127.0.0.1]:33371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hN2kO-0005rn-3J for patchwork@mira.cbaines.net; Sat, 04 May 2019 18:03:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hN2kK-0005rg-K9 for guix-patches@gnu.org; Sat, 04 May 2019 18:03:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hN2kJ-0001Bo-3T for guix-patches@gnu.org; Sat, 04 May 2019 18:03:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38999) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hN2kJ-0001Bf-0H for guix-patches@gnu.org; Sat, 04 May 2019 18:03:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hN2kI-0006fu-ON for guix-patches@gnu.org; Sat, 04 May 2019 18:03:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#35568] [PATCH] gnu: gcc: Add 9.1.0. Resent-From: Carl Dong Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 04 May 2019 22:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 35568 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 35568@debbugs.gnu.org X-Debbugs-Original-To: "guix-patches@gnu.org" Received: via spool by submit@debbugs.gnu.org id=B.155700735925617 (code B ref -1); Sat, 04 May 2019 22:03:02 +0000 Received: (at submit) by debbugs.gnu.org; 4 May 2019 22:02:39 +0000 Received: from localhost ([127.0.0.1]:52542 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hN2jt-0006f5-6Z for submit@debbugs.gnu.org; Sat, 04 May 2019 18:02:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38147) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hN2jn-0006ej-Nj for submit@debbugs.gnu.org; Sat, 04 May 2019 18:02:33 -0400 Received: from lists.gnu.org ([209.51.188.17]:37991) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hN2ji-0000zM-7q for submit@debbugs.gnu.org; Sat, 04 May 2019 18:02:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52522) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hN2jg-0005qd-O4 for guix-patches@gnu.org; Sat, 04 May 2019 18:02:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hN2jf-0000xm-9V for guix-patches@gnu.org; Sat, 04 May 2019 18:02:24 -0400 Received: from mail-40132.protonmail.ch ([185.70.40.132]:18960) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hN2je-0000wS-OB for guix-patches@gnu.org; Sat, 04 May 2019 18:02:23 -0400 Date: Sat, 04 May 2019 22:02:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=carldong.me; s=protonmail; t=1557007340; bh=TfqCuorV8SDsBUY1SxiSZL4IvypQrdak5yxSSIZX3Y8=; h=Date:To:From:Reply-To:Subject:Feedback-ID:From; b=kEND20QW5wwT8UcdHilVcG31WCDTR9Y+5fVsNlsFzMF8eIO6AJqwGlSLzqvtQsqxD fmcmTTgVECYLie7829lGXe4It9oHE01tYGx0w1EYjC2SIxvNByEa+2K971r7q3dl8e TgLmHpaz0pjxJ5KrRozkCB1zxOJOITaIpgIXcWMQ= From: Carl Dong Message-ID: Feedback-ID: a8j8tDUaJ4AYuDVBywMTwsJebN4w8TVXadJLsJb8td3t3dZi9RdXFlPaQvoFKnI9KgXySsPXcRkajVyY0cGTcA==:Ext:ProtonMail MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Carl Dong Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/packages/gcc.scm (gcc-9): New variable. * gnu/packages/commencement.scm (gcc-toolchain-9): New variable. --- gnu/packages/commencement.scm | 3 + gnu/packages/gcc.scm | 14 +++ .../gcc-9-strmov-store-file-names.patch | 114 ++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 gnu/packages/patches/gcc-9-strmov-store-file-names.patch -- 2.21.0 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 +and . + +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 . */ ++ 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 ++ . */ ++ 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