From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36691) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqbi3-0005eY-NX for guix-patches@gnu.org; Tue, 27 Feb 2018 04:38:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqbhy-0005CM-PK for guix-patches@gnu.org; Tue, 27 Feb 2018 04:38:07 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:54665) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqbhy-0005Bz-M8 for guix-patches@gnu.org; Tue, 27 Feb 2018 04:38:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eqbhy-0000p0-Dd for guix-patches@gnu.org; Tue, 27 Feb 2018 04:38:02 -0500 Subject: [bug#30111] [PATCH] gnu: gcc@7: Use retpoline options when building itself. Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <877esksi62.fsf@gmail.com> <87lggkt2ck.fsf@gmail.com> Date: Tue, 27 Feb 2018 10:37:10 +0100 In-Reply-To: <87lggkt2ck.fsf@gmail.com> (Alex Vong's message of "Sat, 27 Jan 2018 11:19:55 +0800") Message-ID: <87r2p64vuh.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: Alex Vong Cc: 30111@debbugs.gnu.org Hi Alex, Sorry for the delay. Alex Vong skribis: > 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.) Any idea what upstream thinks of compiling GCC itself with these options? Do they offer a configure flag or something to help with that? > Are we going to add these options to other natively compiled programs as > well? I don=E2=80=99t have a good answer. Clearly we=E2=80=99ll want that in key= packages, but then where do we draw the line, and also how do we make sure we don=E2=80=99t repeat ourselves? Thoughts? >>>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. [...] > + (arguments > + (substitute-keyword-arguments `(#:modules ((guix build gnu-build-sy= stem) > + (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_T= ARGET)=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_C= FLAGS=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 appe= nd-flag > + ,fla= gs)))) > + ,flags))))) I=E2=80=99m a bit concerned by the apparent complexity and the extra mainte= nance burden it may entail. I don=E2=80=99t have any concrete suggestions though= . I suppose we should somehow abstract GCC compilation to make it easier to pass new flags? Thanks, Ludo=E2=80=99.