Skip to content

Instantly share code, notes, and snippets.

@brant-ruan
Created April 3, 2024 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brant-ruan/da7458f623325864a1112abf13b1e46c to your computer and use it in GitHub Desktop.
Save brant-ruan/da7458f623325864a1112abf13b1e46c to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root. Please use 'sudo' to run it."
exit 1
fi
if [ $# -eq 0 ]; then
echo "Usage: $0 <version>"
exit 1
fi
VERSION=$1
LLVM_BIN_PATH="/usr/bin"
if [ -f "${LLVM_BIN_PATH}/clang-${VERSION}" ]; then
ln -sf "clang-${VERSION}" "${LLVM_BIN_PATH}/clang"
else
echo "clang-${VERSION} not found."
fi
for tool in $(ls ${LLVM_BIN_PATH}/llvm-*-${VERSION} 2>/dev/null); do
base_tool=$(echo $tool | sed -E "s/-${VERSION}$//")
if [ -f "$tool" ]; then
ln -sf "$(basename $tool)" "${base_tool}"
else
echo "$tool not found."
fi
done
echo "Symbolic links have been created for LLVM/Clang version ${VERSION}."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment