unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Alex Vong <alexvong1995@gmail.com>
Cc: 30111@debbugs.gnu.org
Subject: [bug#30111] [PATCH] gnu: gcc@7: Use retpoline options when building itself.
Date: Tue, 27 Feb 2018 10:37:10 +0100	[thread overview]
Message-ID: <87r2p64vuh.fsf@gnu.org> (raw)
In-Reply-To: <87lggkt2ck.fsf@gmail.com> (Alex Vong's message of "Sat, 27 Jan 2018 11:19:55 +0800")

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’.

  reply	other threads:[~2018-02-27  9:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-14 13:07 [bug#30111] gnu: gcc@7: Apply the 'retpoline' mitigation technique Alex Vong
2018-01-15 14:29 ` Alex Vong
2018-01-16 13:14   ` Alex Vong
2018-01-16 14:33     ` Ludovic Courtès
2018-01-16 15:24       ` Alex Vong
2018-01-17 13:11         ` Ludovic Courtès
2018-01-17 23:31           ` Leo Famulari
2018-01-27  3:19 ` [bug#30111] [PATCH] gnu: gcc@7: Use retpoline options when building itself Alex Vong
2018-02-27  9:37   ` Ludovic Courtès [this message]
2018-06-22 20:07 ` [bug#30111] gnu: gcc@7: Use retpoline options when building itself. Previous Next Gábor Boskovits
2020-12-18 23:22 ` [bug#30111] gnu: gcc@7: Apply the 'retpoline' mitigation technique zimoun
2021-01-11 15:43   ` zimoun
2021-01-11 20:03     ` Efraim Flashner
2021-02-09  1:07       ` bug#30111: " zimoun

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=87r2p64vuh.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=30111@debbugs.gnu.org \
    --cc=alexvong1995@gmail.com \
    /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).