-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make run-clang-tidy.sh pick a default LLVM installation #8904
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
Merged
+61
−35
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,27 @@ set -e | |
|
|
||
| ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
|
|
||
| ## | ||
|
|
||
| # We standardize a common LLVM/Clang version for this script. | ||
| # Note that this is totally independent of the version of LLVM that you | ||
| # are using to build Halide itself. If you don't have the right version | ||
| # installed, you can usually install what you need easily via: | ||
| # | ||
| # sudo apt-get install llvm-X clang-X libclang-X-dev clang-tidy-X | ||
| # export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-X | ||
| # | ||
| # On macOS: | ||
| # | ||
| # brew install llvm@X | ||
| # export CLANG_TIDY_LLVM_INSTALL_DIR=/opt/homebrew/opt/llvm@X | ||
| # | ||
| # Where X matches the EXPECTED_VERSION below. | ||
|
|
||
| EXPECTED_VERSION=21 | ||
|
|
||
| ## | ||
|
|
||
| usage() { echo "Usage: $0 [-j MAX_PROCESS_COUNT] [-f]" 1>&2; exit 1; } | ||
|
|
||
| get_thread_count () { | ||
|
|
@@ -13,8 +34,10 @@ get_thread_count () { | |
|
|
||
| if [ "$(uname)" == "Darwin" ]; then | ||
| patch_file () { sed -i '' -E "$@"; } | ||
| _DEFAULT_LLVM_LOCATION="/opt/homebrew/opt/llvm@$EXPECTED_VERSION" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MacPorts? 🥺 |
||
| else | ||
| patch_file () { sed -i -E "$@"; } | ||
| _DEFAULT_LLVM_LOCATION="/usr/lib/llvm-$EXPECTED_VERSION" | ||
| fi | ||
|
|
||
| J=$(get_thread_count) | ||
|
|
@@ -41,32 +64,22 @@ if [ -n "${FIX}" ]; then | |
| echo "Operating in -fix mode!" | ||
| fi | ||
|
|
||
| # We are currently standardized on using LLVM/Clang 21 for this script. | ||
| # Note that this is totally independent of the version of LLVM that you | ||
| # are using to build Halide itself. If you don't have LLVM21 installed, | ||
| # you can usually install what you need easily via: | ||
| # | ||
| # sudo apt-get install llvm-21 clang-21 libclang-21-dev clang-tidy-21 | ||
| # export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-21 | ||
| # | ||
| # On macOS: | ||
| # | ||
| # brew install llvm@21 | ||
| # export CLANG_TIDY_LLVM_INSTALL_DIR=/opt/homebrew/opt/llvm@21 | ||
|
|
||
| if [ -z "$CLANG_TIDY_LLVM_INSTALL_DIR" ]; then | ||
| echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM installation dir for this script." | ||
| exit | ||
| if [ -d "${_DEFAULT_LLVM_LOCATION}" ]; then | ||
| CLANG_TIDY_LLVM_INSTALL_DIR="${_DEFAULT_LLVM_LOCATION}" | ||
| else | ||
| echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM installation dir for this script." | ||
| exit | ||
| fi | ||
| fi | ||
|
|
||
| echo "CLANG_TIDY_LLVM_INSTALL_DIR = ${CLANG_TIDY_LLVM_INSTALL_DIR}" | ||
|
|
||
| VERSION=$("${CLANG_TIDY_LLVM_INSTALL_DIR}/bin/clang-tidy" --version) | ||
| if [[ ${VERSION} =~ .*version\ 21.* ]] | ||
| then | ||
| echo "clang-tidy version 21 found." | ||
| if [[ ${VERSION} =~ .*version\ $EXPECTED_VERSION.* ]]; then | ||
| echo "clang-tidy version $EXPECTED_VERSION found." | ||
| else | ||
| echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM 21 install!" | ||
| echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM $EXPECTED_VERSION install!" | ||
| exit 1 | ||
| fi | ||
|
|
||
|
|
@@ -94,10 +107,11 @@ if [[ $(${CC} --version) =~ .*Homebrew.* ]]; then | |
| SDKROOT="$(xcrun --show-sdk-path)" | ||
| # TOOLCHAINROOT="$(xcrun --show-toolchain-path)" | ||
| TOOLCHAINROOT="$(cd "$(dirname "$(xcrun --find clang)")"/../.. && pwd)" | ||
| RCDIR="$(xcrun clang -print-resource-dir)" | ||
| cat > "${CLANG_TIDY_BUILD_DIR}/toolchain.cmake" << EOF | ||
| set(CMAKE_SYSROOT "${SDKROOT}") | ||
| set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES | ||
| "${TOOLCHAINROOT}/usr/lib/clang/17/include" | ||
| "${RCDIR}/include" | ||
| "${SDKROOT}/usr/include" | ||
| "${TOOLCHAINROOT}/usr/include" | ||
| "${SDKROOT}/System/Library/Frameworks" | ||
|
|
||
Oops, something went wrong.
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.
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.
Would be great if you add support for MacPorts. I recently discovered macports. They are actually enabling people with older macbooks to continue working. I have a 2015 MacBook Pro, and recent LLVM versions through Homebrew are like a day worth of compiling from source. MacPorts maintains builds for older OSes, and installation is much leaner and cleaner.