3 ############################
5 # Author: Koustubha Bhat
7 # VU University, Amsterdam.
9 ############################
22 # Set default values for essential variables
23 : ${GENERATE_MAP="no"}
24 : ${C="servers,drivers"}
28 echo "C=<target Minix module(s)> $0 [<LLVM-pass name> ...]"
31 echo "C=pm,vfs ./$0 dummy"
32 echo "C=drivers ./$0 dummy"
34 echo "Additional arguments to the passes may be passed through \${LLVM_PASS_ARGS}."
38 function check_current_dir
()
40 #Make sure we are running from the root dir of the Minix sources
41 if [ -d .
/minix
/drivers
] && [ -d .
/minix
/servers
] ; then
43 elif [ -d ..
/..
/minix
/drivers
] && [ -d ..
/..
/minix
/servers
]; then
44 MINIX_ROOT
="${MYPWD}/../.."
46 echo "Please run the script from either of the following locations:"
47 echo "> Root of the Minix sources."
49 echo "> minix/llvm directory of the Minix sources."
53 MINIX_LLVM_DIR
="${MINIX_ROOT}/minix/llvm"
64 if [ "$1" == "--help" ] ||
[ "$1" == "-h" ]; then
72 # Default value for llvmargs not specified deliberately
74 if [ -f "${INSTALL_DIR}/${llvmpass}.so" ]; then
75 llvmpass_path
="${INSTALL_DIR}/${llvmpass}.so"
76 elif [ -f "${MINIX_LLVM_BIN_DIR}/${llvmpass}.so" ]; then
77 llvmpass_path
="${MINIX_LLVM_BIN_DIR}/${llvmpass}.so"
81 if [ "$llvmpass_path" != "" ]; then
82 LLVMPASS_PATHS
+=" -load=${llvmpass_path}"
84 LLVMPASS_PATHS
+=" -${llvmpass}"
87 if [ ${exit_flag} == 1 ]; then
88 echo "Searched in the following location(s):"
89 echo " ${INSTALL_DIR}"
90 echo " ${MINIX_LLVM_BIN_DIR}"
94 LLVMARGS
=" ${LLVM_PASS_ARGS}"
98 #Make sure we are running from the root dir of the Minix sources
101 # set up the bridge to llvm-apps repository and initialize
102 .
${MINIX_LLVM_DIR}/minix.inc
103 [ ! -f ${ROOT}/apps
/scripts
/include
/configure.llvm.inc
] || .
${ROOT}/apps
/scripts
/include
/configure.llvm.inc
108 if [ "$C" == "" ]; then
112 if [ "${GENERATE_MAP}" != "" ] && [[ ${GENERATE_MAP} =~
[yY
][eE
][sS
] ]]; then
116 : ${OPTFLAGS="-disable-opt -disable-internalize -disable-inlining -load ${MINIX_LLVM_DIR}/bin/weak-alias-module-override.so -weak-alias-module-override"}
118 # If we are really instrumenting with some pass...
119 if [ "${LLVMPASS_PATHS}" != "" ]; then
120 OPTFLAGS
=" ${OPTFLAGS} ${LLVMPASS_PATHS} ${LLVMARGS}"
123 TARGET_MODULES
=`echo $C | sed -e "s/,/ /g"`
125 for m
in ${TARGET_MODULES}
127 for p
in `get_modules_path $m`
129 MINIX_MODS
="${MINIX_MODS} $p"
134 echo "Build.llvm: Executing with following parameters..."
135 echo "LLVM pass : ${LLVMPASS}"
136 echo "LLVM pass arguments : ${LLVMARGS}"
137 echo "Target Minix modules : ${MINIX_MODS}"
138 echo "OPTFLAGS value : ${OPTFLAGS}"
143 for m
in ${MINIX_MODS}
145 echo "Instrumenting $m ..."
146 n
=`get_module_name $m`
147 if [ "" == "$n" ]; then
148 echo "Error: Couldn't fetch the module name for $m"
152 OPTFLAGS
=`echo ${OPTFLAGS} | sed -e "s/\ /\\\ /g"`
153 OPTFLAGS_PLACEHOLDER
="OPTFLAGS.$n=${OPTFLAGS}"
155 (env
"`echo ${OPTFLAGS_PLACEHOLDER}`" MKBITCODE
=yes \
156 ${TOOLDIR}/nbmake-
${ARCH} -C $m all
install && echo "INFO: $m successfully instrumented." ) ||
echo "ERROR: Failed instrumenting $m"