add bootstraped x86_64-linux cross compiled gcc #8

Merged
jakehamilton merged 4 commits from vlinkz/labs:vlinkz/cross into main 2024-09-22 02:55:03 +00:00
Member

Work in progress cross compiler for x86_64. I've managed to get a full x86_64 gcc using the binaries built from foundation, and am working on implementing their builds into tidepool.

Bootstrapping steps

  1. Start with i686 tools (gcc, binutils, musl, etc)
  2. Build binutils targeting x86_64-linux
  3. Build a minimal gcc cross compiler using the cross binutils. This minimal cross compiler does not have support for libc, so is pretty much only useful for building musl or glibc.
  4. Use the minimal cross compiler to build x86_64-linux glibc or musl
  5. Now that we have a cross compiler and x86_64-linux libc, we can build gcc for the target architecture!
  6. Profit! We can now build anything x86_64 using our gcc compiler!
Work in progress cross compiler for x86_64. I've managed to get a full x86_64 gcc using the binaries built from foundation, and am working on implementing their builds into tidepool. ### Bootstrapping steps 0) Start with i686 tools (gcc, binutils, musl, etc) 1) Build binutils targeting x86_64-linux 2) Build a minimal gcc cross compiler using the cross binutils. This minimal cross compiler does not have support for libc, so is pretty much only useful for building musl or glibc. 3) Use the minimal cross compiler to build x86_64-linux glibc or musl 4) Now that we have a cross compiler and x86_64-linux libc, we can build gcc for the target architecture! 5) Profit! We can now build anything x86_64 using our gcc compiler!
vlinkz added 1 commit 2024-08-27 04:43:40 +00:00
WIP: cross compile gcc
Some checks failed
buildbot/nix-eval Build done.
977a1c0092
vlinkz force-pushed vlinkz/cross from 977a1c0092 to 623ba58429 2024-08-27 04:47:33 +00:00 Compare
vlinkz force-pushed vlinkz/cross from 623ba58429 to 46190aef81 2024-08-27 04:51:07 +00:00 Compare
vlinkz force-pushed vlinkz/cross from 46190aef81 to 70bc3dcbd5 2024-08-27 19:01:52 +00:00 Compare
vlinkz force-pushed vlinkz/cross from 70bc3dcbd5 to 2040ecc7d9 2024-09-11 04:19:29 +00:00 Compare
Author
Member

Update: with some hacks, I now have a full x86_64 gcc cross compiler, next step is build a native x86_64-linux gcc compiler. For now a lot of the code is duplicated, but we can optimize later.

Update: with some hacks, I now have a full x86_64 gcc cross compiler, next step is build a native x86_64-linux gcc compiler. For now a lot of the code is duplicated, but we can optimize later.
vlinkz force-pushed vlinkz/cross from 2040ecc7d9 to 6ee203a884 2024-09-11 23:07:56 +00:00 Compare
vlinkz force-pushed vlinkz/cross from 6ee203a884 to 4d2e226250 2024-09-11 23:21:45 +00:00 Compare
vlinkz force-pushed vlinkz/cross from 4d2e226250 to 46d16e6da1 2024-09-11 23:55:32 +00:00 Compare
vlinkz force-pushed vlinkz/cross from 46d16e6da1 to 00c373551f 2024-09-13 22:46:02 +00:00 Compare
vlinkz changed title from WIP: cross compile gcc to cross compile gcc 2024-09-13 22:48:34 +00:00
vlinkz changed title from cross compile gcc to add bootstraped x86_64-linux cross compiled gcc 2024-09-13 22:49:05 +00:00
Author
Member

To build x86_64 gcc, run:

nix build ./tidepool#packages.i686-linux.cross-foundation-gcc-x86_64-linux

Next steps:

  • build gnu build tools natively
  • build binutils, glibc, etc natively
  • build gcc using native dependencies
To build x86_64 gcc, run: ```bash nix build ./tidepool#packages.i686-linux.cross-foundation-gcc-x86_64-linux ``` Next steps: - build gnu build tools natively - build binutils, glibc, etc natively - build gcc using native dependencies
vlinkz changed target branch from feat/cross to main 2024-09-13 23:10:13 +00:00
vlinkz force-pushed vlinkz/cross from 00c373551f to 4111958d69 2024-09-14 00:00:37 +00:00 Compare
vlinkz force-pushed vlinkz/cross from 4111958d69 to 8a0e831a7b 2024-09-14 00:04:06 +00:00 Compare
vlinkz force-pushed vlinkz/cross from 8a0e831a7b to 5432ea31f1 2024-09-14 00:04:53 +00:00 Compare
vlinkz force-pushed vlinkz/cross from 5432ea31f1 to 694b442682 2024-09-14 00:05:32 +00:00 Compare
jakehamilton requested review from jakehamilton 2024-09-14 08:45:18 +00:00
Owner

Awesome!! I've just tested this and it all builds correctly, producing an x86_64-linux build of GCC. Amazing work @vlinkz!

I am going to approve the PR here for us to merge in as-is. After it is merged I'll make a pass to clean up comments, formatting, etc.

Again, outstanding work. I cannot stress enough just how monumental of an accomplishment this piece is.

Awesome!! I've just tested this and it all builds correctly, producing an x86_64-linux build of GCC. Amazing work @vlinkz! I am going to approve the PR here for us to merge in as-is. After it is merged I'll make a pass to clean up comments, formatting, etc. Again, outstanding work. I cannot stress enough just how monumental of an accomplishment this piece is.
jakehamilton approved these changes 2024-09-14 09:31:26 +00:00
jakehamilton merged commit d7762a5a78 into main 2024-09-22 02:55:03 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: auxolotl/labs#8
No description provided.