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

fix: ggml: fix vulkan-shaders-gen build #10448

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sparkleholic
Copy link
Contributor

The vulkan-shaders-gen target was not being built correctly in case of cross-compilation.
Other outputs need to be built for the cross compile target, but vulkan-shaders-gen needs to be built for the host.

@sparkleholic
Copy link
Contributor Author

sparkleholic commented Nov 25, 2024

@jeffbolznv , @0cc4m
This fix is ​​needed for cross-compilation.
vulkan-shaders-gen is needed at build time, so arch should be the same as host pc, but other binaries (libggml, libllama, etc.) are needed at runtime.
Therefore, CMAKE compilation variables that apply when building the llama.cpp project should not apply when building vulkan-shaders-gen in case of cross-compilation.

@0cc4m
Copy link
Collaborator

0cc4m commented Nov 25, 2024

@sparkleholic @jeffbolznv I understand, I'm sorry that a few PRs are getting delayed because of me. I'm currently ill, but getting better and I should be able to catch up with all of them later this week.

Maybe you can resolve the merge conflict already?

@jeffbolznv
Copy link
Collaborator

No rush, get well!

I'm not an expert at cmake or cross compilation, so I don't think I should review the change.

The vulkan-shaders-gen target was not being built correctly
in case of cross-compilation.
Other outputs need to be built for the cross compile target,
but vulkan-shaders-gen needs to be built for the host.
@sparkleholic
Copy link
Contributor Author

@0cc4m
master rebased to resolve conflicts.
I didn't mean to rush you. I sincerely hope you feel better soon. :)

@0cc4m
Copy link
Collaborator

0cc4m commented Nov 27, 2024

I can confirm this still works as usual on my system, but I'm also not a CMake expert. Maybe @bandoti can take a look?

@bandoti
Copy link
Contributor

bandoti commented Nov 27, 2024

I am happy to take a look. The one thing that comes to mind here after initial look through is being able to customize the compiler in this case. In particular, gcc and g++ are hardcoded.

It would be worthwhile to add a default toolchain file for the build and allow one to customize by passing -DGGML_SHADERS_GEN_CROSS_TOOLCHAIN=... (or similar)

This would allow one to use a desire toolchain—maybe clang, etc.

And a lot of those switches passed to ExternalProject_Add() can of course be moved to the toolchain file instead.

- Add GGML_SHADERS_GEN_TOOLCHAIN CMake option.
- Auto-detect host toolchain if not set.
@sparkleholic
Copy link
Contributor Author

@bandoti
Thank you for the valuable feedback.

I have updated the code to handle the GGML_SHADERS_GEN_TOOLCHAIN variable. When this variable is provided, the specified file is used. If it is not set, the code generates a temporary host toolchain file by detecting the host environment's compiler.

Please review the updated code once again.

@github-actions github-actions bot added Vulkan Issues specific to the Vulkan backend ggml changes relating to the ggml tensor library for machine learning labels Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ggml changes relating to the ggml tensor library for machine learning Vulkan Issues specific to the Vulkan backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants