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

Makefile: prefetch crossgcc tarballs (ftpmirror.gnu.org failing downloads on coreboot builds) #947

Closed
wants to merge 2 commits into from

Conversation

Tonux599
Copy link
Contributor

@Tonux599 Tonux599 commented Jan 1, 2021

Ever look at your CircleCI build for about 2 hours and then the whole thing fails because it failed to fetch some tarballs for a coreboot crossgcc version that hasn't been build yet? Hopefully this will help that. Fetches the tarballs required for coreboot's crossgcc for version 4.8.1, 4.11 and 4.13 (these appear to be the ones currently in use) early on.

Possible extra feature that I haven't implemented yet is checking the checksums early too but as it stands this should help a bit.

@tlaurion
Copy link
Collaborator

tlaurion commented Jan 2, 2021

@Tonux599 This brings an interesting concept that could be simplified the other way around. I don't find the maintainability path sexy at all, and caching the files for non extracted coreboot build script is not interesting at all (which would be the alternative, scoping file versions under /heads/build/coreboot-*/util/crossgcc/buildgcc for yet non extracted file).

Hashes could be made on coreboot module and coreboot_cross cache made on build/coreboot-4.*/util/crossgcc/tarballs instead? I understand this approach would not resolve the issue of downloading files prior of failing, but a successful build of all boards would produce that cache and be reused for all subsequent builds for the same unmodified coreboot module file (whiche should change only once per coreboot version change, bi-annually)

I could push a PR of that, where the mirror of gnu should not fail... normally.

@Tonux599 Tonux599 force-pushed the make-prefetch-packages branch from d4478b8 to df8f97b Compare January 2, 2021 01:26
@Tonux599
Copy link
Contributor Author

Tonux599 commented Jan 2, 2021

This brings an interesting concept that could be simplified the other way around. I don't find the maintainability path sexy at all, and caching the files for non extracted coreboot build script is not interesting at all.

Hashes could be made on coreboot module and cache made on packages/ build/coreboot-4.*/util/crossgcc/tarballs instead? I understand this approach would not resolve the issue of downloading files prior of failing, but a successful build of all boards would produce that cache and be reused for all subsequent builds for the same unmodified coreboot module file.

I could push a PR of that, where the mirror of gnu should not fail... normally.

Actually why stop with the tarballs, we may be able to cache the built crossgcc for each coreboot version? Will mess around more tomorrow.

@tlaurion
Copy link
Collaborator

tlaurion commented Jan 2, 2021

This brings an interesting concept that could be simplified the other way around. I don't find the maintainability path sexy at all, and caching the files for non extracted coreboot build script is not interesting at all.
Hashes could be made on coreboot module and cache made on packages/ build/coreboot-4.*/util/crossgcc/tarballs instead? I understand this approach would not resolve the issue of downloading files prior of failing, but a successful build of all boards would produce that cache and be reused for all subsequent builds for the same unmodified coreboot module file.
I could push a PR of that, where the mirror of gnu should not fail... normally.

Actually why stop with the tarballs, we may be able to cache the built crossgcc for each coreboot version? Will mess around more tomorrow.

@Tonux599 The actual cache system is based on modules and patches directory checksums.
We could split those.

@tlaurion
Copy link
Collaborator

tlaurion commented Jan 2, 2021

@Tonux599

As of right now:

Digest creation of what we currently measure and cache consequently:

      - run:
          name: Creating all modules and patches digest
          command: |
            find ./patches/ ./modules/ -type f | sort -h |xargs sha256sum > /tmp/all_modules_and_patches.sha256sums \

      - run:
          name: Creating musl-cross-make and musl-cross-make patches digest
          command: |
            find modules/musl-cross* -type f | sort -h | xargs sha256sum > /tmp/musl-cross_module_and_patches.sha256sums \

Cache creation based on those digest:

      - save_cache:
          #Generate cache for the same musl-cross module definition if hash is not previously existing
          key: heads-cross-musl-{{ checksum "/tmp/musl-cross_module_and_patches.sha256sums" }}{{ .Environment.CACHE_VERSION }}
          paths:
            - crossgcc
            - build/musl-cross-*

      - save_cache:
          #Generate cache for the exact same modules definitions if hash is not previously existing
          key: heads-modules-and-patches-{{ checksum "/tmp/all_modules_and_patches.sha256sums" }}{{ .Environment.CACHE_VERSION }}
          paths:
            - packages
            - crossgcc
            - build

As you can see here, the coreboot packages are cached under build (build/coreboot-*/util/crossgcc/tarballs/) upon successful build of all boards in a CI run.

Cache restore based on previous digests:

      - restore_cache:
          keys:
            #Restore existing cache for modules checksums validated to be exactly the same as in github current commit
            - heads-modules-and-patches-{{ checksum "/tmp/all_modules_and_patches.sha256sums" }}{{ .Environment.CACHE_VERSION }}
            #If precedent fails. Restore cache for musl-cross module checksum validated to be exactly the same as in github current commit
            - heads-cross-musl-{{ checksum "/tmp/musl-cross_module_and_patches.sha256sums" }}{{ .Environment.CACHE_VERSION }}

@tlaurion
Copy link
Collaborator

tlaurion commented Jan 2, 2021

@Tonux599 : What I was suggesting would be the introduction of a new cache between musl-cross and actual boards build cache, which could be limited to coreboot cache upon a successful run, which just like musl-cross cache only changing when that module signature changes, could be reused until coreboot module changes.

It would look like something like the following:

Add a new digest for coreboot module (and associated patches)

      - run:
          name: Creating all modules and patches digest
          command: |
            find ./patches/ ./modules/ -type f | sort -h |xargs sha256sum > /tmp/all_modules_and_patches.sha256sums \

      - run:
          name: Creating coreboot module (and associated patches) digest
          command: |
            find ./modules/coreboot ./patches/coreboot* -type f | sort -h | xargs sha256sum > /tmp/coreboot.sha256sums \

      - run:
          name: Creating musl-cross-make and musl-cross-make patches digest
          command: |
            find modules/musl-cross* -type f | sort -h | xargs sha256sum > /tmp/musl-cross_module_and_patches.sha256sums \

Add coreboot module cache in between global cache and musl-cross for successful build (cache is build only if digest signature is different). The cache is made on save, and only if the digest is different from found, and hashed files in the digest created tmp file before.

      - save_cache:
          #Generate cache for the same musl-cross module definition if hash is not previously existing
          key: heads-cross-musl-{{ checksum "/tmp/musl-cross_module_and_patches.sha256sums" }}{{ .Environment.CACHE_VERSION }}
          paths:
            - crossgcc
            - build/musl-cross-*
      - save_cache:
          #Generate cache for the same coreboot module definition if hash is not previously existing for coreboot cache
          key: heads-coreboot-{{ checksum "/tmp/coreboot.sha256sums" }}{{ .Environment.CACHE_VERSION }}
          paths:
            - build/coreboot-*
      - save_cache:
          #Generate cache for the exact same modules definitions if hash is not previously existing
          key: heads-modules-and-patches-{{ checksum "/tmp/all_modules_and_patches.sha256sums" }}{{ .Environment.CACHE_VERSION }}
          paths:
            - packages
            - crossgcc
            - build
            - install

Restore the cache in order of bigger to smaller. Logic here is

  • if all modules are found with same integrity, that cache will be extracted (only scripts changed, not modules. Fastest build).
  • If a module integrity changed, we want to use the next bigger stable cache (same coreboot versions caches from module definition will be extracted) (longer build)
  • If there is neither all modules cache nor coreboot cache, reuse musl-cross cache (longest builds)
      - restore_cache:
          keys:
            #Restore existing cache for modules checksums validated to be exactly the same as in github current commit
            - heads-modules-and-patches-{{ checksum "/tmp/all_modules_and_patches.sha256sums" }}{{ .Environment.CACHE_VERSION }}
            #If precedent fails. Restore cache for coreboot module (and patches) checksum validated to be exactly the same as in github current commit
            - heads-coreboot-{{ checksum "/tmp/coreboot.sha256sums" }}{{ .Environment.CACHE_VERSION }}
            #If precedent fails. Restore cache for coreboot module checksum validated to be exactly the same as in github current commit           
            - heads-cross-musl-{{ checksum "/tmp/musl-cross_module_and_patches.sha256sums" }}{{ .Environment.CACHE_VERSION }}

Any better idea welcome.

tlaurion added a commit to tlaurion/heads that referenced this pull request Jan 2, 2021
@tlaurion
Copy link
Collaborator

tlaurion commented Jan 2, 2021

@Tonux599 Maybe we should take a different approach and have cache per boards? coreboot version?
EDIT: have not played with this, but I think the cache save statement can be moved in the CircleCI configuration....

Silly idea, but https://app.circleci.com/pipelines/github/tlaurion/heads/677/workflows/c684d1ad-c557-4fb1-8aaa-ed364c270f34/jobs/736 is showing that the gnu mirror issue is not going away, while current successful build (so a specific coreboot version) are not cached (here, 4.8.1 coreboot under ./build could be cached and reused).

I do not have a good angle as of right now to propose, while being conscious this holiday season is not over and gnu people have not answered.

Another silly idea (hack) would be to resolve the mirror and sed buildgcc script to replace mirror with reolved name so that tarballs are downloaded.... But this is ugly also.

@Tonux599
Copy link
Contributor Author

Tonux599 commented Jan 2, 2021

Silly idea, but https://app.circleci.com/pipelines/github/tlaurion/heads/677/workflows/c684d1ad-c557-4fb1-8aaa-ed364c270f34/jobs/736 is showing that the gnu mirror issue is not going away, while current successful build (so a specific coreboot version) are not cached (here, 4.8.1 coreboot under ./build could be cached and reused).

The cache would have to include the tarballs, as even if crossgcc is already build Coreboot's make still verifies the tarball hash and extracts before checking to see if its already build.

Maybe we are thinking too big for the moment, if I prepare a PR that simply has CircleCI cache only the crossgcc tarballs would you accept? At least with that once a build has been successful the gnu mirror doesn't need to be contacted again for another six months.

@tlaurion
Copy link
Collaborator

tlaurion commented Jan 3, 2021

Another approach could be to hack around the following output and cache only the files, as in OP (without hardcoding them)

user@localhost:~/heads/build/coreboot-4.13/util/crossgcc$ ./buildgcc -u
https://ftpmirror.gnu.org/gmp/gmp-6.2.0.tar.xz https://ftpmirror.gnu.org/mpfr/mpfr-4.1.0.tar.xz https://ftpmirror.gnu.org/mpc/mpc-1.2.0.tar.gz 	https://ftpmirror.gnu.org/gcc/gcc-8.3.0/gcc-8.3.0.tar.xz https://ftpmirror.gnu.org/binutils/binutils-2.35.tar.xz https://ftpmirror.gnu.org/gdb/gdb-9.2.tar.xz https://acpica.org/sites/acpica/files/acpica-unix2-20200717.tar.gz 	https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tar.xz https://downloads.sourceforge.net/sourceforge/expat/expat-2.2.9.tar.bz2 https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/llvm-10.0.1.src.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/clang-10.0.1.src.tar.xz 	https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/compiler-rt-10.0.1.src.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/clang-tools-extra-10.0.1.src.tar.xz https://cmake.org/files/v3.18/cmake-3.18.1.tar.gz https://www.nasm.us/pub/nasm/releasebuilds/2.15.03/nasm-2.15.03.tar.bz2

@tlaurion tlaurion changed the title Makefile: prefetch crossgcc tarballs Makefile: prefetch crossgcc tarballs (ftpmirror.gnu.org failing downloads on coreboot builds) Jan 3, 2021
tlaurion added a commit to tlaurion/heads that referenced this pull request Jan 3, 2021
The idea here is a cache to restore from (musl-cross from coreboot version bound crosscomipler, from which coreboot is built)

1- Reuse existing cache for all modules and patches created digest's hash. (If a single module or patch changes, we have cache miss)
2- Reuse existing coreboot and musl-cross-make created digest's hash (If a patch was added to current coreboot, or new coreboot version was added in coreboot module definition, we have a cache miss. Otherwise, we reuse the whole musl-cross-make and coreboot cache for current used versions.)
3- Reuse existing musl-cross-make created digest's hash matching cache (If musl-cross-make module didn't change, we don't rebuild it)
Per linuxboot#947 (comment) proposition
@tlaurion
Copy link
Collaborator

tlaurion commented Jan 3, 2021

@Tonux599 the coreboot cache was kind of useless, since it was not caching musl-cross-make.
Consequently, reusing coreboot cache would have required musl-cross-make to be rebuilt.
Please look at #950, where caching mechanism is more documented directly in CircleCI conf.

tlaurion added a commit to tlaurion/heads that referenced this pull request Jan 3, 2021
The idea here is a cache to restore from (musl-cross from coreboot version bound crosscomipler, from which coreboot is built)

1- Reuse existing cache for all modules and patches created digest's hash past build matching cache.
(If a single module or patch changes, we have cache miss.)
2- Reuse existing coreboot and musl-cross-make created digest's hash past build's matching cache
(If a patch was added to current coreboot, or new coreboot version was added in coreboot module definition, we have a cache miss.)
3- Reuse existing musl-cross-make created digest's hash past build matching cache
(If musl-cross-make module didn't change, we don't rebuild it.)

Per linuxboot#947 (comment) proposition
@tlaurion
Copy link
Collaborator

tlaurion commented Jan 3, 2021

@Tonux599 not sure how to implement/extend this hack, but it seems it could work (without adding maintenance like implied in this PR at each coreboot release.)

Does this ignite some more proper hacks in your mind?

user@localhost:~/heads$ cd build/coreboot-4.13/util/crossgcc/tarballs/
user@localhost:~/heads/build/coreboot-4.13/util/crossgcc/tarballs$ ../buildgcc -u | xargs wget
--2021-01-03 17:46:55--  https://ftpmirror.gnu.org/gmp/gmp-6.2.0.tar.xz
Resolving ftpmirror.gnu.org (ftpmirror.gnu.org)... 209.51.188.200
Connecting to ftpmirror.gnu.org (ftpmirror.gnu.org)|209.51.188.200|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://ftp-gnu-org.ip-connect.vn.ua/gmp/gmp-6.2.0.tar.xz [following]
--2021-01-03 17:46:57--  https://ftp-gnu-org.ip-connect.vn.ua/gmp/gmp-6.2.0.tar.xz
Resolving ftp-gnu-org.ip-connect.vn.ua (ftp-gnu-org.ip-connect.vn.ua)... 91.236.251.14
Connecting to ftp-gnu-org.ip-connect.vn.ua (ftp-gnu-org.ip-connect.vn.ua)|91.236.251.14|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2012444 (1.9M) [application/x-xz]
Saving to: ‘gmp-6.2.0.tar.xz.1’

gmp-6.2.0.tar.xz.1                     46%[================================>                                       ] 919.75K   139KB/s    
[...]
user@localhost:~/heads/build/coreboot-4.13/util/crossgcc/tarballs$ ls
acpica-unix2-20200717.tar.gz  gcc-8.3.0.tar.xz	gmp-6.2.0.tar.xz.1  mpfr-4.1.0.tar.xz
binutils-2.35.tar.xz	      gmp-6.2.0.tar.xz	mpc-1.2.0.tar.gz    nasm-2.15.03.tar.bz2

And then continuing with boards compilation as in normal builds? Where to implement this, so that coreboot tarballs are extracted, prior of first board build? That could be in CI config, prior of first build of each version, requiring maintainer to move boards around (and comment CI per coreboot version)?

EDIT: the precedent download a whole crap of unneeded stuff, including llvm gdb...

tlaurion added a commit to tlaurion/heads that referenced this pull request Jan 4, 2021
The idea here is a cache to restore from (musl-cross from coreboot version bound crosscomipler, from which coreboot is built)

1- Reuse existing cache for all modules and patches created digest's hash past build matching cache.
(If a single module or patch changes, we have cache miss.)
2- Reuse existing coreboot and musl-cross-make created digest's hash past build's matching cache
(If a patch was added to current coreboot, or new coreboot version was added in coreboot module definition, we have a cache miss.)
3- Reuse existing musl-cross-make created digest's hash past build matching cache
(If musl-cross-make module didn't change, we don't rebuild it.)

Per linuxboot#947 (comment) proposition
@tlaurion
Copy link
Collaborator

tlaurion commented Jan 5, 2021

#950 was merged. @Tonux599 close this one?

@Tonux599
Copy link
Contributor Author

Tonux599 commented Jan 5, 2021

#950 was merged. @Tonux599 close this one?

Yep no problem 👍

@Tonux599 Tonux599 closed this Jan 5, 2021
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.

2 participants