Skip to content

[patch_repo] allow script to detect if patches have been applied already#337

Open
bojle wants to merge 2 commits into
qualcomm:qualcomm-softwarefrom
bojle:patch_repo_patch
Open

[patch_repo] allow script to detect if patches have been applied already#337
bojle wants to merge 2 commits into
qualcomm:qualcomm-softwarefrom
bojle:patch_repo_patch

Conversation

@bojle

@bojle bojle commented May 5, 2026

Copy link
Copy Markdown
Contributor

In the current implementation, re-running builds fails as git apply fails to apply patches to _deps/* due to the patches already being applied. This patch fixes that by detecting if patches have been applied using git apply --reverse checks.

In the current implementation, re-running builds fails as git apply
fails to apply patches to _deps/* due to the patches already being
applied. This patch fixes that by detecting if patches have been applied
using git apply --reverse checks.

Signed-off-by: Shreeyash Pandey <shrpand@qti.qualcomm.com>
@bojle bojle force-pushed the patch_repo_patch branch from f1ced90 to b998949 Compare May 5, 2026 08:00
@bojle

bojle commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

I've implemented the detection logic for 'git apply' for now. I can implement something similar for 'git am' too.

Comment thread qualcomm-software/cmake/patch_repo.py
@apazos

apazos commented May 5, 2026

Copy link
Copy Markdown
Contributor

Hi @bojle,

It seems you are trying to apply the patch files over and over in your local build, not following the instructions to skip patching:

https://github.com/qualcomm/cpullvm-toolchain/blob/release/qualcomm-software/22.x/qualcomm-software/docs/developing.md#manually-checking-out-and-patching-dependencies
(Set DFETCHCONTENT_FULLY_DISCONNECTED=ON)

https://github.com/qualcomm/cpullvm-toolchain/blob/qualcomm-software/qualcomm-software/docs/building.md#patching
(Do not repeat the command python3 qualcomm-software/cmake/patch_repo.py --method apply qualcomm-software/patches/llvm-project)

No need to change the github workflow, as Navaneeth pointed out, the workflow creates a new space every time

@bojle

bojle commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

Hi @apazos

Please see my other comment #337 (comment)

In local workflows, any change to cmake variables will trigger the patch application script which ultimately fails if its not the first application. Only workaround so far is the cmake variable to disable it (which is a manual process), if its just a python script applying the patch, why can't it check and fail gracefully when its not the first application?

@apazos

apazos commented May 5, 2026

Copy link
Copy Markdown
Contributor

The proper cmake command should include -DFETCHCONTENT_FULLY_DISCONNECTED=ON for your local build.

@jonathonpenix jonathonpenix left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the current situation can be a bit painful, and I think something like this makes sense to me?

The one thing I'm unsure about is ex: if we have a patch that is essentially an "early merge" from upstream (while it is still under review, etc.) and that patch eventually comes in from upstream would this treat the patch as already applied?

I wonder if it'd be helpful to error in that case (though arguably people should keep an eye on when their patches will come in). I don't think we could actually distinguish the two cases either. I think this is only a minor concern though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this?

I guess it should be NFC given the current defaults, but seems unrelated to this patch.

apply is important here I think, so I don't think it is necessarily an issue to be explicit about that

@bojle bojle May 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it as patch_repo.py uses 'apply' as the default method, and providing --method apply is just an affirmation. Thought it might make the command line cleaner (fewer flags to remember). That said, I don't have a problem with explicitly providing --method.

Comment thread qualcomm-software/docs/developing.md Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a limitation that this can't happen with am?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No limitation, I added support for just git apply as I am unsure why we have two variants to do the same thing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above, do we actually care about capture_output/text?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both can be removed, they are remnants from testing. Although, capture_output can be useful as without it, git will emit its error messages to the stdout when forward and reverse check are run (either one is bound to fail atleast once) - capture_output keeps it clean.

Signed-off-by: Shreeyash Pandey <shrpand@qti.qualcomm.com>
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.

4 participants