GNU bug report logs - #30111
[PATCH] gnu: gcc@7: Use retpoline options when building itself.

Previous Next

Package: guix-patches;

Reported by: Alex Vong <alexvong1995 <at> gmail.com>

Date: Sun, 14 Jan 2018 13:10:01 UTC

Severity: normal

Tags: patch, security

Done: zimoun <zimon.toutoune <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: ludo <at> gnu.org (Ludovic Courtès)
To: Alex Vong <alexvong1995 <at> gmail.com>
Cc: 30111 <at> debbugs.gnu.org
Subject: [bug#30111] [PATCH] gnu: gcc <at> 7: Use retpoline options when building itself.
Date: Tue, 27 Feb 2018 10:37:10 +0100
Hi Alex,

Sorry for the delay.

Alex Vong <alexvong1995 <at> 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 <at> gmail.com>
> Date: Thu, 25 Jan 2018 23:24:24 +0800
> Subject: [PATCH] gnu: gcc <at> 7: Use retpoline options when building itself.
>
> * gnu/packages/gcc.scm (gcc <at> 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’.




This bug report was last modified 4 years and 101 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.