Hi Karel!

I am having issues with usage of cross-compilation toolchains withing Guix
shell.

/gnu/store/1hnwdgx0irx58v97b25gl5fqfl8s5c9y-profile/include/gnu/stubs.h:7:11: fatal error: gnu/stubs-32.h: No such file or directory
    7 | # include <gnu/stubs-32.h>
      |           ^~~~~~~~~~~~~~~~

The compilation works once I remove gcc-toolchain from my environment. This is
clearly caused by injection of X86_64 headers to the profile with gcc-toolchain.

I’m aware of such issues as well. And I’m sure I have a solution to it.

The hotfix would be to swap the order (prefer the platform specific ones), but
that is not correct fix at all. Some macros can still check if some header is
available and include it when it is. If that header is available on x86 but not
on AVR then it would be included in AVR build from x86. This feels like a bug
somewhere.

Does anyone have an idea what is the purpose of unified include directory and
how to keep the platform paths separate?

The problem is that gcc requires a special order of include directories and 
that standard headers and libraries must not be reachable via C_INCLUDE_PATH 
etc, as they destroy this order and inject foreign architecture files.

The only proper solution is to embed the search path to the standard headers 
and libraries into gcc, which is the usual case on other distributions. With 
embedded paths all is working and there is even no real need for a 
gcc-toolchain package, but a simple gcc package is usable and composable with 
another cross-gcc.

You may want to take a look at my respository¹. It contains an embedded.scm 
file providing several (still old) GCC packages:

 • [email protected]
 • [email protected]
 • [email protected]
 • [email protected]
 • [email protected]
 • [email protected]
 • [email protected]

The newlib-nano variants do not provide files with a nano suffix as often 
expected from other distributions. I used the picolibc variants myself to build 
a keyboard firmware with ZMK.

Actually I got derailed to work on a better gcc-bootstrap with all these 
problems fixed (using less and only up-to-date packages), even improving on all 
the findings I had while working on [email protected]. It offers a bootstrapped 
[email protected] package without all the known issues. You may try to use it in 
combination with any cross-gcc package, it won’t pollute environment variables 
with include and library paths to standard headers and libraries. But be 
warned, bootstrapping that [email protected] takes a day.

I plan to base the cross compilers on this [email protected] in the next months. 
Currently all these GCC*@14.2.0 packages base on the gcc-toolchain of Guix and 
therefore still build much faster. Unfortunately I did not re-build the 
GCC*@14.2.0 packages since a long time with a recent Guix version, so it is 
possible that something broke.

I still don’t have a channel file in my repository, so you would need to use 
guix build -L … after cloning it.


Bye

Stefan


¹ <https://git.pub.solar/stefan/embedded-channel/>

Reply via email to