Home Explore Blog Models CI



nixpkgs

2nd chunk of `pkgs/development/compilers/llvm/README.md`
3cab048d3f0b8cbd2577d744d44caeb0959c7c4044d242ec0000000100000802
     note: keeping build directory '/tmp/nix-build-compiler-rt-libc-unstable-2022-25-07.drv-20'
     error: 1 dependencies of derivation '/nix/store/ndbbh3wrl0l39b22azf46f1n7zlqwmag-clang-wrapper-unstable-2022-25-07.drv' failed to build
     ```

     Notice the `Hunk #1 Failed at 487` line.
     The lines above show us that the `purity.patch` failed on `lib/Driver/ToolChains/Gnu.cpp` when compiling `clang`.

 3. The task now is to cross reference the hunks in the purity patch with
    `lib/Driver/ToolCahins/Gnu.cpp.orig` to see why the patch failed.
    The `.orig` file will be in the build directory referenced in the line `note: keeping build directory ...`;
    this message results from the `--keep-failed` flag.

 4. Now you should be able to open whichever patch failed, and the `foo.orig` file that it failed on.
    Correct the patch by adapting it to the new code and be mindful of whitespace;
    which can be an easily missed reason for failures.
    For cases where the hunk is no longer needed you can simply remove it from the patch.

 This is fine for small corrections, but when more serious changes are needed, it's better to use git.

 1. Clone the LLVM monorepo at https://github.com/llvm/llvm-project/

 2. Check out the revision we were using before.

 3. Use `patch -p1 < path/to-path` in the project subdirectories to apply the patches and commit.

 4. Use `git rebase HEAD^ --onto <dest>` to rebase the patches onto the new revision we are trying to build, and fix all conflicts.

 5. Use `git diff HEAD^:<project> HEAD:<project>` to get subdir diff to write back to Nixpkgs.

## Information on our current patch sets

### "GNU Install Dirs" patches

Use CMake's [`GNUInstallDirs`](https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html) to support multiple outputs.

Previously, LLVM just hard-coded `bin`, `include`, and `lib${LLVM_TARGET_PREFIX}`.
We are making it use these variables.

For the older LLVM versions, these patches live in https://github.com/Ericson2314/llvm-project branches `split-prefix`.

Title: Advanced LLVM `llvm_git` Patch Management and Specific Patch Sets
Summary
This section continues the guidance on updating `llvm_git` patches, reiterating the process of identifying failed hunks in patches, cross-referencing them with `.orig` files in the preserved build directory, and correcting them while being mindful of whitespace or removing obsolete hunks. For more significant patch modifications, a Git-based approach is recommended: cloning the LLVM monorepo, checking out the previous revision, applying existing patches, rebasing them onto the new revision to resolve conflicts, and then generating new diffs using `git diff` for Nixpkgs. The document also provides information on current patch sets, specifically the "GNU Install Dirs" patches. These patches utilize CMake's `GNUInstallDirs` to support multiple output directories (e.g., for `bin`, `include`, `lib`), replacing previously hard-coded paths. For older LLVM versions, these patches are located in the `split-prefix` branches of Ericson2314's `llvm-project` repository.