[llvm-config] Append the version number to the llvm-config executable name #150774
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
llvm-configexecutable name.So
llvm-configis installed asllvm-config-20andllvm-configis a symlink to it, the same wayclangis installed asclang-20andclangis a symlink to it.I target the LLVM 20 branch because this is the one I currently use in my development and after having rebased to the current
mainit failed to build and I couldn't test it. By targeting the LLVM 20 branch I made sure I could test it and I tested it and I confirm it works.I expect this to be merged in any maintained LLVM version branch.
The motivation for this is that when building Mesa, the Mesa build system selected my system's clang 20 because there was a
llvm-config-20in path that had an higher version number than thellvm-configexecutable I built myself for the sole purpose of being used by my Mesa build. But the system LLVM had a different minor version than the one I built and because Mesa linked against the system LLVM but ran against my self-built LLVM, it faced symbol mismatches and crashed.It is then required by users to have their self-built LLVM to append the version number to the
llvm-configbinary. In fact the distribution packages already do that, and the system LLVM that mismatched my Mesa build comes from the official apt.llvm.org that is already doing that.So by merging this patch we also make possible to simplify all the distro-specific packaging scripts by making possible to remove all the custom code to create after installation a symlink with an appended version number.
This code is the same code used by for appending the version number to the
clangbinary, copy-pasted and adapted to thellvm-configbinary.There is one known drawback, it's that once the version number is set in CMake configuration by CMake the first time CMake runs, that version will not change when pulling the repository and the LLVM version has been bumped (
LLVM_CONFIG_EXECUTABLE_VERSIONis set once for all). This limitation is not specific to this branch and is already true for theclangbinary and thelibclanglibrary (CLANG_EXECUTABLE_VERSIONandLIBCLANG_LIBRARY_VERSIONare set once for all). Fixing that much general problem is not within the scope of that PR.