Stella Laurenzo | 14a944b | 2021-02-22 21:01:43 -0800 | [diff] [blame] | 1 | # Debugging releases playbook |
| 2 | |
| 3 | ## Tools and Locations |
| 4 | |
| 5 | * `.github/workflows/build_package.yml`: Release packaging jobs |
| 6 | * `build_tools/github_actions/build_dist.py`: Main script to build various |
| 7 | release packages (for all platforms). We usually use this when reproing to |
| 8 | approximate exactly what the CI does. Assumes a subdirectory of `main_checkout` |
| 9 | and writes builds to `iree-build` and `iree-install` as a peer of it. To use |
| 10 | locally, just symlink your source dir as `main_checkout` in an empty |
| 11 | directory (versus checking out). |
| 12 | |
| 13 | ## Manylinux releases |
| 14 | |
| 15 | The Linux releases are done in a manylinux2014 docker container. At the time of |
| 16 | this writing, it has gcc 9.3.1 and Python versions 3.5 - 3.9 under `/opt/python`. |
| 17 | Note that this docker image approximates a 2014 era RHEL distro, patched with |
| 18 | backported (newer) dev packages. It builds with gcc and BFD linker unless if |
| 19 | you arrange otherwise. `yum` can be used to get some packages. |
| 20 | |
| 21 | Get a docker shell (see exact docker image in build_package.yml workflow): |
| 22 | |
| 23 | ```shell |
| 24 | docker run --rm -it -v $(pwd):/work/main_checkout stellaraccident/manylinux2014_x86_64-bazel-3.7.2:latest /bin/bash |
| 25 | ``` |
| 26 | |
| 27 | Remember that docker runs as root unless if you take steps otherwise. Don't |
| 28 | touch write files in the `/work/main_checkout` directory to avoid scattering |
| 29 | root owned files on your workstation. |
| 30 | |
| 31 | The default system Python is 2.x, so you must select one of the more modern |
| 32 | ones: |
| 33 | |
| 34 | ```shell |
| 35 | export PATH=/opt/python/cp39-cp39/bin:$PATH |
| 36 | ``` |
| 37 | |
| 38 | |
| 39 | Build core installation: |
| 40 | |
| 41 | ```shell |
| 42 | # (from within docker) |
| 43 | cd /work |
| 44 | python ./main_checkout/build_tools/github_actions/build_dist.py main-dist |
| 45 | |
| 46 | # Also supports: |
| 47 | # main-dist |
| 48 | # py-runtime-pkg |
| 49 | # py-xla-compiler-tools-pkg |
| 50 | # py-tflite-compiler-tools-pkg |
| 51 | # py-tf-compiler-tools-pkg |
| 52 | ``` |
| 53 | |
| 54 | You can `git bisect` on the host and keep running the above in the docker |
| 55 | container. Note that every time you run `build_dist.py`, it deletes the cmake |
| 56 | cache but otherwise leaves the build directory (so it pays the configure cost |
| 57 | but is otherwise incremental). You can just `cd iree-build` and run `ninja` |
| 58 | for faster iteration (after the first build or if changing cmake flags). |
| 59 | Example: |
| 60 | |
| 61 | Extended debugging in the manylinux container: |
| 62 | |
| 63 | ```shell |
| 64 | cd /work/iree-build |
| 65 | # If doing extended debugging in the container, these may make you happier. |
Stella Laurenzo | a2868a9 | 2021-02-23 00:15:16 -0800 | [diff] [blame] | 66 | yum install ccache devtoolset-9-libasan-devel gdb |
| 67 | |
| 68 | # Get an LLVM symbolizer. |
| 69 | yum install llvm9.0 |
| 70 | ln -s /usr/bin/llvm-symbolizer-9.0 /usr/bin/llvm-symbolizer |
Stella Laurenzo | 14a944b | 2021-02-22 21:01:43 -0800 | [diff] [blame] | 71 | |
| 72 | # You can manipulate cmake flags. These may get you a better debug experience. |
| 73 | cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DIREE_ENABLE_ASAN=ON -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=gold -DIREE_ENABLE_CCACHE=ON . |
| 74 | |
| 75 | ninja |
| 76 | |
| 77 | # Or you may need this if buggy LLVM tools (like mlir-tblgen) are leaking :( |
| 78 | ASAN_OPTIONS="detect_leaks=0" ninja |
| 79 | ``` |
| 80 | |
| 81 | Other tips: |
| 82 | |
| 83 | * If debugging the runtime, you may have a better time just building the |
| 84 | Release mode `main-dist` package above once, which will drop binaries in the |
| 85 | `iree-install` directory. Then build the `py-runtime-pkg` or equiv and |
| 86 | iterate further in the build directory. Ditto for TF/XLA/etc. |
not-jenni | 952804a | 2021-09-08 14:17:27 -0700 | [diff] [blame^] | 87 | |
| 88 | ## Testing releases on your fork |
| 89 | |
| 90 | To avoid interrupting the regular releases published on the IREE github, you |
| 91 | can test any changes to the release process on your own fork. Some setup is |
| 92 | required before these github actions will work on your fork and development |
| 93 | branch. |
| 94 | |
| 95 | To run |
| 96 | [`schedule_snapshot_release.yml`](https://github.com/google/iree/blob/main/.github/workflows/schedule_snapshot_release.yml), |
| 97 | comment out |
| 98 | [this line](https://github.com/google/iree/blob/392449e986493bf710e3da637ebf807715da9ffe/.github/workflows/schedule_snapshot_release.yml#L14): |
| 99 | ```yaml |
| 100 | # Don't run this in everyone's forks. |
| 101 | if: github.repository == 'google/iree' |
| 102 | ``` |
| 103 | |
| 104 | And change the branch from 'main' to the branch you are developing on |
| 105 | [here](https://github.com/google/iree/blob/392449e986493bf710e3da637ebf807715da9ffe/.github/workflows/schedule_snapshot_release.yml#L37): |
| 106 | ```yaml |
| 107 | - name: Pushing changes |
| 108 | uses: ad-m/github-push-action@v0.6.0 |
| 109 | with: |
| 110 | github_token: ${{ secrets.WRITE_ACCESS_TOKEN }} |
| 111 | branch: main |
| 112 | tags: true |
| 113 | ``` |
| 114 | |
| 115 | To speed up |
| 116 | [`build_package.yml`](https://github.com/google/iree/blob/main/.github/workflows/build_package.yml), |
| 117 | you may want to comment out some of the builds |
| 118 | [here](https://github.com/google/iree/blob/392449e986493bf710e3da637ebf807715da9ffe/.github/workflows/build_package.yml#L34-L87). |
| 119 | The |
| 120 | [`py-pure-pkgs`](https://github.com/google/iree/blob/392449e986493bf710e3da637ebf807715da9ffe/.github/workflows/build_package.yml#L52) |
| 121 | build takes only ~2 minutes and the |
| 122 | [`py-runtime-pkg`](https://github.com/google/iree/blob/392449e986493bf710e3da637ebf807715da9ffe/.github/workflows/build_package.yml#L39) |
| 123 | build takes ~5, while the others can take several hours. |
| 124 | |
| 125 | From your development branch, you can manually run the |
| 126 | [Schedule Snapshot Release](https://github.com/google/iree/actions/workflows/schedule_snapshot_release.yml) |
| 127 | action, which invokes the |
| 128 | [Build Native Release Packages](https://github.com/google/iree/actions/workflows/build_package.yml) |
| 129 | action, which finally invokes the |
| 130 | [Validate and Publish Release](https://github.com/google/iree/actions/workflows/validate_and_publish_release.yml) |
| 131 | action. If you already have a draft release and know the release id, package |
| 132 | version, and run ID from a previous Build Native Release Packages run, you can |
| 133 | also manually run just the Validate and Publish Release action. |