minimal icon indicating copy to clipboard operation
minimal copied to clipboard

cross-compiling toolchain

Open bauen1 opened this issue 8 years ago • 12 comments

Having a cross-compiling toolchain is essential to build a working c-compiler (tcc or gcc) for MLL and to ensure that no libraries from the host are used (currently we are relying on binary-compatibility between the host and MLL which is very bad)

  • Build a cross-compiling toochain (binutils and gcc) that target the generated sysroot
  • Install bundles to the sysroot, so the libraries used as from the bundles that will be on the final system ( #100 )
  • Allow for cross-compiling to for example arm ( use #113 to select the arch MLL should be compiled for)

bauen1 avatar Nov 29 '17 16:11 bauen1

Few notes:

  • GCC is really slow and really heavy to build, especially if you take in mind the 3 consequent passes which are required if you want to ensure that everything is correct with the GCC build. Also, GCC has tons of dependencies.
  • Compiling for ARM architecture is not that difficult. However, the overall ARM design is very different from the x86 architecture and for starters this has impact on the kernel configuration. One major difference is that pretty much all ARM devices require specific device tree blob file to be present at boot time or otherwise the Linux OS may not start at all.

My general conclusion is that if MLL builds its own toolchain, the overall build process will become at least as complex as the LFS project which follows the same concept - it relies on the host OS to build some mandatory packages (including GCC) and then pretty much everything is built once again by using the previously prepared LFS specific toolchain.

I encourage you to research for yourself the complexity of the task to provide MLL specific build toolchain. If you manage to handle all the dependencies in proper way and the build process is stable, I'll be really happy to adopt this major feature.

ivandavidov avatar Nov 29 '17 16:11 ivandavidov

GCC deps: gmp, mpfr, mpc

ghost avatar Apr 20 '18 09:04 ghost

@protonesso - these are only the library dependencies and we can go without them when we build everything from source, because we'll build these libraries before we start building the GCC.

The full list of GCC build dependencies is much longer:

https://gcc.gnu.org/install/prerequisites.html

Adding all of these dependencies in MLL will be very hard at this point.

ivandavidov avatar Apr 20 '18 10:04 ivandavidov

https://github.com/sabotage-linux/sabotage/blob/master/pkg/gcc640

Look at host.deps and deps

For making cross-compiler: clfs.org

On Fri, Apr 20, 2018, 1:25 PM Ivan Davidov [email protected] wrote:

@protonesso https://github.com/protonesso - these are only the library dependencies and we can go without them when we build everything from source, because we'll build these libraries before we start building the GCC.

The full list of GCC build dependencies is much longer:

https://gcc.gnu.org/install/prerequisites.html

Adding all of these dependencies in MLL will be very hard at this point.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ivandavidov/minimal/issues/123#issuecomment-383054615, or mute the thread https://github.com/notifications/unsubscribe-auth/AZS_I-XTNHoSt90UT9zukHi4QQeTlNBTks5tqbeTgaJpZM4QvQKv .

ghost avatar Apr 20 '18 10:04 ghost

https://github.com/protonesso/minimal I provided a musl cross-complier(because glibc sucks and second stage of gcc couldn't build with glibc :+1: )

ghost avatar Apr 29 '18 13:04 ghost

This work looks impressive. @bauen1 - could you please take a look at @protonesso's branch and share your thoughts?

EDIT: When I say 'impressive' this doesn't mean MLL will drop GLIBC in favor of Musl just like that. :)

ivandavidov avatar Apr 29 '18 13:04 ivandavidov

I would just like to note that the overlay bundles aren't using the toolchain, which will lead to breaking bundles (expecting features of the host's glibc which aren't present in musl), but otherwise it looks good :+1:

bauen1 avatar Apr 29 '18 13:04 bauen1

It's unfinished yet(I have some troubles)

ghost avatar Apr 29 '18 13:04 ghost

One other thing, I'm not sure if the kernel .config changes what headers_install does.

bauen1 avatar Apr 29 '18 13:04 bauen1

02_build_toolchain.sh

ghost avatar Apr 29 '18 13:04 ghost

The kernel config only gets written in 08_build_kernel.sh, but make headers_install is already called on the kernel source code in 02_build_toolchain.sh. (I'm not sure if headers_install really cares about the .config, just something to keep in mind=)

bauen1 avatar Apr 29 '18 13:04 bauen1

I Have some experience in building cross-compilers. Here there are some instructions on how to buid one targeting glibc: https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/ This one targets aarch64, but we can change the target to something line x86_64-mll-linux-gnu to make it work. I put mll between x86_64- and -linux-gnu to differentiate it from the host toolchain. We can get GCC dependencies by running ./contrib/download_prerequisites from its source directory. Note: The nice thing about the tutorial above is that it builds GCC only once instead of two. Normally one would build a reduced simple cross compiler just to build the C Library and then rebuild GCC again. This method instead saves a lot of time, which is essential, especially on low power laptops like mine.

I encourage you also to take a look at my project for some clues. I'm here if you need help.

Cheers

michele13 avatar Jan 17 '21 18:01 michele13