mbox series

[bug#66263,00/23] guix: Add avr as a platform.

Message ID 20230929091333.7623-1-jean@foundationdevices.com
Headers show
Series guix: Add avr as a platform. | expand

Message

Jean-Pierre De Jesus DIAZ Sept. 29, 2023, 9:13 a.m. UTC
Hello Guixers,

This adds avr as a platform to GNU Guix allowing to cross-compile
packages to it.

For the impatient, with this patch series one can build the provided
unity package with this invocation:

./pre-inst-env guix build unity --target=avr

It uses the AVR Libc as the default libc and fully builds a
cross-compiler using the AVR Libc instead of building them separately
like it's done currently.  This could allow to use other of front-ends of
GCC in the future if possible, however, Fortran and Objective-C
front-ends don't build right now for AVR, haven't tested any other
front-ends.

This also adds the cross-toolchain module for instantiating
cross-toolchain packages, this is to avoid each platform defining a
module like avr to instantiate a toolchain, this helps in avoiding
circular dependencies as cross-toolchain should depend only on
cross-base and that'd be it.

I think could've added cross-toolchains there for MinGW though, but I
don't have a need for it but allows others to do so.  Perhaps it could
be a requirement that to add a platform one needs to add a
cross-toolchain package.

I enabled multilib support for AVR as most embedded platforms will need
it, which makes me think, perhaps should the platform record contain a
`mutlilib?' field?

Information about individual patches:

On [PATCH 05/23] I didn't find a better way of deleting the
--disable-multilib flag from GCC configure flags, if anyone has a better
idea let me know.

The [PATCH 01/23] and [PATCH 02/23] are optional but there
might be some platforms defined in the future that don't have
a proper libc and it still should be fine to use these I think.

The [PATCH 21/23] fixes a bug in the meson-configuration module
and can be applied independently.

Feel free to cherry pick the interesting/trivial patches.

PS:

I CC'ed the embedded team and Maxim Cournoyer as I saw his current work
on QMK firmwares and could be of interest to him.

Jean-Pierre De Jesus DIAZ (23):
  gnu: cross-libc: Return #f if no libc available.
  guix: gnu: Handle platforms without libc.
  gnu: Add avr platform.
  guix: utils: Add target-avr?.
  gnu: cross-gcc: Enable multilib for avr.
  gnu: microscheme: Move to avr-xyz.
  gnu: Add AVR phases to cross-gcc-build-phases.
  gnu: avr-libc: Convert to procedure.
  gnu: Add make-cross-gcc-toolchain.
  gnu: Add binutils-cross-avr.
  gnu: avr-binutils: Deprecate package.
  gnu: Remove various AVR packages.
  gnu: cross-libc: Add AVR Libc case.
  gnu: cross-gcc-arguments: Handle AVR target.
  guix: meson-configuration: Fix boolean assigment.
  gnu: cross-gcc-search-paths: Handle AVR target.
  gnu: cross-gcc: Handle inputs for AVR.
  gnu: Add avr-libc.
  gnu: Add gcc-cross-avr-toolchain.
  gnu: Add avr-toolchain.
  guix: meson-build-system: Support AVR.
  guix: meson-build-system: Disable PIC for AVR.
  gnu: Add unity.

 Makefile.am                        |   1 +
 doc/guix.texi                      |   6 +
 gnu/build/cross-toolchain.scm      |  41 +++++-
 gnu/local.mk                       |   1 +
 gnu/packages/avr-xyz.scm           |  41 ++++++
 gnu/packages/avr.scm               | 152 +++-----------------
 gnu/packages/check.scm             |  41 ++++++
 gnu/packages/cross-base.scm        | 213 +++++++++++++++++++----------
 gnu/packages/cross-toolchain.scm   |  88 ++++++++++++
 guix/build-system/gnu.scm          |  12 +-
 guix/build-system/meson.scm        |  14 +-
 guix/build/meson-configuration.scm |   4 +-
 guix/platforms/avr.scm             |  29 ++++
 guix/utils.scm                     |   4 +
 14 files changed, 421 insertions(+), 226 deletions(-)
 create mode 100644 gnu/packages/cross-toolchain.scm
 create mode 100644 guix/platforms/avr.scm

Comments

Jean-Pierre De Jesus DIAZ Sept. 29, 2023, 9:18 a.m. UTC | #1
> The [PATCH 21/23] fixes a bug in the meson-configuration module
> and can be applied independently.

Meant [PATCH 15/23], my mistake.
Mathieu Othacehe Oct. 4, 2023, 1:01 p.m. UTC | #2
Hello,

> The [PATCH 21/23] fixes a bug in the meson-configuration module
> and can be applied independently.

I applied this one. Now the rest of the series also seems fine to me.
Maxim, Efraim, Vagrant any thoughts?

Thanks,

Mathieu
Maxim Cournoyer Oct. 5, 2023, 3:20 p.m. UTC | #3
Hi,

Mathieu Othacehe <othacehe@gnu.org> writes:

> Hello,
>
>> The [PATCH 21/23] fixes a bug in the meson-configuration module
>> and can be applied independently.
>
> I applied this one. Now the rest of the series also seems fine to me.
> Maxim, Efraim, Vagrant any thoughts?

I've reviewed the series, thanks for the ping.  It seems it'll need to
be rebased on master as some of the changes conflict with turning the
previous avr-toolchain and friends into procedure that was merged
perhaps a week ago.
Jean-Pierre De Jesus DIAZ Nov. 28, 2023, 11:50 a.m. UTC | #4
Hello,

I've sent an updated revision of the changes, now adding
the MinGW toolchain targets and also changing the Ergodox
and QMK firmwares to use #:target "avr" for cross-compilation,
so it removes make-avr-toolchain from `qmk` inputs as packages
should use #:target "avr" or in user profiles cases they can install
the toolchain from the packages in cross-toolchain.scm.

The QMK package warns about the firmware not compiling with
GCC 8+ but it seems to be working right now with the default
GCC used in Guix, so maybe it'd be to tie the package to the
default GCC version as IIRC there's no way to pass a custom base
GCC version when using #:target means of cross compilation.

I've also moved the toolchain procedure to cross-base.scm and
memoized it.
Ludovic Courtès Dec. 6, 2023, 9:57 p.m. UTC | #5
Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

> Mathieu Othacehe <othacehe@gnu.org> writes:
>
>> Hello,
>>
>>> The [PATCH 21/23] fixes a bug in the meson-configuration module
>>> and can be applied independently.
>>
>> I applied this one. Now the rest of the series also seems fine to me.
>> Maxim, Efraim, Vagrant any thoughts?
>
> I've reviewed the series, thanks for the ping.  It seems it'll need to
> be rebased on master as some of the changes conflict with turning the
> previous avr-toolchain and friends into procedure that was merged
> perhaps a week ago.

Just a heads-up for you embedded team :-) : Jean-Pierre sent an updated
version last week.

Ludo’.
Efraim Flashner Dec. 11, 2023, 11:58 a.m. UTC | #6
On Tue, Nov 28, 2023 at 11:50:50AM +0000, Jean-Pierre De Jesus Diaz via Guix-patches via wrote:
> Hello,
> 
> I've sent an updated revision of the changes, now adding
> the MinGW toolchain targets and also changing the Ergodox
> and QMK firmwares to use #:target "avr" for cross-compilation,
> so it removes make-avr-toolchain from `qmk` inputs as packages
> should use #:target "avr" or in user profiles cases they can install
> the toolchain from the packages in cross-toolchain.scm.
> 
> The QMK package warns about the firmware not compiling with
> GCC 8+ but it seems to be working right now with the default
> GCC used in Guix, so maybe it'd be to tie the package to the
> default GCC version as IIRC there's no way to pass a custom base
> GCC version when using #:target means of cross compilation.
> 
> I've also moved the toolchain procedure to cross-base.scm and
> memoized it.

Wow! Thank you for all the work on this.

Patches slightly modified (indentation, wording on commit messages) and
pushed!
Jean-Pierre De Jesus DIAZ Dec. 11, 2023, 12:30 p.m. UTC | #7
Hi!

Thanks for pushing these changes! Hope to help around more in embedded
target areas,
and sorry for the issues on indentation and commit messages.

Cheers!

On Mon, Dec 11, 2023 at 11:58 AM Efraim Flashner <efraim@flashner.co.il> wrote:
>
> On Tue, Nov 28, 2023 at 11:50:50AM +0000, Jean-Pierre De Jesus Diaz via Guix-patches via wrote:
> > Hello,
> >
> > I've sent an updated revision of the changes, now adding
> > the MinGW toolchain targets and also changing the Ergodox
> > and QMK firmwares to use #:target "avr" for cross-compilation,
> > so it removes make-avr-toolchain from `qmk` inputs as packages
> > should use #:target "avr" or in user profiles cases they can install
> > the toolchain from the packages in cross-toolchain.scm.
> >
> > The QMK package warns about the firmware not compiling with
> > GCC 8+ but it seems to be working right now with the default
> > GCC used in Guix, so maybe it'd be to tie the package to the
> > default GCC version as IIRC there's no way to pass a custom base
> > GCC version when using #:target means of cross compilation.
> >
> > I've also moved the toolchain procedure to cross-base.scm and
> > memoized it.
>
> Wow! Thank you for all the work on this.
>
> Patches slightly modified (indentation, wording on commit messages) and
> pushed!
>
> --
> Efraim Flashner   <efraim@flashner.co.il>   רנשלפ םירפא
> GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
> Confidentiality cannot be guaranteed on emails sent or received unencrypted