Using precompiled toolchain

Hi all,

I want to reduce build time and wanted to reuse some of the existing directories in a new, clear environment.

I'm trying to reuse the following directories of the build_dir:

  • host
  • hostpkg
  • toolchain

And the following directories of the staging_dir:

  • host
  • hostpkg
  • toolchain

However, when I run the make command, the system starts to recompile everything and seems to ignore that the hosttools and toolchain are allready available.

I tried to put the old packages back in the dl folder, as I found out that the system restarts compiling if he cannot find the package there. But still, this seems not enough.

Has anyone an idea what I am missing here?

Matthias

1 Like

However, when I run the make command, the system starts to recompile everything and seems to ignore that the hosttools and toolchain are allready available.

Thats because the build system is based on GNU Make so you would need to account for that, probably by fixing the file timestamps and stamp files.

Take a look at the SDK which exists for the same purpose, you can use official Docker images as well.

What do you exactly mean with fixing the timestamps? The timestamps of the files in the directories staging_dir and build_dir are from the time I compiled these tools for the first time (a few days ago).

In the directory staging_dir/host/stamp, files like .libressl_installed are available. When I start compiling, these files are updated with current time.

Are these the files I should modify? I tried to modify the timestamp of these files to an hour ago. But still, the buildsystem seems to ignore this and starts compiling the components again.

If you plan to fight this uphill battle, then you need to understand how Make works. Otherwise just use SDK.

restore_cache() {
        [ -d "$cache_dir" ] || return
        [ "$build_use_cache" = "yes" ] || return

        echo "Restoring build cache..."

        mkdir -p "$build_dir/build/packages"
        rsync --archive --delete "$cache_dir/packages" "$build_dir/build/" || exit

        mkdir -p "$build_dir/build/openwrt/build_dir"
        rsync --archive --delete $cache_dir/{host*,toolchain-*} "$build_dir/build/openwrt/build_dir/" || exit

        mkdir -p "$build_dir/build/openwrt/staging_dir"
        rsync --archive --delete $cache_dir/staging_dir/ "$build_dir/build/openwrt/staging_dir/" || exit

        find $build_dir/build/openwrt/build_dir/{host*,toolchain-*} -name .built\* -exec touch {} \;
        touch $build_dir/build/openwrt/staging_dir/{host*,toolchain-*,target-*}/stamp/.*
}
1 Like

Not only that, but unless the toolchain changes (additions, edits, or removal) then the toolchain Openwrt uses shouldn't be rebuilding every time. It's compiled the first time and then used until it needs to be rebuilt.

First of all, thank you for your help solving this problem.

This is what 'solved' the problem:

  • Create tar.gz from staging_dir/ and build_dir/
  • Extract the files in a new environment
  • Execute the commands based on these of @ynezz
find build_dir/{host*,toolchain-*} -name .built\* -exec touch {} \;
touch staging_dir/{host*,toolchain-*}/stamp/.*

This modification of timestamps seems to work for the toolchain, but not for the host tools. However, another way of triggering the system to not compile the host tools is to clear the tools/Makefile. Not the most clean way, but it prevents the host tools from being compiled again.

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.

I've only seen rather than used them so may have misunderstood their capabilities, but I wonder if using the "external toolchain" options would allow you to use the already built ones.

This topic was automatically closed 0 minutes after the last reply. New replies are no longer allowed.