From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efH3B-0005Im-9W for guix-patches@gnu.org; Fri, 26 Jan 2018 22:21:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1efH38-0007VS-20 for guix-patches@gnu.org; Fri, 26 Jan 2018 22:21:05 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:36329) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1efH37-0007Uf-RP for guix-patches@gnu.org; Fri, 26 Jan 2018 22:21:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1efH37-0000PJ-LL for guix-patches@gnu.org; Fri, 26 Jan 2018 22:21:01 -0500 Subject: [bug#30111] [PATCH] gnu: gcc@7: Use retpoline options when building itself. References: <877esksi62.fsf@gmail.com> In-Reply-To: <877esksi62.fsf@gmail.com> Resent-Message-ID: From: Alex Vong Date: Sat, 27 Jan 2018 11:19:55 +0800 Message-ID: <87lggkt2ck.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 30111@debbugs.gnu.org --=-=-= Content-Type: text/plain Hello, This patch makes gcc use retpoline options when building itself. My last attempt to build it was successful. But after that I have changed something, I hope it wouldn't make it fail to build. (It shouldn't, since the options passed aren't changed.) Are we going to add these options to other natively compiled programs as well? --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-gnu-gcc-7-Use-retpoline-options-when-building-itself.patch Content-Transfer-Encoding: quoted-printable >From f6b9caae6e13936be65550c871208a3425fe4ce4 Mon Sep 17 00:00:00 2001 From: Alex Vong Date: Thu, 25 Jan 2018 23:24:24 +0800 Subject: [PATCH] gnu: gcc@7: Use retpoline options when building itself. * gnu/packages/gcc.scm (gcc@7)[arguments]: Add retpoline options to #:make-flags. --- gnu/packages/gcc.scm | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm index 48e7b8ee3..6344ce734 100644 --- a/gnu/packages/gcc.scm +++ b/gnu/packages/gcc.scm @@ -5,6 +5,7 @@ ;;; Copyright =C2=A9 2015 Andreas Enge ;;; Copyright =C2=A9 2015, 2016, 2017 Efraim Flashner ;;; Copyright =C2=A9 2016 Carlos S=C3=A1nchez de La Lama +;;; Copyright =C2=A9 2018 Alex Vong ;;; ;;; This file is part of GNU Guix. ;;; @@ -428,6 +429,45 @@ Go. It also includes runtime support libraries for th= ese languages.") "0p71bij6bfhzyrs8676a8jmpjsfz392s2rg862sdnsk30jpacb43")) (patches (search-patches "gcc-strmov-store-file-names.patch" "gcc-5.0-libvtv-runpath.patch")))) + (arguments + (substitute-keyword-arguments `(#:modules ((guix build gnu-build-syst= em) + (guix build utils) + (ice-9 regex) + (srfi srfi-1) + (srfi srfi-26)) + ,@(package-arguments gcc-6)) + ;; Use retpoline options when building itself. + ((#:make-flags flags) + `(let* ((cross-compiling? ,(%current-target-system)) + (system (if cross-compiling? + ,(%current-target-system) + ,(%current-system))) + (retpoline-opts '("-mindirect-branch=3Dthunk" + "-mfunction-return=3Dthunk" + "-mindirect-branch-register")) + (append-flag + (lambda (flag) + (if (string-match "^((BOOT_)?CFLAGS|C(XX)?FLAGS_FOR_TAR= GET)=3D" + flag) + (string-join (cons flag retpoline-opts)) + flag))) + (add-flag + (lambda (prefix flags) + (if (any (cut string-prefix? prefix <>) flags) + flags + (cons (string-append prefix + (string-join retpoline-opts)) + flags)))) + (add-gcc-flag (cut add-flag + (if cross-compiling? "CFLAGS=3D" "BOOT_CFL= AGS=3D") + <>)) + (add-c-lib-flag (cut add-flag "CFLAGS_FOR_TARGET=3D" <>)) + (add-c++-lib-flag (cut add-flag "CXXFLAGS_FOR_TARGET=3D" <= >))) + ;; Right now, the retpoline options are x86-specific. + (if (any (cut string-prefix? <> system) '("x86_64" "i686")) + (add-gcc-flag (add-c-lib-flag (add-c++-lib-flag (map append= -flag + ,flags= )))) + ,flags))))) (description "GCC is the GNU Compiler Collection. It provides compiler front-ends for several languages, including C, C++, Objective-C, Fortran, Ada, and Go. --=20 2.15.1 --=-=-= Content-Type: text/plain Cheers, Alex --=-=-=--