Skip to content

Instantly share code, notes, and snippets.

@mossheim
Created November 21, 2020 19:14
Show Gist options
  • Save mossheim/2f80768eb2429b285902f8898182ae2d to your computer and use it in GitHub Desktop.
Save mossheim/2f80768eb2429b285902f8898182ae2d to your computer and use it in GitHub Desktop.
#!/bin/env bash
set -uoe pipefail
echo "This script will do the following:"
echo "- install or update gcc, cmake, and make"
echo "- clone the llvm project to ./llvm-project"
echo "- install clang-format to /usr/local/clang-format-8"
echo "- leave ./llvm-project intact when done"
echo ""
echo "Sudo is used to install packages and install clang-format"
echo ""
echo "The entire process should take 3-10 minutes."
echo ""
printf "If you are OK with that, enter 'y', anything else to quit: "
read YESNO
case $YESNO in
y)
;;
*)
exit 0
;;
esac
sudo pacman -Sy --needed gcc cmake make
git clone https://github.com/llvm/llvm-project --branch llvmorg-8.0.1 --depth 1
cd llvm-project
git apply - <<EOF
diff --git a/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h b/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
index 9e3478e9f..f54e8d161 100644
--- a/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
+++ b/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
@@ -4,6 +4,8 @@
#include "llvm/Demangle/Compiler.h"
#include "llvm/Demangle/StringView.h"
#include <array>
+#include <cstdint>
+#include <string>
class OutputStream;
EOF
mkdir build
cd build
cmake ../llvm -DCMAKE_BUILD_TYPE=Release -G"Unix Makefiles" -DLLVM_ENABLE_PROJECTS=clang \
-DCMAKE_INSTALL_PREFIX=/usr/local/clang-format-8
make -j$(nproc) clang-format
sudo make install-clang-format
echo "----------------------------------------------------------------------------------------------------"
echo ""
echo "Success!"
echo ""
echo "clang-format location (SC_CLANG_FORMAT): /usr/local/clang-format-8/bin/clang-format"
echo "clang-format-diff.py location (SC_CLANG_FORMAT_DIFF): /usr/local/clang-format-8/share/clang/clang-format-diff.py"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment