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

Do not apply patches if repo is a not a git repo. #539

Merged
merged 3 commits into from
Jul 3, 2024

Conversation

haonanya
Copy link
Contributor

@haonanya haonanya commented Jul 3, 2024

No description provided.

@haonanya
Copy link
Contributor Author

haonanya commented Jul 3, 2024

also drafted patches for 15,16,17,18 and main.
#540
#541
#542
#543
#544

Co-authored-by: Wenju He <wenju.he@intel.com>
Co-authored-by: Wenju He <wenju.he@intel.com>
Copy link
Contributor

@wenju-he wenju-he left a comment

Choose a reason for hiding this comment

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

LGTM

@haonanya haonanya merged commit e03e0e3 into intel:ocl-open-140 Jul 3, 2024
1 check passed
@haonanya haonanya deleted the fix-git-return-140 branch July 3, 2024 13:55
@th0ma7
Copy link

th0ma7 commented Jul 4, 2024

@haonanya I tested the patch and at first glance it looked like working just fine. But when further replaying with it thru a new PR aiming for LLVM 14.x it occured that it still fails such as:

-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") 
-- Using SPIR-V Headers from
          /home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1/SPIRV-Headers
-- Checking for one of the modules 'SPIRV-Tools'
-- [OPENCL-CLANG] Using Clang source code direcotry: /home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1/clang
-- [OPENCL-CLANG] Using SPIRV-LLVM-Translator source code directory: /home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1/SPIRV-LLVM-Translator
-- [OPENCL-CLANG] Patching repository /home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1
-- [OPENCL-CLANG] Validating release/14.x in repository
fatal: ambiguous argument 'release/14.x': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
-- [OPENCL-CLANG] ref release/14.x not exists in repository, using current HEAD:470e7a2a7c50af3b63cb4b3e3090aa38266f4978
-- [OPENCL-CLANG] Switched to a new branch 'ocl-open-140' which starts from ref : 470e7a2a7c50af3b63cb4b3e3090aa38266f4978
-- [OPENCL-CLANG] Checking if patch 1ca45b5f5725a447ded14c0096df39f2751c4e9a is present in repository
fatal: Not a valid commit name 1ca45b5f5725a447ded14c0096df39f2751c4e9a
error: sha1 information is lacking or useless (clang/lib/Frontend/InitPreprocessor.cpp).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
-- [OPENCL-CLANG] Not present - Applying: Remove __IMAGE_SUPPORT__ macro for SPIR
Patch failed at 0001 Remove __IMAGE_SUPPORT__ macro for SPIR
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

CMake Error at /home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1/opencl-clang/cmake/modules/CMakeFunctions.cmake:164 (message):
  [OPENCL-CLANG] Failed to apply patch!
Call Stack (most recent call first):
  /home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1/opencl-clang/CMakeLists.txt:155 (apply_patches)


-- Configuring incomplete, errors occurred!
See also "/home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1/opencl-clang.build/CMakeFiles/CMakeOutput.log".
See also "/home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1/opencl-clang.build/CMakeFiles/CMakeError.log".
make[2]: *** [../../mk/spksrc.cross-cmake.mk:150: cmake_configure_target] Error 1
make[2]: Leaving directory '/home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140'
make[1]: *** [../../mk/spksrc.supported.mk:71: build-arch-x64-7.1] Error 1
make[1]: Leaving directory '/home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140'

Although after cleaning-up the build directory and re-executing it would succeed such as:

-- Looking for include file sys/inotify.h
-- Looking for include file sys/inotify.h - found
-- Not building amdgpu-arch: hsa-runtime64 not found
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") 
-- Using SPIR-V Headers from
          /home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1/SPIRV-Headers
-- Checking for one of the modules 'SPIRV-Tools'
-- [OPENCL-CLANG] Using Clang source code direcotry: /home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1/clang
-- [OPENCL-CLANG] Using SPIRV-LLVM-Translator source code directory: /home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1/SPIRV-LLVM-Translator
-- [OPENCL-CLANG] Patching repository /home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1
Already on 'ocl-open-140'
-- [OPENCL-CLANG] No patches in /home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1/opencl-clang/patches/spirv
-- Registering Bye as a pass plugin (static build: OFF)
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    PREFERRED_LLVM_VERSION


-- Build files have been written to: /home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1/opencl-clang.build
===>  Compiling for opencl-clang
===>  - Ninja compile
===>  - Ninja build path = /home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1/opencl-clang-ocl-open-140//home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1/opencl-clang.build
===>  - Use NASM = 0

Further investigating showed that it had changed my branch I was working on under the spksrc repository to:

$ git status
On branch ocl-open-140
You are in the middle of an am session.
  (fix conflicts and then run "git am --continue")
  (use "git am --skip" to skip this patch)
  (use "git am --abort" to restore the original branch)

nothing to commit, working tree clean

Explaining the following messages at the second pass:

-- [OPENCL-CLANG] Patching repository /home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1
Already on 'ocl-open-140'
-- [OPENCL-CLANG] No patches in /home/spksrc/ffmpeg-opencl-140/spksrc/cross/intel-opencl-clang-140/work-x64-7.1/opencl-clang/patches/spirv

@haonanya
Copy link
Contributor Author

haonanya commented Jul 4, 2024

Hi, @th0ma7, opencl-clang is always creating ocl-open-140 branch based on release/14.x branch when build opencl-clang, if you changes source of that branch and the changes are related to patches/clang dir, it's possible that git apply would fail. If you have ocl-open-140 branch already, git apply will not perform and just switch to ocl-open-140 branch when build opencl-clang.

@th0ma7
Copy link

th0ma7 commented Jul 4, 2024

Well that is where the build issue is as the assumption is wrong. Make is being called from an upper level from within a totally unrelated git repository where ocl assumes wrongly that it can change branch. My use case could be seen as ocl being a nested git within the spksrc repository.

Further, to build ocl I'm directly downloading the source tar ball of the ocl-140 branch, rather than git cloning. Therefore the ocl source has no git artifact at all just like any other source package I'm building. Thus when the build process is being called it should have a way to detect this and skip the patching process.

Spksrc (git) -> work directory (git ignored) -> ocl (plain source tree)

Thus when the build is being called from make at spkrc level, the branch switching made at ocl cmake level is affecting the wrong repository and is unnecessary.

@haonanya
Copy link
Contributor Author

haonanya commented Jul 5, 2024

@th0ma7 , I see, I will take a look.

haonanya added a commit that referenced this pull request Jul 9, 2024
)

follow up #539.
Also add an option to control patch apply which is default on. Pass
-DAPPLY_PATCHES=OFF will skip patch apply process.
haonanya added a commit that referenced this pull request Aug 26, 2024
…it repo. (#540)

[Backport] Do not apply patches if repo is a not a git repo.
#539
[Backport] Do not apply patches if sub non-git repo is located in a git
repo. #545
Also add an option to control patch apply which is default on. Pass
-DAPPLY_PATCHES=OFF will skip patch apply process.
haonanya added a commit that referenced this pull request Aug 26, 2024
…it repo. (#541)

[Backport] Do not apply patches if repo is a not a git repo.
#539
[Backport] Do not apply patches if sub non-git repo is located in a git
repo. #545
Also add an option to control patch apply which is default on. Pass
-DAPPLY_PATCHES=OFF will skip patch apply process.
Update LLVM_BASE_REVISION.
haonanya added a commit that referenced this pull request Aug 26, 2024
…it repo. (#542)

[Backport] Do not apply patches if repo is a not a git repo.
#539
[Backport] Do not apply patches if sub non-git repo is located in a git
repo. #545
Also add an option to control patch apply which is default on. Pass
-DAPPLY_PATCHES=OFF will skip patch apply process.
Update LLVM_BASE_REVISION.
haonanya added a commit that referenced this pull request Aug 26, 2024
…it repo. (#543)

[Backport] Do not apply patches if repo is a not a git repo.
#539
[Backport] Do not apply patches if sub non-git repo is located in a git
repo. #545
Also add an option to control patch apply which is default on. Pass
-DAPPLY_PATCHES=OFF will skip patch apply process.
Update LLVM_BASE_REVISION.
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.

3 participants