-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathllvm-setup.sh
executable file
·45 lines (36 loc) · 1.35 KB
/
llvm-setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
# Script to set up binutils for Gold linker, LLVM, etc
# compile the gold linker
set -x
apt-get -y install libgmp-dev libmpfr-dev
apt reinstall binutils # Create a sane information
yes | ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
ssh -o StrictHostKeyChecking=no user@github.com
git clone --depth 1 git://sourceware.org/git/binutils-gdb.git binutils
mkdir gold-build
cd gold-build
../binutils/configure --enable-gold --enable-plugins --disable-werror
make all-gold -j8
cd ..
# change the system-wide linker after backing it up
mv /usr/bin/ld /usr/bin/ld-bkup
ln -s "$(realpath ./gold-build/gold/ld-new)" /usr/bin/ld
# Build the LLVM compiler
git submodule update --init
cd llvm12
export BINUTILS_INC_DIR="$(realpath ../binutils/include)"
cmake -S llvm -B debug-build -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug \
-DLLVM_ENABLE_DUMP=ON -DLLVM_ENABLE_PROJECTS="compiler-rt;clang;lld" \
-DLLVM_BINUTILS_INCDIR=$BINUTILS_INC_DIR -DCMAKE_INSTALL_PREFIX=/usr/
cd debug-build
make -j8
cd ../..
echo "export PATH=\"$(realpath ./llvm12/debug-build/bin):\$PATH\"" >> ~/.bashrc
echo "export LLVM_DIR=\"$(realpath ./llvm12/debug-build/bin)\"" >> ~/.bashrc
LLVM_DIR=$(realpath ./llvm12/debug-build/bin)
echo "export LLVM_HOME=$LLVM_DIR" >> ~/.bashrc
source ~/.bashrc
cd kaleidoscope-pta
./build.sh debug
cd ../