-
Notifications
You must be signed in to change notification settings - Fork 5
/
rust-1.64.0-build.sh
executable file
·102 lines (79 loc) · 3.6 KB
/
rust-1.64.0-build.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
# immediately stop building if error occurs
set -e
# install prerequisite package
echo "build rustc & llvm"
export WORKING_DIR=`pwd`/../src
export RUSTC=`pwd`/../src/rustc-1.64.0/compiler
# install rustc - commit : 94f8ee1f7c27b749f84ce9dbea0762975aaa7770
git clone https://github.com/rust-lang/rust.git
export RUST=$PWD/rust
cd rust
git reset --hard 94f8ee1f7c27b749f84ce9dbea0762975aaa7770
# set config.toml
cp $WORKING_DIR/rustc-1.64.0/config-file/config.toml $RUST
cd $RUST
# Set Mir Instrumentation
# echo "Seting for Compiler-rt in Rust Compiler"
# rm src/bootstrap/native.rs
# cp $WORKING_DIR/rustc-1.64.0/src/bootstrap/native.rs $RUST/src/bootstrap
echo "Setting for MIR Instrumentation"
echo "[START]Remove the rust compiler file"
echo "[Remove compiler/rustc_codegen_ssa/src/mir/statement.rs]"
rm compiler/rustc_codegen_ssa/src/mir/statement.rs
echo "[Remove compiler/rustc_codegen_ssa/src/mir/block.rs]"
rm compiler/rustc_codegen_ssa/src/mir/block.rs
echo "[Remove compiler/rustc_codegen_ssa/src/mir/operand.rs]"
rm compiler/rustc_codegen_ssa/src/mir/operand.rs
echo "[Remove compiler/rustc_codegen_ssa/src/traits/builder.rs]"
rm compiler/rustc_codegen_ssa/src/traits/builder.rs
echo "[Remove compiler/rustc_codegen_llvm/src/builder.rs]"
rm compiler/rustc_codegen_llvm/src/builder.rs
echo "[END]Remove the rust compiler file"
echo "[START]Copy the rust compiler file"
echo "[Copy compiler/rustc_codegen_ssa/src/mir/statement.rs]"
cp $RUSTC/rustc_codegen_ssa/src/mir/statement.rs $RUST/compiler/rustc_codegen_ssa/src/mir
echo "[Copy compiler/rustc_codegen_ssa/src/mir/block.rs]"
cp $RUSTC/rustc_codegen_ssa/src/mir/block.rs $RUST/compiler/rustc_codegen_ssa/src/mir
echo "[Copy compiler/rustc_codegen_ssa/src/mir/operand.rs]"
cp $RUSTC/rustc_codegen_ssa/src/mir/operand.rs $RUST/compiler/rustc_codegen_ssa/src/mir
echo "[Copy compiler/rustc_codegen_ssa/src/traits/builder.rs]"
cp $RUSTC/rustc_codegen_ssa/src/traits/builder.rs $RUST/compiler/rustc_codegen_ssa/src/traits
echo "[Copy compiler/rustc_codegen_llvm/src/builder.rs]"
cp $RUSTC/rustc_codegen_llvm/src/builder.rs $RUST/compiler/rustc_codegen_llvm/src
echo "[END]Copy the rust compiler code to our rust file"
# build rust compiler
echo "[Build Rust Compiler]"
cd $RUST
python3 ./x.py build --stage 1 -j 8
echo "[Build Finished]"
# echo "[Setting Rust LLVM & Opt files]"
# # only delete llvm-finished-building for making llvm build fast
# rm build/x86_64-unknown-linux-gnu/llvm/llvm-finished-building
# export OPT_FILES=$WORKING_DIR/rustc-1.64.0/opt-files
# pushd $RUST
# rm src/llvm-project/llvm/include/llvm/Analysis/CallPrinter.h
# popd
# cp $OPT_FILES/CallPrinter.h $RUST/src/llvm-project/llvm/include/llvm/Analysis/
# pushd $RUST
# rm src/llvm-project/llvm/lib/Analysis/CallPrinter.cpp
# popd
# cp $OPT_FILES/CallPrinter.cpp $RUST/src/llvm-project/llvm/lib/Analysis/
# pushd $RUST
# rm src/llvm-project/llvm/lib/Passes/PassBuilder.cpp
# rm src/llvm-project/llvm/lib/Passes/PassRegistry.def
# popd
# cp $OPT_FILES/PassBuilder.cpp $RUST/src/llvm-project/llvm/lib/Passes
# cp $OPT_FILES/PassRegistry.def $RUST/src/llvm-project/llvm/lib/Passes
# pushd $RUST
# rm src/llvm-project/llvm/test/Other/heat-colors-graphs.ll
# popd
# cp $OPT_FILES/heat-colors-graphs.ll $RUST/src/llvm-project/llvm/test/Other/
# cp $OPT_FILES/heat-colors-multigraph.ll $RUST/src/llvm-project/llvm/test/Other/
# echo "[Finished Rust LLVM & Opt files]"
# # build rust compiler with LLVM changed
# echo "[Rebuild Rust Compiler with LLVM & Opt files changed]"
# cd $RUST
# python3 ./x.py build --stage 1 -j 4
# echo "[Finished Rust Compiler with LLVM & Opt files changed]"
# echo "[All Rust Stuffs are Ready!]"