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

reproducible engine build #271

Open
jwinarske opened this issue Mar 20, 2023 · 0 comments
Open

reproducible engine build #271

jwinarske opened this issue Mar 20, 2023 · 0 comments

Comments

@jwinarske
Copy link
Contributor

Requirement is to support a reproducible engine library.

This means the file can be compared to prior build, and there is not difference.

The solution revolves around removal of .git folders and any processes dependent on the .git folder.

Round 1

gclient sync --revision ada363ee93b17cfe31587b5102679885cb40837e --no-history --shallow
find . -name .git -type d -print0|xargs -0 rm -r --
./flutter/tools/gn --unoptimized --no-goma

It fails with

Generating GN files in: out/host_debug_unopt
ERROR at //flutter/shell/version/version.gni:17:7: Script returned non-zero exit code.
      exec_script("//flutter/build/git_revision.py",
      ^----------
Current dir: /mnt/raid10/flutter-engine/src/out/host_debug_unopt/
Command: vpython3 /mnt/raid10/flutter-engine/src/flutter/build/git_revision.py --repository /mnt/raid10/flutter-engine/src/flutter
Returned 1.
stderr:

fatal: not a git repository (or any parent up to mount point /mnt)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Traceback (most recent call last):
  File "/mnt/raid10/flutter-engine/src/flutter/build/git_revision.py", line 58, in <module>
    sys.exit(main())
  File "/mnt/raid10/flutter-engine/src/flutter/build/git_revision.py", line 51, in main
    version = get_repository_version(repository)
  File "/mnt/raid10/flutter-engine/src/flutter/build/git_revision.py", line 28, in get_repository_version
    version = subprocess.check_output([
  File "/home/joel/depot_tools/.cipd_bin/3.8/lib/python3.8/subprocess.py", line 415, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/home/joel/depot_tools/.cipd_bin/3.8/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', '-C', '/mnt/raid10/flutter-engine/src/flutter', 'rev-parse', 'HEAD']' returned non-zero exit status 128.

See //flutter/tools/path_ops/BUILD.gn:5:1: whence it was imported.
import("//flutter/shell/version/version.gni")
^-------------------------------------------
See //flutter/BUILD.gn:93:9: which caused the file to be included.
        "//flutter/tools/path_ops",
        ^-------------------------

I update flutter/build/git_revision.py to return value of the engine I just pulled:

def get_repository_version(repository):
  return 'ada363ee93b17cfe31587b5102679885cb40837e'

./flutter/tools/gn --unoptimized --no-goma returns without error.

Build attempt fails with:

 ./flutter/tools/gn --unoptimized --no-goma --no-prebuilt-dart-sdk
Generating GN files in: out/host_debug_unopt
Generating compile_commands took 25ms
Done. Made 1276 targets from 349 files in 946ms
[joel@air src]$ ninja -C out/host_debug_unopt
ninja: Entering directory `out/host_debug_unopt'
[0/1] Regenerating ninja files
...
[0/1] Regenerating ninja files
ninja: error: manifest 'build.ninja' still dirty after 100 tries

More later

arnout pushed a commit to buildroot/buildroot that referenced this issue Sep 29, 2023
There are many issues with this package:

- The release tarballs from https://github.com/flutter/engine are in no state
  to compile. They are only for the use of gclient to download a source
  directory structure suitable to build the Flutter engine! If you download,
  extract and attempt to run `./tools/gn --no-goma --no-prebuilt-dart-sdk`, you
  receive the error message:
  `No such file or directory: 'flutter/flutter/third_party/gn/gn.'

  But wait! Wasn't the gn binary just called? No, that's a wrapper in the
  Flutter source tree that formats arguments to call the real gn binary.
  The real gn is not provided in the tarball but is downloaded via gclient
  (among many other supporting repositories.)

  Even worse, the flutter buildsystem depends on the .git dirs being present.
  (meta-flutter/meta-flutter#271) This dependency
  means it is not possible to create a reproducible tarball from the downloaded
  sources, which is why there is no .hash file provided.

  I have asked the flutter project to release full tarballs suitable for
  compiling here: flutter/flutter#130734

- Flutter engine includes a patched copy of clang that must be used to compile.
  Using a Buildroot-build clang results in linking warning and errors.
  As such, we depend on LLVM_ARCH_SUPPORTS but use the included clang for
  building. On the plus side, this saves time having to compile clang.

- flutter-engine relies on the "PUB_CACHE", that is provided by flutter-sdk,
  so we need a build dependency, even if no tool from host-flutter-sdk-bin
  is used to build flutter-engine

Tested with:
  - Debian 11 and 12
  - Ubuntu 18.04, 20.04, and 22.04
  - Fedora 38
  - Per-package directories

Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
[yann.morin.1998@free.fr:
  - search gclient.py from PATH
  - indent shell script with 4 spaces
  - reorganise schell script with prepare/cleanup
  - tweak comment about weirdness of flutter buildsystem
  - use suitable-extactor and TAR_OPTIONS
  - use FLUTTER_SDK_BIN_PUB_CACHE
  - add dependency to host-futter-sdk-bin (Adam)
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
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

No branches or pull requests

1 participant