Repository navigation
Expand file tree
/
Copy pathrelink.llvm
More file actions
executable file
·138 lines (110 loc) · 2.92 KB
/
Copy pathrelink.llvm
File metadata and controls
executable file
·138 lines (110 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<
8000
div data-line-number="21" class="react-line-number react-code-text" style="padding-right:16px">2122
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
137
#!/bin/bash
############################
#
# Author: Koustubha Bhat
# Date : 3-April-2014
# VU University, Amsterdam.
#
############################
set -o errexit
MYPWD=`pwd`
MINIX_ROOT=
MINIX_LLVM_DIR=
TARGET_MODULES=
MINIX_MODS=
STATIC_LIBS=
LDFLAGS_PLACEHOLDER=" "
# Set default values to essential variables.
: ${GENERATE_MAP="no"}
: ${C="servers,drivers"}
function usage()
{
echo "C=<target Minix module> $0 [<static library name>]"
echo
echo "Examples:"
echo "C=pm,vfs ./$0 dummy"
echo "C=drivers ./$0 dummy"
echo
}
function check_current_dir()
{
#Make sure we are running from the root dir of the Minix sources
if [ -d ./minix/drivers ] && [ -d ./minix/servers ] ; then
MINIX_ROOT="${MYPWD}"
elif [ -d ../../minix/drivers ] && [ -d ../../minix/servers ]; then
MINIX_ROOT="${MYPWD}/../.."
else
echo "Please run the script from either of the following locations:"
echo "> Root of the Minix sources."
echo " OR"
echo "> minix/llvm directory of the Minix sources."
exit 1
fi
MINIX_LLVM_DIR="${MINIX_ROOT}/minix/llvm"
}
function find_static_libs()
{
local stat_libs_llvmapps=
local stat_libs_minix=
local install_dir_save=
stat_libs_llvmapps=`build_llvm_libs $*`
install_dir_save=${INSTALL_DIR}
INSTALL_DIR=${MINIX_LLVM_BIN_DIR}
stat_libs_minix=`build_llvm_libs $*`
INSTALL_DIR=${install_dir_save}
echo "${stat_libs_llvmapps} ${stat_libs_minix}"
}
#Make sure we are running from the right directory
check_current_dir
# Arguments check
if [ "$1" == "--help" ] || [ "$1" == "-h" ]; then
usage
exit 1
fi
# set up the bridge to llvm-apps repository and initialize
. ${MINIX_LLVM_DIR}/minix.inc
. ${ROOT}/apps/scripts/include/configure.llvm.inc
echo "LLVM root
614C
directory is set to :"
echo " ${ROOT}"
echo ".so and .bcc binaries of LLVM passes set to be picked up from:"
echo " ${INSTALL_DIR}"
echo " and"
echo " ${MINIX_LLVM_BIN_DIR}"
echo
# Picking up the selected modules
if [ "${GENERATE_MAP}" != "" ] && [[ ${GENERATE_MAP} =~ [yY][eE][sS] ]]; then
generate_modules_map
fi
STATIC_LIBS=`find_static_libs $*`
TARGET_MODULES=`echo $C | sed -e "s/,/ /g"`
for m in ${TARGET_MODULES}
do
for p in `get_modules_path $m`
do
MINIX_MODS="${MINIX_MODS} $p"
done
done
# Show info
echo "relink.llvm: Executing with following parameters..."
echo "LIBRARIES : $*"
echo "Target Minix modules : ${MINIX_MODS}"
echo
cd ${MINIX_ROOT}
for m in ${MINIX_MODS}
do
echo "Relinking $m ..."
n=`get_module_name $m`
if [ "" == "$n" ]; then
echo "Error: Couldn't fetch the module name for $m"
continue
fi
clean_module $n $m "relink"
if [ "${STATIC_LIBS}"!="" ]; then
STATIC_LIBS=`echo ${STATIC_LIBS} | sed -e "s/\ /\\\ /g"`
LDFLAGS_PLACEHOLDER="BITCODE_LD_FLAGS_1ST.$n=${STATIC_LIBS}"
fi
env "`echo ${LDFLAGS_PLACEHOLDER}`" MKBITCODE=yes \
${TOOLDIR}/nbmake-${ARCH} -C $m
echo
done
cd ${MYPWD}