Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building across architectures #5

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

dhendrix
Copy link
Contributor

Support building cross target platforms

This supplants #3

@dhendrix
Copy link
Contributor Author

Currently I can build a binary built on ppc64le targeting x86_64 and run it in qemu-system-x86_64. Needs some clean-up.

Next up: aarch64. riscv64 doesn't have a prebuilt package from https://go.dev/dl/ like other major architectures, so we may need to build from source like Ron suggested at the last sync meeting.

Add an ARCH variable and replace the hardcoded "amd64" with a string
derived from `uname -m` in order to build non-x86 initramfs images.

Signed-off-by: David Hendricks <[email protected]>
Replace crossgcc-i386 with crossgcc-${ARCH} based on the
architecture passed in from Makefile.inc.

Signed-off-by: David Hendricks <[email protected]>
Make VPD support optional in order to enable builds for more mainboard
targets. VPD should still be added for production usage, this is
mostly intended to help get new targets up and running.

Signed-off-by: David Hendricks <[email protected]>
This will be used when cross-compiling Linux kernels.

Signed-off-by: David Hendricks <[email protected]>
Linux and `uname` don't always agree on what to call a given
architecture. This adds a LINUX_ARCH variable that will be used for
kernel config names and for cross-compilation.

Signed-off-by: David Hendricks <[email protected]>
Accomodate different paths to the kernel image for various
architectures.

Signed-off-by: David Hendricks <[email protected]>
Make the build and qemu invocation more cross-platform friendly.

Signed-off-by: David Hendricks <[email protected]>
GOARCH needs to reflect the target architecture. GOROOT needs to point
at GOROOT that is compatible with the host.

Signed-off-by: David Hendricks <[email protected]>
@dhendrix dhendrix force-pushed the crossbuild branch 2 times, most recently from 22110d4 to 8a6a92c Compare January 9, 2022 22:36
Leverage coreboot's buildgcc to build a suitable Linux toolchain if
needed.

Signed-off-by: David Hendricks <[email protected]>
This is needed due to mismatched machine names used by `uname` and
qemu-system-*.

Signed-off-by: David Hendricks <[email protected]>
This will be useful later when we add targets for other architectures.

Signed-off-by: David Hendricks <[email protected]>
GCC 8.3.0 seems to have compilation issues, and we may as well update
to the latest coreboot release anyway.

Signed-off-by: David Hendricks <[email protected]>
This attempts to make a "splitconfig" type of kernel configuration for
x86_64 so that we only include options that are intentionally enabled.
Other options will be set to default values by `make olddefconfig`.

Tested by building from scratch and booting to u-root shell using
qemu-system-x86_64.

Signed-off-by: David Hendricks <[email protected]>
Decompressing GCC takes a significant amount of time. Gzip can be
decompressed using multiple threads (buildgcc will use `pigz` if
available), so this just trades decompression speed and download
time (download should only occur once anyway).

Signed-off-by: David Hendricks <[email protected]>
This gives us a target to build. It does not work yet.

Signed-off-by: David Hendricks <[email protected]>
This gives us a target to build. It does not work yet.

Note: This should use the power9 qemu target for coreboot once it's merged:
  https://review.coreboot.org/c/coreboot/+/57084

Signed-off-by: David Hendricks <[email protected]>
@dhendrix dhendrix changed the title [WIP] crossbuild support Support building across architectures Jan 10, 2022
@dhendrix
Copy link
Contributor Author

dhendrix commented Jan 10, 2022

There are still some loose ends here, but I think we can start reviewing it and perhaps merge a few commits. x86_64 fully builds and boots into u-root, other configs need some work which I hope will be relatively easy now that the scaffolding is in place.

With this patchset applied, one should be able to build using the following commands:
ARCH=aarch64 COREBOOT_VPD_SUPPORT=0 make
ARCH=ppc64le COREBOOT_VPD_SUPPORT=0 make
ARCH=x86_64 COREBOOT_VPD_SUPPORT=0 make

ARCH=x86_64 make run should work when done on a non-x86 host.

For reference, the coreboot docs provide recipes for getting qemu targets running:
aarch64: https://review.coreboot.org/plugins/gitiles/coreboot/+/refs/heads/master/Documentation/mainboard/emulation/qemu-aarch64.md
riscv: https://review.coreboot.org/plugins/gitiles/coreboot/+/refs/heads/master/Documentation/mainboard/emulation/qemu-riscv.md
power9: https://review.coreboot.org/c/coreboot/+/58656/12/Documentation/mainboard/emulation/qemu-power9.md

Copy link
Contributor

@jonzhang-fb jonzhang-fb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update the readme file as well?
Do you want to get this to finish line? Now that we have it supporting AMD platform (Onyx) as well.

Copy link
Contributor

@rminnich rminnich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very old, so I will take it over and try to get it to work.

Makefile.inc Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants