GNU bug report logs

#30111 [PATCH] gnu: gcc@7: Use retpoline options when building itself.

PackageSource(s)Maintainer(s)
guix-patches PTS Buildd Popcon
Full log

Message #35 received at 30111@debbugs.gnu.org (full text, mbox, reply):

Received: (at 30111) by debbugs.gnu.org; 27 Feb 2018 09:37:16 +0000
From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 27 04:37:16 2018
Received: from localhost ([127.0.0.1]:34326 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
	id 1eqbhC-0000ne-Eb
	for submit@debbugs.gnu.org; Tue, 27 Feb 2018 04:37:16 -0500
Received: from hera.aquilenet.fr ([185.233.100.1]:50778)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@gnu.org>) id 1eqbhA-0000nU-Jj
 for 30111@debbugs.gnu.org; Tue, 27 Feb 2018 04:37:13 -0500
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id F14A310CD3;
 Tue, 27 Feb 2018 10:37:11 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 3dVscEN-_2qH; Tue, 27 Feb 2018 10:37:11 +0100 (CET)
Received: from ribbon (unknown [193.50.110.216])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id EFD641069E;
 Tue, 27 Feb 2018 10:37:10 +0100 (CET)
From: ludo@gnu.org (Ludovic Courtès)
To: Alex Vong <alexvong1995@gmail.com>
Subject: Re: [bug#30111] [PATCH] gnu: gcc@7: Use retpoline options when
 building itself.
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>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 30111
Cc: 30111@debbugs.gnu.org
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request@debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit@debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request@debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request@debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces@debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
X-Spam-Score: 1.0 (+)
Hi Alex,

Sorry for the delay.

Alex Vong <alexvong1995@gmail.com> 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’t have a good answer.  Clearly we’ll want that in key packages,
but then where do we draw the line, and also how do we make sure we
don’t repeat ourselves?

Thoughts?

>>From f6b9caae6e13936be65550c871208a3425fe4ce4 Mon Sep 17 00:00:00 2001
> From: Alex Vong <alexvong1995@gmail.com>
> 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-system)
> +                                                (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=thunk"
> +                                  "-mfunction-return=thunk"
> +                                  "-mindirect-branch-register"))
> +                (append-flag
> +                 (lambda (flag)
> +                   (if (string-match "^((BOOT_)?CFLAGS|C(XX)?FLAGS_FOR_TARGET)="
> +                                     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=" "BOOT_CFLAGS=")
> +                                <>))
> +                (add-c-lib-flag (cut add-flag "CFLAGS_FOR_TARGET=" <>))
> +                (add-c++-lib-flag (cut add-flag "CXXFLAGS_FOR_TARGET=" <>)))
> +           ;; 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)))))

I’m a bit concerned by the apparent complexity and the extra maintenance
burden it may entail.  I don’t have any concrete suggestions though.  I
suppose we should somehow abstract GCC compilation to make it easier to
pass new flags?

Thanks,
Ludo’.




Send a report that this bug log contains spam.


debbugs.gnu.org maintainers <help-debbugs@gnu.org>. Last modified: Fri Jan 3 00:31:13 2025; Machine Name: wallace-server

GNU bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.