-
Notifications
You must be signed in to change notification settings - Fork 1
/
psu-setup.sh
executable file
·136 lines (109 loc) · 5.2 KB
/
psu-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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
function msg() {
echo -ne '\033[01;36m'
echo "$1"
echo -ne '\033[00m'
}
function die() {
echo -ne '\033[01;31m'
echo "$1"
echo -ne '\033[00m'
exit 1
}
# Some quick checks before we get started with side effects
if [ -z "$1" ]; then
die "usage: ./psu-setup.sh /vagrant # replace \"/vagrant\" with directory to your thread library if not in the VM"
fi
if [ ! -d "$1" ]; then
die "argument '$1' is not a directory"
fi
if [ "`pwd | cut -d/ -f2`" = "vagrant" ]; then
die "cannot run from the VM's shared host directory (/vagrant)! please clone the repository in $HOME instead."
fi
# Get started with side effects.
# skip this if patch already applied
if ! grep -- "--std=gnu++0x" src/bochs-2.6.8/instrument/landslide/Makefile.in >/dev/null; then
# PSU cluster machines don't have a gcc new enough for gnu++11
# -N: forwards (don't ask if seems reversed); -f: force (don't ask questions)
patch -N -f -p1 < src/patches/psu-gnu0xx.patch || die "couldn't patch landslide for gnu0xx"
fi
# set paths appropriately and configure bochs
sed -i 's/--with-x/--without-x/' ./prepare-workspace.sh || die "couldn't sed prepare"
sed -i 's/--with-x11/--without-x11/' ./prepare-workspace.sh || die "couldn't sed prepare"
./prepare-workspace.sh || die "couldn't prepare workspace"
VERSION_FILE=current-git-commit.txt
rm -f "$VERSION_FILE"
git show | head -n 1 > "$VERSION_FILE"
# Build iterative deepening wrapper.
cd id || die "couldn't cd into id"
sed -i 's@system_cpus / 2@system_cpus@' option.c || msg "couldn't adjust default cpu number"
make || die "couldn't build id program"
# Put config.landslide into place.
cd ../pebsim || die "couldn't cd into pebsim"
rm -f current-psu-group.txt
echo "$1" > current-psu-group.txt
rm -f current-architecture.txt
echo "psu" > current-architecture.txt
CONFIG=config.landslide.pathos-p2
[ -f $CONFIG ] || die "couldn't find appropriate config: $CONFIG"
rm -f config.landslide
ln -s $CONFIG config.landslide || die "couldn't create config symlink"
rm -f bochsrc.txt || die "couldn't clear symlink bochsrc.txt"
ln -s bochsrc-pebbles.txt bochsrc.txt || die "couldn't create bochsrc symlink"
# Import and build student p2.
cd p2-basecode || die "couldn't cd into thread library basecode directory"
# update makefile for different userspace library requiremence, if necessary
# but also supports cmu projecce
if [ ! -d "$1/user/libautostack" ]; then
msg "setting up PSU-compatible (no libautostack) build"
if grep "^STUDENT_LIBS_EARLY *=.*libautostack.a" Makefile >/dev/null; then
# libautostack present; remove it
sed -i 's/\(^STUDENT_LIBS_EARLY *=.*\) libautostack.a/\1/' Makefile || die "couldn't remove libautostack from libs-early"
fi
else
msg "setting up CMU-compatible (yes libautostack) build"
if ! grep "^STUDENT_LIBS_EARLY *=.*libautostack.a" Makefile >/dev/null; then
# libautostack missing; add it back
sed -i 's/\(^STUDENT_LIBS_EARLY *=.*\)/\1 libautostack.a/' Makefile || die "couldn't add libauto to libs-early"
fi
fi
if [ -d "$1/user/libatomic" ]; then
msg "setting up PSU-compatible (libatomic) build"
if ! grep "^STUDENT_LIBS_LATE *=.*libatomic.a" Makefile >/dev/null; then
# libatomic missing; add it
sed -i 's/\(^STUDENT_LIBS_LATE *=.*\)/\1 libatomic.a/' Makefile || die "couldn't add libatomic to libs-late"
fi
else
msg "setting up CMU-compatible (no libatomic) build"
if grep "^STUDENT_LIBS_LATE *=.*libatomic.a" Makefile >/dev/null; then
# libatomic present; remove it again
sed -i 's/\(^STUDENT_LIBS_LATE *=.*\) libatomic.a/\1/' Makefile || die "couldn't remove libatomic from libs-late"
fi
fi
# PSU's cluster machines suck
if grep -- "-fno-aggressive-loop-optimizations" Makefile >/dev/null; then
if ! gcc -c -x c -fno-aggressive-loop-optimizations /dev/null -o /dev/null 2>/dev/null; then
msg "gcc version is too old; disabling -fno-aggressive-loop-optimizations"
sed -i 's/-fno-aggressive-loop-optimizations//' Makefile || die "couldn't disable it"
fi
fi
P2DIR="$PWD"
msg "Importing your project into '$P2DIR' - look there if something goes wrong..."
./import-p2.sh "$1" || die "could not import your thread library"
make veryclean # i have no idea why i need this but you get some real twilight zone looking builds without it
make || die "source code import was successful, but build failed (from '$PWD')"
cp bootfd.img ../../pebsim/ || die "couldn't move floppy disk image (from '$PWD')"
cp kernel ../../pebsim/ || die "couldn't move kernel binary (from '$PWD')"
# symbol table and line numbers files are generated per-test-case in pebsim/build.sh
rm -f ../../src/bochs-2.6.8/instrument/landslide/line_numbers.h || die "couldn't clear linenrs"
touch ../../src/bochs-2.6.8/instrument/landslide/line_numbers.h || die "couldn't make linenrs"
cd ../../pebsim/ || die "couldn't cd into pebsim"
msg "Setting up Landslide..."
rm -f ../work/modules/landslide/student_specifics.h
export LANDSLIDE_CONFIG=config.landslide
./build.sh || die "Failed to compile landslide. Please send a tarball of this directory to Ben for assistance."
echo -ne '\033[01;33m'
echo "Note: Your thread library was imported into '$P2DIR'. If you wish to make changes to it, recommend editing it in '$1' then running this script again."
echo -ne '\033[01;32m'
echo "Setup successful. Can now run ./landslide."
echo -ne '\033[00m'