unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: kiasoc5--- via "Development of GNU Guix and the GNU System distribution." <guix-devel@gnu.org>
To: zimoun <zimon.toutoune@gmail.com>
Cc: Guix Devel <guix-devel@gnu.org>
Subject: Re: Hardened toolchain
Date: Sat, 26 Mar 2022 23:02:41 +0100 (CET)	[thread overview]
Message-ID: <Mz7FAvG--3-2@tutanota.com> (raw)
In-Reply-To: <Mz6i-jN--3-2@tutanota.com>

Mar 26, 2022, 19:33 by kiasoc5@tutanota.com:

> Hi Simon,
>
> Mar 25, 2022, 22:54 by zimon.toutoune@gmail.com:
>
>> Hi,
>>
>> On Fri, 25 Mar 2022 at 20:39, kiasoc5@tutanota.com wrote:
>>
>>> ====the middle of guix build -f hardened.scm====
>>> building /gnu/store/1nlrgg5ryl486haw0kdqnbp4wa17lhwh-gcc-10.3.0.drv...
>>> Backtrace:
>>> In ice-9/eval.scm:
>>>    217:50 19 (lp (#<procedure 7ffff3fff5e0 at ice-9/eval.scm:282:?> ?))
>>>    217:50 18 (lp (#<procedure 7ffff3fff580 at ice-9/eval.scm:282:?> ?))
>>>    217:50 17 (lp (#<procedure 7ffff3fff4c0 at ice-9/eval.scm:649:?> ?))
>>>    217:50 16 (lp (#<procedure 7ffff3fff300 at ice-9/eval.scm:282:?> ?))
>>>    217:50 15 (lp (#<procedure 7ffff3fff2a0 at ice-9/eval.scm:649:?> ?))
>>>    217:50 14 (lp (#<procedure 7ffff3fff140 at ice-9/eval.scm:282:?> ?))
>>>    217:50 13 (lp (#<procedure 7ffff3fff120 at ice-9/eval.scm:282:?> ?))
>>>    217:50 12 (lp (#<procedure 7ffff3fff100 at ice-9/eval.scm:282:?> ?))
>>>    217:50 11 (lp (#<procedure 7ffff2c01f40 at ice-9/eval.scm:649:?> ?))
>>>    217:50 10 (lp (#<procedure 7ffff2c01f20 at ice-9/eval.scm:282:?> ?))
>>>    217:50  9 (lp (#<procedure 7ffff2c01f00 at ice-9/eval.scm:282:?> ?))
>>>    217:50  8 (lp (#<procedure 7ffff2c01ee0 at ice-9/eval.scm:282:?> ?))
>>>    217:50  7 (lp (#<procedure 7ffff2c01e80 at ice-9/eval.scm:649:?> ?))
>>>    217:50  6 (lp (#<procedure 7ffff2c01e60 at ice-9/eval.scm:282:?> ?))
>>>    217:50  5 (lp (#<procedure 7ffff2c20ed0 at ice-9/eval.scm:196:?> ?))
>>>    217:50  4 (lp (#<procedure 7ffff2c01d20 at ice-9/eval.scm:282:?> ?))
>>>    217:33  3 (lp (#<procedure 7ffff2c01b20 at ice-9/eval.scm:649:?> ?))
>>>     159:9  2 (_ #(#(#<directory (guile-user) 7ffff3fd7c80> #f) #f))
>>>     159:9  1 (_ #(#(#<directory (guile-user) 7ffff3fd7c80> #f) #f))
>>> In unknown file:
>>>            0 (string-append "LDFLAGS=" "-Wl,-rpath=" #f "/lib " "-W?" ?)
>>>
>>> ERROR: In procedure string-append:
>>> In procedure string-append: Wrong type (expecting string): #f
>>> builder for `/gnu/store/1nlrgg5ryl486haw0kdqnbp4wa17lhwh-gcc-10.3.0.drv' failed with exit code 1
>>> build of /gnu/store/1nlrgg5ryl486haw0kdqnbp4wa17lhwh-gcc-10.3.0.drv failed
>>> View build log at '/var/log/guix/drvs/1n/lrgg5ryl486haw0kdqnbp4wa17lhwh-gcc-10.3.0.drv.gz'.
>>> guix build: error: build of `/gnu/store/1nlrgg5ryl486haw0kdqnbp4wa17lhwh-gcc-10.3.0.drv' failed
>>> ====the middle of guix build -f hardened.scm====
>>>

Here's a smaller example that has the same error:
===the file===
(use-modules (gnu)
             (guix)
             (guix packages))

(use-package-modules gcc base commencement)

(package-with-c-toolchain gcc `(("toolchain" ,(make-gcc-toolchain gcc))))
===the file===
===try to build it===
In unknown file:
           0 (string-append "LDFLAGS=" "-Wl,-rpath=" #f "/lib " "-W?" ?)

ERROR: In procedure string-append:
In procedure string-append: Wrong type (expecting string): #f
===try to build it===

The gcc package already exists! Why can't I build gcc with itself?


>> You are creating a cycle, no?  It is not a DAG and so the transformation
>> fails, no?
>>
> Oh I didn't notice that. The example makes sense too.
>
>> For instance, this:
>>
>> --8<---------------cut here---------------start------------->8---
>> (use-modules (guix packages)
>> (gnu packages gcc)
>> (gnu packages base))
>>
>> (define make-gcc-toolchain
>> (@@ (gnu packages commencement) make-gcc-toolchain))
>>
>> (define gcc-bis
>> (package
>> (inherit gcc)
>> (version (string-append (package-version gcc) "-bis"))))
>>
>> (define gcc-toolchain-bis
>> (make-gcc-toolchain gcc-bis glibc))
>>
>> (define (package-with-c-toolchain-bis package)
>> (package-with-c-toolchain
>> package `(("toolchain" ,gcc-toolchain-bis))))
>>
>>
>> (package-with-c-toolchain-bis gcc-bis)
>> --8<---------------cut here---------------end--------------->8---
>>
>> fails with the same message.  There is bootstrapping issue: the binary
>> of gcc-bis is required to compile the source of gcc-bis; where does come
>> from such binary of gcc-bis?
>>
>>
>> Considering your use case, you need:
>>
>> - gcc considered as binary seed
>>
>> - use this binary gcc with the hardened options to compile the source
>> of GCC; resulting to the binary gcc-hardened-1
>>
>> - use this binary gcc-hardened-2 with the hardened options to recompile
>> the source of GCC; resulting to the binary gcc-hardened-2
>>
>> - if checksum(gcc-hardened-1) == checksum(gcc-hardened-2)
>> then use this binary to define a new toolchain
>> else reach the fixed point
>>
>> fixed point: use this binary gcc-hardened-{n-1} to compile the source of
>> GCC and output the binary gcc-hardened-{n}; compare the checksum of
>> the binary {n-1} and {n} and repeat until equality is reached.
>>
> Just so I understand, in other (imperative) words:
>
> gcc-hardened-1 = gcc-hardened built with regular gcc
> gcc-hardened-2 = gcc-hardened built with gcc-hardened-1
> n = 1
> while checksum(gcc-hardened-{n}) != checksum(gcc-hardened-{n+1}):
>    gcc-hardened-{n+1} = gcc-hardened built with gcc-hardened-{n}
>    n++
> define the new toolchain with gcc-hardened-{n+1}
>
>
>> Guix is not auto-magically resolving the fixed-point, i.e., it does not
>> unroll the cycle by magic. :-) You have to do it manually or write code
>> for automatise the process; described above.
>>
> Thanks, are there any examples in the code base that would be a good reference?
>
>>
>> Hope that helps.
>>
>> Cheers,
>> simon
>>
>
>



  reply	other threads:[~2022-03-26 22:03 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21 13:34 Hardened toolchain zimoun
     [not found] ` <Mymdzxm--3-2@tutanota.com>
2022-03-22 19:06   ` zimoun
2022-03-22 20:02     ` kiasoc5--- via Development of GNU Guix and the GNU System distribution.
2022-03-25 19:39       ` kiasoc5--- via Development of GNU Guix and the GNU System distribution.
2022-03-25 22:54         ` zimoun
2022-03-26 19:33           ` kiasoc5--- via Development of GNU Guix and the GNU System distribution.
2022-03-26 22:02             ` kiasoc5--- via Development of GNU Guix and the GNU System distribution. [this message]
2022-03-27 20:06             ` zimoun
2022-03-27 20:22 ` Maxime Devos
2022-03-28  3:17   ` Maxim Cournoyer
2022-03-28  7:35     ` zimoun
2022-03-29  0:02     ` kiasoc5--- via Development of GNU Guix and the GNU System distribution.
2022-03-29 10:15     ` Ludovic Courtès
2022-04-14 18:59       ` kiasoc5--- via Development of GNU Guix and the GNU System distribution.
2022-04-15 15:18       ` jbranso
2022-04-15 16:04         ` Zhu Zihao
2022-04-15 16:34           ` raingloom
2022-04-26 11:07             ` Katherine Cox-Buday
2022-04-28 17:36               ` Aurora
2022-04-28 17:41                 ` Katherine Cox-Buday
2022-04-28 19:53                   ` Aurora
2022-04-28 17:50                 ` Vagrant Cascadian
2022-04-28 19:54                   ` Aurora
2022-04-29 10:31       ` zimoun
2022-04-29 15:51         ` kiasoc5--- via Development of GNU Guix and the GNU System distribution.
2022-05-02 14:55         ` Katherine Cox-Buday
2022-05-02 16:25         ` Maxime Devos
2022-05-02 17:41           ` zimoun
2022-05-02 21:10             ` Maxime Devos
  -- strict thread matches above, loose matches on Subject: below --
2022-04-15 20:36 Nathan Dehnel
2022-04-16  3:51 ` raingloom
2022-03-21  4:31 kiasoc5--- via Development of GNU Guix and the GNU System distribution.

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=Mz7FAvG--3-2@tutanota.com \
    --to=guix-devel@gnu.org \
    --cc=kiasoc5@tutanota.com \
    --cc=zimon.toutoune@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).