-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
fix build-info.h for git submodules #1289
Conversation
Fix issue with git submodule and CMake in llama.cppIn the discussion on #1232 (comment) there was a suggestion to include llama.cpp as a git submodule and include the CMake via add_subdirectory(external/llama.cpp).
However, when using a git submodule, the .git file in the submodule directory is actually a text file containing a reference to the actual git directory:
In that case, the current implementation in CMakeLists.txt causes an error. Line 93 checks for the existence of the .git file:
Since the file exists, the condition passes. However, line 103 has a dependency on the
This causes the following error:
To fix this issue, we can add backslash to line 93 to check that .git/ is a folder.
This ensures that the .git file is a directory that can contain the required index file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. The git commands should work for submodules. However the observation, that the .git/index
file in that case does not exist is correct. Can the DEPENDS
be applied to directories too?
I don't understand why we need those lines: Lines 97 to 105 in 67c7779
Is the build script not executed every time anyway? Lines 90 to 91 in 67c7779
|
I removed the suggested lines 97-105 and the empty line at 106. Tested with a project that contained llama.cpp as a submodule and it compiles now. Good. I do get this warning: CMake Warning at llama.cpp/CMakeLists.txt:97 (message):
Git repository not found; to enable automatic generation of build info,
make sure Git is installed and the project is a Git repository. |
not sure what your issue is, but I tried those changes and it works fine now for me. eg output of benchmark:
|
Oh, my mistake. I had not properly cleaned build directory on rebuild. It works now without errors. Thank you! |
Perhaps this was a case of me trying to be too clever. We only need to reevaluate when git changes, but then when you first open the project a bunch of errors would show up because |
Actually, we do need the |
@DannyDaemonic the line
causes issues
bacause
so I am going to put the |
If llama.cpp is added as a project submodule, .git is a text file containing gitdir. Adding extra backslash .git/ to if(EXISTS) makes it sure that .git/ is a folder containing index.
Removed custom command to rebuild build-info.h when .git/index changes. No longer triggers cmake compilation error if llama.cpp is included as a submodule.
@kuvaus please check my changes, I force pushed onto your branch. |
Nice. Looks like it builds without errors for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to find a project to test this on. Ended up using kuvaus' llama-chat.
Looks good to me; smart fix @Green-Sky.
@kuvaus you merged in master literally seconds before I wanted to click merge. 🤣 |
If llama.cpp is added as a project submodule, .git is a text file containing gitdir. Adding extra backslash .git/ to if(EXISTS) makes it sure that .git/ is a folder containing index.