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

buildroot: Speed up build times #38

Merged

Conversation

nathanchance
Copy link
Member

Switch to prebuilt toolchains wherever possible and use ccache.

All of the individual commits should be self explanatory but heckle me as necessary :)

support/scripts/setlocalversion within Buildroot's source is run when
make print-version is called, which gets information about the
boot-utils repository, not Buildroot, resulting in the version check
failing and always redownloading the Buildroot source, even when it is
not necessary.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
fakeroot 1.25.3 does not build with glibc 2.33 currently so add the
upstream Buildroot patch that adds fakeroot upstream patches to resolve
this.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Copy link
Member

@msfjarvis msfjarvis left a comment

Choose a reason for hiding this comment

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

LGTM, great job putting this together 👍

BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV5_EABI_UCLIBC_STABLE=y
BR2_TARGET_GENERIC_ROOT_PASSWD="root"
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
BR2_ROOTFS_OVERLAY="../overlay-reboot"
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
BR2_PACKAGE_BASH=y
Copy link
Member

Choose a reason for hiding this comment

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

What shell do we boot to with -i? I assume we still have one, it's just whatever busybox has which I don't think is Bash?

Copy link
Member

Choose a reason for hiding this comment

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

I use this with -i a lot, so I'm just checking this doesn't break that.

Copy link

Choose a reason for hiding this comment

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

I believe the shell is busybox ash.

Copy link
Member

@nickdesaulniers nickdesaulniers left a comment

Choose a reason for hiding this comment

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

Assuming this doesn't break -i workflows by removing bash. Neat changes, did you find these as tips somewhere?

@nickdesaulniers
Copy link
Member

I was thinking about this more overnight: does using ccache really speed up builds? I would expect to add to build time, unless you were to rebuild multiple images in repetition. Given how infrequently we update these, is it worth using ccache? Or does it somehow speed up the build regardless? I don't see how it would, unless some of the same code is being rebuilt for each image. Since we're cross compiling, I'd expect many cache misses even for the same source inputs.

@nathanchance
Copy link
Member Author

Yes, as Dima said, we have always been using busybox's ash except for on PowerPC it seems. Unless you were manually running bash after getting into the machine, there will be no visible difference.

Well, the prebuilt toolchains are infrequently updated so they should have some cache hits and the cache location is in ${HOME} so it cannot be accidentally deleted but it seems that at least for me, there is no visible generation of a cache. I will delete it from the configurations and force push here shortly.

This saves cycles while rebuilding the images.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
This saves cycles while rebuilding the images.

We need to switch off software floating point emulation so that the
prebuilt toolchain can be selected. This should not impact anything as
all of the kernels that we build have CONFIG_MIPS_FP_SUPPORT, which
emulates an FPU if there is not one present.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
We are going to be specifying POWER8 as the target architecture for our
64-bit PowerPC builds to allow us to use a prebuilt Bootlin toolchain to
build our rootfs images. To compliment that, emulate a POWER8 CPU so
that there are no issues when we get to userspace.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
This saves cycles while rebuilding the images.

For 32-bit, we need to switch to the 440fp variant so that the prebuilt
toolchain can be selected. This does not impact anything because the
kernel builds FP emulation for targets that do not have an FPU (which it
seems like bamboo does from my research anyways).

For 64-bit, we need to switch to the power8 variant so that the prebuilt
toolchain can be selected. We can boot QEMU with a power8 CPU so this
does not affect anything either.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
This saves cycles while rebuilding the images.

We need to switch to the LP64 ABI so that the prebuilt toolchain can be
selected. This is a soft float ABI, which is not the biggest deal
because this rootfs will always be run under emulation so performance is
not the biggest deal.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Use newer versions of GCC and binutils to generate better code. There is
no prebuilt toolchain available for this target.

The glibc components are dropped because they are the default. s390 does
not have any other libc support.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
This saves cycles while rebuilding the images.

We switch to the i686 subarchitecture so that the prebuilt toolchain can
be selected. This still passes all of my 32-bit x86 build tests.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
We are going to update our x86_64 rootfs image to be able to be built
with a prebuilt toolchain to speed up builds of the rootfs images, which
will require at least SSE 4.2 support. This CPU is the microarchitecture
of the first Core i7 processor, which will be the target for Buildroot.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
This saves cycles while rebuilding the images.

We switch to the corei7 target so that the prebuilt toolchain can be
selected.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
To help slim down images after upgrading the compiler implicitly by
moving to Bootlin's prebuilt toolchains, use -Os instead of -O3 and do
not build bash. We were not even using bash by default aside from on
PowerPC and these images are meant for quick smoke tests. In depth
debugging is better done using the Debian support that boot-utils offers
or by rebuilding one of the images with EDITCONFIG=1 set.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
@nathanchance nathanchance force-pushed the prebuilt-toolchains-ccache branch from 41f1231 to 471fc66 Compare March 15, 2021 18:09
@nathanchance
Copy link
Member Author

Alright, should be good, PTAL.

@nathanchance nathanchance merged commit 82a1770 into ClangBuiltLinux:main Mar 15, 2021
@nathanchance nathanchance deleted the prebuilt-toolchains-ccache branch March 15, 2021 18:24
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.

4 participants