From: David van Moolenbroek Date: Fri, 13 Nov 2015 11:12:33 +0000 (+0100) Subject: Remove llvm-apps scripts X-Git-Url: http://zhaoyanbai.com/repos/%22http:/static/doc/zpipe.c?a=commitdiff_plain;h=refs%2Fchanges%2F36%2F3236%2F2;p=minix.git Remove llvm-apps scripts These utilities were already largely broken and are now also obsolete. In addition, they have too many issues (for example, dependencies on Linux specifics) to keep around. The few usable features left in the clientctl script are not LLVM specific and, if anything, should be recreated somewhere else. Change-Id: Id5645cf21837bcee069f560ae72570fb38f75adc --- diff --git a/minix/llvm/build.llvm b/minix/llvm/build.llvm deleted file mode 100755 index 934dd9d72..000000000 --- a/minix/llvm/build.llvm +++ /dev/null @@ -1,162 +0,0 @@ -#!/bin/bash - -############################ -# -# Author: Koustubha Bhat -# Date : 3-April-2014 -# VU University, Amsterdam. -# -############################ - -set -o errexit - -MYPWD=`pwd` -MINIX_ROOT= -MINIX_LLVM_DIR= -LLVMARGS= -LLVMPASS_PATHS= -TARGET_MODULES= -MINIX_MODS= - -# Set default values for essential variables -: ${GENERATE_MAP="no"} -: ${C="servers,fs,net,drivers"} - -function usage() -{ - echo "C= $0 [ ...]" - echo - echo "Examples:" - echo "C=pm,vfs ./$0 dummy" - echo "C=drivers ./$0 dummy" - echo - echo "Additional arguments to the passes may be passed through \${LLVM_PASS_ARGS}." - 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 check_args() -{ - local llvmpass= - local llvmpass_path= - local exit_flag=0 - - if [ $# -ge 1 ]; then - - if [ "$1" == "--help" ] || [ "$1" == "-h" ]; then - usage - exit 1 - fi - - for p in "$@" ; - do - llvmpass=$p - # Default value for llvmargs not specified deliberately - - if [ -f "${INSTALL_DIR}/${llvmpass}.so" ]; then - llvmpass_path="${INSTALL_DIR}/${llvmpass}.so" - elif [ -f "${MINIX_LLVM_BIN_DIR}/${llvmpass}.so" ]; then - llvmpass_path="${MINIX_LLVM_BIN_DIR}/${llvmpass}.so" - else - llvmpass_path="" - fi - if [ "$llvmpass_path" != "" ]; then - LLVMPASS_PATHS+=" -load=${llvmpass_path}" - fi - LLVMPASS_PATHS+=" -${llvmpass}" - done - - if [ ${exit_flag} == 1 ]; then - echo "Searched in the following location(s):" - echo " ${INSTALL_DIR}" - echo " ${MINIX_LLVM_BIN_DIR}" - exit 1 - fi - - LLVMARGS=" ${LLVM_PASS_ARGS}" - fi -} - -#Make sure we are running from the root dir of the Minix sources -check_current_dir - -. ${MINIX_LLVM_DIR}/minix.inc - -# Arguments check -check_args "$@" - -if [ "$C" == "" ]; then - C="hello" -fi - -if [ "${GENERATE_MAP}" != "" ] && [[ ${GENERATE_MAP} =~ [yY][eE][sS] ]]; then - generate_modules_map -fi - -: ${OPTFLAGS="-disable-opt -disable-inlining -load ${MINIX_LLVM_DIR}/bin/weak-alias-module-override.so -weak-alias-module-override"} - -# If we are really instrumenting with some pass... -if [ "${LLVMPASS_PATHS}" != "" ]; then - OPTFLAGS=" ${OPTFLAGS} ${LLVMPASS_PATHS} ${LLVMARGS}" -fi - -TARGET_MODULES=`echo " $C " | sed -e "s/,/ /g" -e "s/ rd / ramdisk memory /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 "Build.llvm: Executing with following parameters..." -echo "LLVM pass : $@" -echo "LLVM pass arguments : ${LLVMARGS}" -echo "Target Minix modules : ${MINIX_MODS}" -echo "OPTFLAGS value : ${OPTFLAGS}" -echo - -cd ${MINIX_ROOT} - -OPTFLAGS=`echo ${OPTFLAGS} | sed -e 's/\\$/$$/g'` -for m in ${MINIX_MODS} -do - echo "Instrumenting $m ..." - - n=`get_module_name $m` - if [ "" == "$n" ]; then - echo "Error: Couldn't fetch the module name for $m" - continue - fi - if [ "$n" == "ramdisk" ] || [ "$n" == "memory" ]; then - (cd minix/llvm && C=$n ./relink.llvm) - continue - fi - clean_module $n $m - - ( ${TOOLDIR}/nbmake-${ARCH} -C $m all install MKBITCODE=yes OPTFLAGS="${OPTFLAGS}" \ - && echo "INFO: $m successfully instrumented." - ) - echo -done - -cd ${MYPWD} diff --git a/minix/llvm/clientctl b/minix/llvm/clientctl deleted file mode 100755 index 4cbad5676..000000000 --- a/minix/llvm/clientctl +++ /dev/null @@ -1,465 +0,0 @@ -#!/bin/bash - -set -o errexit - -cd $(dirname $0) - -CMD=$(pwd)/$(basename $0) -mode=$1 -shift || mode="no_action" - -ROOT=../.. -MYPWD=$( pwd ) -IMAGE=$( readlink -f $ROOT/minix_x86.img ) -DISK=$( readlink -f $ROOT/minix_x86.disk ) -RC=$( readlink -f $ROOT/minix_x86.rc ) -CONF=$( readlink -f $ROOT/minix_x86.conf ) -MKFS=$( readlink -f $ROOT/../obj.i386/tooldir*/bin/nbmkfs.mfs ) -MAKE=$( readlink -f $ROOT/../obj.i386/tooldir*/bin/nbmake-i386 ) -ADDR2LINE=$( readlink -f $ROOT/../obj.i386/tooldir*/bin/i586-elf32-minix-addr2line ) - -BATCH=${BATCH:-0} -HYPER=${HYPER:-} -DISK_SIZE=${DISK_SIZE:-1024} -DISK_MNT=${DISK_MNT:-/media/minix-disk} -OUT=${OUT:-S} # S=STDOUT, F=FILE, C=CONSOLE, P=PTY -APPEND=${APPEND:-} - -TIMEOUT=${TIMEOUT:-60} -BOOT_TIMEOUT=${BOOT_TIMEOUT:-45} - -function rc_create { - cat <&1 - if [ "${!conf_var}" == "NULL" ]; then - if [ $BATCH -eq 0 ]; then - read -r $conf_var - echo -en "\e[1A" - else - eval $conf_var="" - fi - fi - if [ "${!conf_var}" == "" ]; then - eval $conf_var=$default - fi - ( - echo -en "\e[0K\r" - echo -n "$line" - echo ${!conf_var} - ) 2>&1 - RET=${!conf_var} -} - -function get_conf_value_repeat -{ - local check=$1 - shift - local conf_var=$1 - while true - do - get_conf_value "$@" - eval $check $RET || break - eval $conf_var="NULL" - done -} - -function __get_conf_value_check_list -{ - for v in $( echo $VALUES | sed "s/|/ /g" ) - do - [ "$1" == "$v" ] && return 1 - done - return 0 -} - -function get_conf_value_list -{ - get_conf_value_repeat __get_conf_value_check_list "$@" -} - -function get_conf_value_yn -{ - VALUES="y|n" get_conf_value_list "$@" -} - -function __get_conf_value_check_int_range -{ - min=$( echo $VALUES | sed "s/|/ /g" | cut -d' ' -f 1 ) - max=$( echo $VALUES | sed "s/|/ /g" | cut -d' ' -f 2 ) - case $min in - ''|*[!0-9]*) return 0 ;; - esac - case $max in - ''|*[!0-9]*) return 0 ;; - esac - [ $1 -ge $min ] && [ $1 -le $max ] && return 1 - return 0 -} - -function get_conf_value_int_range -{ - get_conf_value_repeat __get_conf_value_check_int_range "$@" -} - -function get_conf_value_nic -{ - VALUES="0|13" get_conf_value_int_range "$@" -} - -function __get_conf_value_check_string -{ - return 1 -} - -function get_conf_value_string -{ - get_conf_value_repeat __get_conf_value_check_string "$@" -} - -function disk_mount { - local mnt=$1 - echo "* Mounting ${DISK} to $mnt..." - [ -d $mnt ] || sudo mkdir -p $mnt - disk_umount &> /dev/null || true - sudo mount -o loop $DISK $mnt || true -} - -function disk_umount { - echo "* Unmounting ${DISK}..." - sudo umount $DISK -} - -function disk_build { - local size=$1 - local tmp_mnt=$( mktemp -d /tmp/clientctl-XXXXX ) - echo "* Building ${size} MB disk image..." - dd if=/dev/zero of=$DISK bs=1M count=$size - $MKFS $DISK - echo "* Setting up /ext/etc/rc file executed at startup..." - rc_create > $RC - disk_mount $tmp_mnt - [ -d $tmp_mnt/etc ] || mkdir -p $tmp_mnt/etc - rc_ext_default_create > $tmp_mnt/etc/rc - disk_umount - rm -rf $tmp_mnt -} - -function minix_conf { - conf_init - nics="virbr0 virbr1 eth0 eth1 wlan0 wlan1" - for n in $nics - do - host_ip_addr_default=$( ifconfig $n 2> /dev/null | perl -nle'/dr:(\S+)/ && print $1' ) - [ -z "$host_ip_addr_default" ] || break - done - get_conf_value_nic guest_nic "[NIC] Which nic do you want to use on MINIX (see MINIX' \`netconf -c\`)?" 7 - get_conf_value_string host_ftp_user "[FTP] Username for FTP server running on the host?" ftptest - get_conf_value_string host_ftp_pass "[FTP] Password for FTP server running on the host?" ftptest - get_conf_value_string host_ftp_port "[FTP] Port for FTP server running on the host?" 21 - get_conf_value_string host_ftp_dir "[FTP] Base directory for FTP server running on the host?" /home/$host_ftp_user - get_conf_value_string host_ip_addr "[HOSTS] Host ip address?" $host_ip_addr_default - - echo "" - echo "* Setting up configuration settings in $CONF..." - minix_conf_create > $CONF -} - -function wait_output { - RET=0 - date - timeout $1 watch -n 1 -e \! grep -q "$2" $3 &> /dev/null < /dev/null || RET=$? - if [ $RET -eq 124 ]; then - echo "* Timed out after $1 seconds!" 1>&2 - return 1 - fi - echo "* Done." 1>&2 - date - return 0 -} - -function run_cmd_exec { - echo "* Waiting for MINIX to boot..." 1>&2 - wait_output $BOOT_TIMEOUT "__runcmd_start" runcmd.log || return 33 - echo "* Waiting for command \"$*\"..." 1>&2 - wait_output $TIMEOUT "__runcmd_end" runcmd.log || return 66 - RET=$( grep __runcmd_end runcmd.log | cut -d' ' -f 2 ) - return $RET -} - -function run_cmd { - echo "* Setting up configuration..." 1>&2 - [ -f $DISK ] || $CMD builddisk - [ -f $IMAGE ] || $CMD buildimage - - $CMD mountdisk - [ ! -f $DISK_MNT/etc/rc ] || mv $DISK_MNT/etc/rc $DISK_MNT/etc/rc.bak - rc_ext_runcmd_create $* > $DISK_MNT/etc/rc - $CMD umountdisk - echo "* Starting up..." 1>&2 - rm -f runcmd.* - OUT=S $CMD run &> runcmd.log & - PID=$! - RUNCMD_RET=0 - run_cmd_exec $* || RUNCMD_RET=$? - cat runcmd.log | awk '/__runcmd_end/ {N=0;} { if (N==1) print; } /__runcmd_start/ {N=1;}' > runcmd.out - echo "* Shutting down..." 1>&2 - for pid in $(ps ax -o pid,args --sort start_time | grep -e "$CMD run[^a-zA-Z]" -e qemu -e kvm | grep -v grep | cut -d' ' -f 1 | head -3 ) - do - kill $pid &> /dev/null || true - done - $CMD mountdisk - [ ! -f $DISK_MNT/etc/rc.bak ] || mv $DISK_MNT/etc/rc.bak $DISK_MNT/etc/rc - echo "* COMMAND: \"$*\", RET: $RUNCMD_RET, OUTPUT:" - cat runcmd.out - return $RUNCMD_RET -} - -function run { - if [ "$HYPER" == "" ]; then - if [ -e /dev/kvm ]; then - HYPER="qemu-system-i386 --enable-kvm" - else - HYPER=qemu-system-i386 - fi - fi - opts="-m 256 -hda $IMAGE" - append="$APPEND rootdevname=c0d0p0" - [ ! -f $DISK ] || opts="$opts -hdb $DISK" - if [ "$OUT" == "F" ]; then - opts="$opts -curses -serial file:$MYPWD/serial.out" - append="$append cttyline=0" - echo "tail -f $MYPWD/serial.out" > $MYPWD/connect.cmd - elif [ "$OUT" == "C" ]; then - opts="$opts -curses -chardev socket,id=serial0,path=$MYPWD/serial.sock,server,nowait -serial chardev:serial0" - append="$append cttyline=0" - echo "(cd $MYPWD && minicom -D unix\#serial.sock)" > $MYPWD/connect.cmd - else - opts="$opts -nographic" - append="$append console=tty00" - if [ "$OUT" == "P" ]; then - opts="$opts -serial pty" - [ -z $PTS ] && PTS=$( $HYPER -serial pty 2>&1 | grep pts | sed "s/.* \([^ ]*pts[^ ]*\) .*/\1/g" ) - echo "minicom -D $PTS" > $MYPWD/connect.cmd - else - echo "echo Cannot connect with OUT=S option." > $MYPWD/connect.cmd - fi - fi - (cd ../../../obj.i386/destdir.i386/boot/minix/.temp && $HYPER -kernel kernel -append "$append" $opts -initrd "mod01_ds,mod02_rs,mod03_pm,mod04_sched,mod05_vfs,mod06_memory,mod07_tty,mod08_mfs,mod09_vm,mod10_pfs,mod11_init") -} - -function minix_connect { - echo "*****" - echo "***** Running: $( cat $MYPWD/connect.cmd )" - echo "*****" - eval $MYPWD/connect.cmd -} - -function minix_unstack { - local service=$1 - shift - if [ ! -f $ROOT/minix.mods.map ]; then - echo "$ROOT/minix.mods.map does not exist, run relink.llvm first!" - return 1 - fi - path=$(grep "^$service=" $ROOT/minix.mods.map | cut -d= -f 2) - path=$ROOT/../obj.i386/$path/$service - $ADDR2LINE -p -f -e $path $* -} - -function minix_test { - JOBS=${JOBS:-8} - RUNCMD=${RUNCMD:-ls} - C=${C:-full} - LOG=$(pwd)/test.log - if [ "$C" == "full" ]; then - cd $ROOT - JOBS=$JOBS BUILDVARS="-V MKBITCODE=yes" ./releasetools/x86_hdimage.sh -b 2>&1 | tee $LOG; test ${PIPESTATUS[0]} -eq 0 || exit 125 - cd - - else - C=$C ./relink.llvm 2>&1 | tee $LOG; test ${PIPESTATUS[0]} -eq 0 || exit 125 - ./clientctl buildimage 2>&1 | tee -a $LOG; test ${PIPESTATUS[0]} -eq 0 || exit 125 - fi - if [ "$RUNCMD" != "" ]; then - ./clientctl runcmd $RUNCMD 2>&1 | tee -a $LOG; test ${PIPESTATUS[0]} -eq 0 || exit 2 - fi - exit 0 -} - -function minix_bisect { - cd $ROOT - git bisect reset - echo " * Enter bad commit: " - read bad - echo " * Enter good commit: " - read good - git bisect start $bad $good - git bisect run minix/llvm/clientctl test - cd - -} - -# Usage: [C=set] ./clientctl buildasr [num] -# -# Build 'num' sets of ASR-randomized service binaries for the 'set' set of -# services. Defaults to one set (in addition to the set used to boot) for -# all services. To be used after building the full system. -# -# The MINIX3 counterpart of the generation taking place here is the -# update_asr(8) command, which cycles through the generated binaries. -# -function minix_buildasr { - MINIXLLVMDIR=$ROOT/minix/llvm - ASRDIR=/usr/service/asr - - . $MINIXLLVMDIR/common.inc # get DESTDIR - DESTDIR="$DESTDIR/destdir.i386" # correct DESTDIR - - ASRDESTDIR="$DESTDIR$ASRDIR" - COUNT=${1:-1} # take count from command line, default to 1 - C=${C:-"servers,fs,net,drivers"} - - # start by relinking everything against the magic library - C=$C $MINIXLLVMDIR/relink.llvm magic - - # we are replacing any previously made ASR binaries - rm -rf $ASRDESTDIR/* - - # generate $COUNT number of sets of ASR-randomized service binaries - # TODO: do not use current time as random seed - N=1 - while [ $N -le $COUNT ]; do - mkdir $ASRDESTDIR/$N - export BINDIR=$ASRDIR/$N - C=$C $MINIXLLVMDIR/build.llvm magic asr - sleep 1 # just to make sure they're guaranteed to be different - N=$(($N + 1)) - done - - # generate the initial set of service binaries, different as well - unset BINDIR - C=$C $MINIXLLVMDIR/build.llvm magic asr - - # finally generate the image - # x86_hdimage will automatically add the binaries to the image set - $MINIXLLVMDIR/clientctl buildimage -} - -case "$mode" in - 'buildimage') - (cd $ROOT && CREATE_IMAGE_ONLY=1 releasetools/x86_hdimage.sh -b) - ;; - 'buildboot') - (cd $ROOT && $MAKE -C releasetools do-hdboot) - ;; - 'conf') - minix_conf - ;; - 'builddisk') - rm -f $DISK - disk_build $DISK_SIZE - ;; - 'mountdisk') - disk_mount $DISK_MNT - ;; - 'umountdisk') - disk_umount - ;; - 'runcmd') - run_cmd $* - ;; - 'run') - run - ;; - 'connect') - minix_connect - ;; - 'unstack') - minix_unstack $* - ;; - 'test') - minix_test - ;; - 'bisect') - minix_bisect - ;; - 'buildasr') - minix_buildasr $* - ;; - *) - echo "Invalid action: $mode" - exit 1 - ;; -esac diff --git a/minix/llvm/configure.llvm b/minix/llvm/configure.llvm deleted file mode 100755 index ca4cf2c60..000000000 --- a/minix/llvm/configure.llvm +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/bash - -############################ -# -# Author: Koustubha Bhat -# Date : 3-April-2014 -# VU University, Amsterdam. -# -############################ - -################## -# Initialization -################## - -set -o errexit - -MYPWD="`pwd`" -ARCH=i386 -MINIX_ROOT= -MINIX_LLVM_DIR= -GOLD_DEST_DIR= -EXITCODE=0 - -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" - GOLD_DEST_DIR="${MINIX_ROOT}/minix/llvm/bin" - - MINIX_ROOT_1=`readlink -f ${MINIX_ROOT}` - MINIX_DEST_DIR=`readlink -f ${MINIX_ROOT}/../obj.${ARCH}` - MINIX_TOOLS_DIR="${MINIX_DEST_DIR}/tooldir.`uname -s`-`uname -r`-`uname -m`" -} - -# Make sure we are running from the right directory -check_current_dir - -# Create common.inc -if [ ! -f ${MINIX_LLVM_DIR}/common.inc ]; then - echo "# This file was automatically generated by configure.llvm" > ${MINIX_LLVM_DIR}/common.inc - echo "DESTDIR=\"${MINIX_DEST_DIR}\"" >> ${MINIX_LLVM_DIR}/common.inc - echo "TOOLDIR=\"${MINIX_TOOLS_DIR}/bin\"" >> ${MINIX_LLVM_DIR}/common.inc -fi - -. ${MINIX_LLVM_DIR}/minix.inc - -# Set default values for essential variables -: ${JOBS=1} -: ${GEN_GOLD_PLUGIN="yes"} -: ${REBUILD_MINIX="yes"} - -######################## -# Generate Gold Plugin -######################## - -if [ "${GEN_GOLD_PLUGIN}" == "yes" ] && [ -f "${MYPWD}/.gold_generated" ]; then - GEN_GOLD_PLUGIN="no" -fi - -if [ "${GEN_GOLD_PLUGIN}" == "yes" ]; then - ${MINIX_LLVM_DIR}/generate_gold_plugin.sh - if [ ! -f "${GOLD_DEST_DIR}/libLTO.so" ] || [ ! -f "${GOLD_DEST_DIR}/LLVMgold.so" ]; then - echo "Failure: generate_gold_plugin.sh" - exit 1 - fi - - echo "Finished generating gold plugin." - touch "${MYPWD}/.gold_generated" -else - echo "Gold plugin generation: NO" -fi - -######################## -# Build Minix -######################## -export BUILDVARS - -if [ "${REBUILD_MINIX}" == "yes" ]; then - - echo "Building Minix..." - echo "CC:$CC" - echo "CXX:$CXX" - echo "JOBS:$JOBS" - echo "BUILDVARS:$BUILDVARS" - echo - cd ${MINIX_ROOT} - ./releasetools/x86_hdimage.sh -b || EXITCODE=1 - cd ${MYPWD} - if [ "$EXITCODE" != "0" ]; then - echo "Error: Failed building Minix source code." - exit $EXITCODE - else - echo "Completed building Minix source code." - fi -else - echo "Building Minix: NO" -fi - -exit $EXITCODE diff --git a/minix/llvm/minix.inc b/minix/llvm/minix.inc deleted file mode 100644 index 59396e8c3..000000000 --- a/minix/llvm/minix.inc +++ /dev/null @@ -1,121 +0,0 @@ -#!/bin/bash - -ARCH=i386 -MINIX_MODULES_MAPFILE=${MINIX_ROOT}/minix.mods.map -MINIX_LLVM_BIN_DIR=${MINIX_LLVM_DIR}/bin - -[ -f ${MINIX_LLVM_DIR}/common.inc ] || cp ${MINIX_LLVM_DIR}/common.inc.default ${MINIX_LLVM_DIR}/common.inc -. ${MINIX_LLVM_DIR}/common.inc - -# generate_modules_map() -# -# Generates the ${MINIX_MODULES_MAPFILE} file - -function generate_modules_map() -{ - local TMPFILE="/tmp/.modules.map.tmp" - local OUTFILE="${MINIX_MODULES_MAPFILE}" - local currdir=`pwd` - - echo "Generating Minix modules map..." 1>&2 - cd ${MINIX_ROOT} - grep -r "^PROG *=" . --include=Makefile | sed -e "s/\s*//g" | sed -e "s/PROG *=//g" > ${TMPFILE} - grep -r "^PROGS *=" . --include=Makefile | sed -e "s/\s\s*/ /g" | sed -e "s/PROGS *=//g" | sed -e "s/\.\///g" | ( - while read line; do - path=$(echo $line | cut -d' ' -f 1) - progs=$(echo $line | cut -d' ' -f 2-) - for p in $progs - do - echo $path$p - done - done - ) >> ${TMPFILE} - - cat ${TMPFILE} | sed -e "s/\.\///g" > ${TMPFILE}.1 - - for l in `cat ${TMPFILE}.1`; do echo "`echo $l | cut -d: -f2`=`echo $l | cut -d: -f1`" | sed -e "s/\/Makefile//g"; done > ${TMPFILE}.2 - GREP_FILTER=$( cat minix/drivers/Makefile | awk "\$1 ~ /endif/ {N=0}; N==1 {print}; \$4 ~ /earm/ {N=1}" | sed "s/^\t//g" | sed "s/SUBDIR[^ ]* *//g" | sed "s/ \\\//g" | xargs | sed "s/ /= -e ^/g") - # The blacklist has drivers not available on x86; ideally this would be extracted from the Makefiles - blacklist="" - blacklist="$blacklist -e ^bmp085=" - blacklist="$blacklist -e ^cat24c256=" - blacklist="$blacklist -e ^fb=" - blacklist="$blacklist -e ^gpio=" - blacklist="$blacklist -e ^i2c=" - blacklist="$blacklist -e ^lan8710a=" - blacklist="$blacklist -e ^mmcemmc=" - blacklist="$blacklist -e ^sht21=" - blacklist="$blacklist -e ^tda19988=" - blacklist="$blacklist -e ^tps65217=" - blacklist="$blacklist -e ^tps65950=" - blacklist="$blacklist -e ^tsl2550=" - blacklist="$blacklist -e ^usbd=" - grep -v -e ^${GREP_FILTER}= -e ^ramdisk -e ^memory= $blacklist ${TMPFILE}.2 > ${OUTFILE} - echo ramdisk=minix/drivers/storage/ramdisk >> ${OUTFILE} # ramdisk always second last - echo memory=minix/drivers/storage/memory >> ${OUTFILE} # memory always last - - rm -rf ${TMPFILE} ${TMPFILE}.1 ${TMPFILE}.2 - - cd ${currdir} -} - -# get_modules_path -# -# Searches through the modules map and gets all the locations -# pertaining to the module(s) being searched. - -function get_modules_path() -{ - local MODULE_NAME=$1 - if [ ! -f "${MINIX_MODULES_MAPFILE}" ]; then - generate_modules_map - fi - if [ $MODULE_NAME == "servers" ] || [ $MODULE_NAME == "drivers" ] || [ $MODULE_NAME == "fs" ] || [ $MODULE_NAME == "net" ] || [ $MODULE_NAME == "commands" ]; then - MODULE_NAME="=minix/${MODULE_NAME}/" - else - MODULE_NAME="^${MODULE_NAME}=" - fi - - echo `grep "${MODULE_NAME}" ${MINIX_MODULES_MAPFILE} | cut -d= -f2` -} - -# get_module_name -# -# Given a module path, it gives its corresponding module name - -function get_module_name() -{ - local MODULE_PATH=$1 - if [ ! -f "${MINIX_MODULES_MAPFILE}" ]; then - generate_modules_map - fi - - echo `grep "${MODULE_PATH}$" ${MINIX_MODULES_MAPFILE} | cut -d= -f1` -} - -# clean_module() -# -# Cleans up the DESTDIR directory for the specified module - -function clean_module() -{ - local MODULE_NAME=$1 - local MODULE_PATH=$2 - local MODE=$3 # MODE can either be "relink" or "build" - local currdir=`pwd` - - # By default, clean only the potentially instrumented files - local TARGETS="${MODULE_NAME} *.opt.bcl *.bcl.o" - - if [ "${MODE}" == "relink" ]; then - TARGETS="${TARGETS} *.bcl" - fi - - if [ -d ${DESTDIR}/${MODULE_PATH} ]; then - cd ${DESTDIR}/${MODULE_PATH} - rm -rf ${TARGETS} 2> /dev/null || true - fi - - cd ${currdir} -} - diff --git a/minix/llvm/relink.llvm b/minix/llvm/relink.llvm deleted file mode 100755 index 1b59c701d..000000000 --- a/minix/llvm/relink.llvm +++ /dev/null @@ -1,136 +0,0 @@ -#!/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,fs,net,drivers"} - -function usage() -{ - echo "C= $0 []" - 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" -} - -# Copied from configure.llvm.inc -function build_llvm_libs() -{ - local LIBS="" - for a in $* - do - LIBS="$LIBS `find $INSTALL_DIR -maxdepth 2 -name ${a}\*.bcc | xargs`" - done - echo $LIBS -} - -function find_static_libs() -{ - local stat_libs_minix= - - stat_libs_minix=`build_llvm_libs $*` - - echo "${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 - -. ${MINIX_LLVM_DIR}/minix.inc - -INSTALL_DIR=${DESTDIR}/minix/lib - -echo ".so and .bcc binaries of LLVM passes set to be picked up from:" -echo " ${INSTALL_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" -e "s/ rd / ramdisk memory /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 all install - echo -done - -cd ${MYPWD} -