]> Zhao Yanbai Git Server - minix.git/commitdiff
Bridging Minix & llvm-apps repos for instrumentating Minix
authorKoustubha Bhat <ksbhat@live.com>
Tue, 6 May 2014 08:43:42 +0000 (10:43 +0200)
committerLionel Sambuc <lionel@minix3.org>
Mon, 28 Jul 2014 15:06:03 +0000 (17:06 +0200)
Allows instrumentation of Minix components using LLVM passes from
"llvm-apps" repository

In addition, the change does the following:
 1. Move releasetools/generate_gold_plugin.sh to minix/llvm
 2. Move external/bsd/llvm/passes to minix/llvm/passes
 3. libLTO.so, LLVMgold.so and WeakAliasModuleOverride.so files
    now get installed in minix/llvm/bin

Makefile
minix/Makefile [new file with mode: 0644]
minix/llvm/build.llvm [new file with mode: 0755]
minix/llvm/configure.llvm [new file with mode: 0755]
minix/llvm/generate_gold_plugin.sh [moved from releasetools/generate_gold_plugin.sh with 87% similarity]
minix/llvm/minix.inc [new file with mode: 0644]
minix/llvm/passes/WeakAliasModuleOverride/Makefile [moved from external/bsd/llvm/passes/WeakAliasModuleOverride/Makefile with 83% similarity]
minix/llvm/passes/WeakAliasModuleOverride/WeakAliasModuleOverride.cpp [moved from external/bsd/llvm/passes/WeakAliasModuleOverride/WeakAliasModuleOverride.cpp with 100% similarity]
minix/llvm/relink.llvm [new file with mode: 0755]
share/mk/bsd.own.mk
share/mk/bsd.prog.mk

index 66aac28d06136fb54d570287976a85239a198d32..c50912c9adfc1e648af463256a91a45feb70388d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -137,7 +137,7 @@ _SRC_TOP_OBJ_=
 # _SUBDIR is used to set SUBDIR, after removing directories that have
 # BUILD_${dir}=no, or that have no ${dir}/Makefile.
 #
-_SUBDIR=       tools lib include gnu external crypto/external bin games
+_SUBDIR=       tools lib include gnu external crypto/external minix bin games
 .if defined(__MINIX)
 _SUBDIR+=      commands man benchmarks test
 _SUBDIR+=      kernel servers drivers
diff --git a/minix/Makefile b/minix/Makefile
new file mode 100644 (file)
index 0000000..55ae5b9
--- /dev/null
@@ -0,0 +1,5 @@
+#      $NetBSD: Makefile,v 1.18 2012/06/14 04:14:36 riz Exp $
+
+SUBDIR+= llvm
+
+.include <bsd.subdir.mk>
diff --git a/minix/llvm/build.llvm b/minix/llvm/build.llvm
new file mode 100755 (executable)
index 0000000..bd25df7
--- /dev/null
@@ -0,0 +1,158 @@
+#!/bin/bash
+
+############################
+#
+# Author: Koustubha Bhat
+# Date  : 3-April-2014
+# VU University, Amsterdam.
+#
+############################
+
+set -o errexit
+
+MYPWD=`pwd`
+MINIX_ROOT=
+MINIX_LLVM_DIR=
+LLVMPASS=
+LLVMARGS=
+LLVMPASS_PATHS=
+OPTFLAGS="  "
+TARGET_MODULES=
+MINIX_MODS=
+
+# Set default values for essential variables
+: ${GENERATE_MAP="no"}
+: ${C="hello"}
+
+function usage()
+{
+   echo "C=<target Minix module(s)> $0 [<LLVM-pass name> ...]"
+   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 ] && [ -d ./drivers ] && [ -d ./servers ] ; then
+        MINIX_ROOT="${MYPWD}"
+   elif [ -d ../../minix ] && [ -d ../../drivers ] && [ -d ../../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
+                       echo "The LLVM pass file ${llvmpass}.so doesn't exit."
+                       exit_flag=1
+               fi
+               LLVMPASS_PATHS+=" -load=${llvmpass_path} -${llvmpass}"
+       done
+
+       if [ ${exit_flag} == 1 ]; then
+               echo "Searched in:"
+               echo "  ${INSTALL_DIR}" 
+               echo "          and"
+               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
+
+# set up the bridge to llvm-apps repository and initialize
+. ${MINIX_LLVM_DIR}/minix.inc
+. ${ROOT}/apps/scripts/include/configure.llvm.inc
+
+# Arguments check
+check_args "$@"
+
+if [ "$C" == "" ]; then
+       C="hello"
+fi 
+
+if [ "${GENERATE_MAP}" != "" ] && [[ ${GENERATE_MAP} =~ [yY][eE][sS] ]]; then
+        generate_modules_map
+fi
+
+# If we are really instrumenting with some pass...
+if [ "${LLVMPASS_PATHS}" != "" ]; then
+       OPTFLAGS=" -disable-opt ${LLVMPASS_PATHS} ${LLVMARGS}"
+fi
+
+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 "Build.llvm: Executing with following parameters..."
+echo "LLVM pass                :       ${LLVMPASS}"
+echo "LLVM pass arguments      :       ${LLVMARGS}"
+echo "Target Minix modules     :       ${MINIX_MODS}"
+echo "OPTFLAGS value           :       ${OPTFLAGS}"
+echo
+
+cd ${MINIX_ROOT}
+
+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
+       clean_module $n $m
+       OPTFLAGS=`echo ${OPTFLAGS} | sed -e "s/\ /\\\ /g"`
+       OPTFLAGS_PLACEHOLDER="OPTFLAGS.$n=${OPTFLAGS}"
+       
+       (env "`echo ${OPTFLAGS_PLACEHOLDER}`" MKBITCODE=yes  SLOPPY_FLIST=yes \
+       ${TOOLDIR}/nbmake-${ARCH} -C $m all install && echo "INFO: $m successfully instrumented." ) || echo "ERROR: Failed instrumenting $m"
+       echo 
+done
+
+cd ${MYPWD}
diff --git a/minix/llvm/configure.llvm b/minix/llvm/configure.llvm
new file mode 100755 (executable)
index 0000000..9896e83
--- /dev/null
@@ -0,0 +1,133 @@
+#!/bin/bash
+
+############################
+#
+# Author: Koustubha Bhat
+# Date  : 3-April-2014
+# VU University, Amsterdam.
+#
+############################
+
+##################
+# Initialization
+##################
+
+set -o errexit
+
+MYPWD="`pwd`"
+MINIX_ROOT=
+MINIX_LLVM_DIR=
+GOLD_DEST_DIR=
+DEFAULT_LLVM_ROOT=
+EXITCODE=0
+
+function check_current_dir()
+{
+   #Make sure we are running from the root dir of the Minix sources
+   if [ -d ./minix ] && [ -d ./drivers ] && [ -d ./servers ] ; then
+        MINIX_ROOT="${MYPWD}"
+   elif [ -d ../../minix ] && [ -d ../../drivers ] && [ -d ../../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"
+   DEFAULT_LLVM_ROOT="${MINIX_ROOT}/../../llvm-apps"
+}
+
+# Make sure we are running from the right directory
+check_current_dir
+
+# LLVM ROOT is the bridging connection from minix branch to the llvm-apps branch
+if [ "${ROOT}" == "" ]; then
+       
+       echo "\${ROOT} is not set."
+       echo "Please specify the path to the \"llvm-apps\" repository..."
+       echo "Default value: ${DEFAULT_LLVM_ROOT} . "
+       echo "If this is correct, press ENTER. Otherwise please enter the path."
+       read response
+
+       if [ "" == "${response}" ]; then
+               ROOT=${DEFAULT_LLVM_ROOT}
+       else
+               ROOT=${response}
+       fi
+fi     
+echo "LLVM root directory is set to :"
+echo "  ${ROOT}"
+
+# Persist the LLVM ROOT path information
+ROOT_1=`echo ${ROOT} | sed "s/\\\//\\\\\\\\\//g"`
+sed -i "s/ROOT=.*$/ROOT=\"${ROOT_1}\"/g" ${MINIX_LLVM_DIR}/minix.inc
+
+if [ ! -d ${ROOT}/.tmp ]; then
+       mkdir ${ROOT}/.tmp 2>/dev/null || true
+fi
+
+# Load useful functions and environment variables from llvm-apps repo.
+. ${ROOT}/apps/scripts/include/configure.llvm.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
+       echo "It is found that Gold plugin has already been generated. Would you like to re-generate? [y | n]"
+       read response
+       if [ "y" == "$response" ] || [ "Y" == "$response" ]; then
+               echo "Gold shall be regenerated."
+       else
+               GEN_GOLD_PLUGIN="no"
+       fi
+fi
+
+if [ "${GEN_GOLD_PLUGIN}" == "yes" ]; then
+
+       echo LLVMPREFIX= ${LLVMPREFIX}
+        ${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
+########################
+if [ "${REBUILD_MINIX}" == "yes" ]; then
+
+       echo "Building Minix..."
+       echo "CC:$CC"
+       echo "CXX:$CXX"
+       echo "JOBS:$JOBS"
+       echo 
+       cd ${MINIX_ROOT}
+       BUILDVARS="-V MKBITCODE=yes -V SLOPPY_FLIST=yes" ./releasetools/x86_hdimage.sh
+       EXITCODE=$?
+       cd ${MYPWD}
+       if [ "$EXITCODE" != "0" ]; then
+               echo "Error: Failed building Minix source code."
+               exit $EXITCODE
+       else
+               echo "Completed building Minix source code."
+               exit $EXITCODE
+       fi
+else
+       echo "Building Minix: NO"
+fi
similarity index 87%
rename from releasetools/generate_gold_plugin.sh
rename to minix/llvm/generate_gold_plugin.sh
index d3af790547ed7ce5adfd13f5777fb95085fd3db6..9b8f42875a95aa3d3aa6d9454575c64b7ae1d57e 100755 (executable)
@@ -2,7 +2,7 @@
 
 cd $(dirname $0)
 
-: ${NETBSDSRCDIR=${PWD}/..}
+: ${NETBSDSRCDIR=${PWD}/../..}
 : ${LLVMSRCDIR=${NETBSDSRCDIR}/external/bsd/llvm/dist}
 : ${ARCH=i386}
 : ${JOBS=1}
@@ -44,15 +44,14 @@ ${LLVMSRCDIR}/llvm/configure \
     ac_cv_path_NEATO="echo neato" \
     ac_cv_path_TWOPI="echo twopi" \
     ac_cv_path_XDOT="echo xdot" \
-    --enable-optimized \
-    CC=cc
+    --enable-optimized 
 
 make -j ${JOBS}
 
 # Copy the gold plugin where the NetBSD build system expects it.
-mkdir -p ${NETBSDSRCDIR}/external/bsd/llvm/passes/lib/
-cp ${OBJ_LLVM}/./Release+Asserts/lib/libLTO.so   ${NETBSDSRCDIR}/external/bsd/llvm/passes/lib/
-cp ${OBJ_LLVM}/./Release+Asserts/lib/LLVMgold.so ${NETBSDSRCDIR}/external/bsd/llvm/passes/lib/
+mkdir -p ${NETBSDSRCDIR}/minix/llvm/bin/
+cp ${OBJ_LLVM}/./Release+Asserts/lib/libLTO.so   ${NETBSDSRCDIR}/minix/llvm/bin/
+cp ${OBJ_LLVM}/./Release+Asserts/lib/LLVMgold.so ${NETBSDSRCDIR}/minix/llvm/bin/
 
 # Copy useful LLVM tools
 mkdir -p ${CROSS_TOOLS}
@@ -61,6 +60,6 @@ cp ${OBJ_LLVM}/./Release+Asserts/bin/opt    ${CROSS_TOOLS}
 cp ${OBJ_LLVM}/./Release+Asserts/bin/llvm-* ${CROSS_TOOLS}
 
 # Generate and Install default MINIX passes
-cd ${NETBSDSRCDIR}/external/bsd/llvm/passes/WeakAliasModuleOverride
+cd ${NETBSDSRCDIR}/minix/llvm/passes/WeakAliasModuleOverride
 make LLVMPREFIX=${OBJ_LLVM}/./Release+Asserts/ install
 
diff --git a/minix/llvm/minix.inc b/minix/llvm/minix.inc
new file mode 100644 (file)
index 0000000..4b772e2
--- /dev/null
@@ -0,0 +1,96 @@
+#!/bin/bash
+
+ARCH=i386
+MINIX_MODULES_MAPFILE=${MINIX_ROOT}/minix.mods.map
+MINIX_LLVM_BIN_DIR=${MINIX_LLVM_DIR}/bin
+
+# 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}
+
+       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 > ${OUTFILE}
+
+       rm -rf ${TMPFILE} ${TMPFILE}.1
+
+       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
+
+       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="${MODULE_NAME} *.o *.bcl"
+       fi
+
+       if [ -d ${DESTDIR}/${MODULE_PATH} ]; then 
+               cd ${DESTDIR}/${MODULE_PATH}
+               rm -rf ${TARGETS} 2> /dev/null || true
+       fi
+
+       cd ${currdir}  
+}
+
+##############################################################################
+# OTHER MINIX SPECIFIC VARIABLES
+##############################################################################
+DESTDIR=${MINIX_ROOT}/../obj.${ARCH}
+TOOLDIR=${DESTDIR}/tooldir.`uname -s`-`uname -r`-`uname -m`/bin
+
+##############################################################################
+# configure.llvm would add an entry for ROOT which points to the llvm-apps 
+# repository
+# 
+##############################################################################
+ROOT="/home/koustubha/systems_thesis.lnk/repositories/llvm-apps"
similarity index 83%
rename from external/bsd/llvm/passes/WeakAliasModuleOverride/Makefile
rename to minix/llvm/passes/WeakAliasModuleOverride/Makefile
index 000d77cbb3b5d4bd944563dd75197a15a3f3209f..38333d677edfd91729fb196d1bf584d74b9cc772 100644 (file)
@@ -2,7 +2,7 @@ QUIET=@
 ECHO=echo
 CP=cp
 
-PASSLIBNAME:= WeakAliasModuleOverride.so
+PASSLIBNAME:= weak-alias-module-override
 
 LLVM_VERSION = $($LLVMPREFIX/bin/llvm-config --version | sed "s/[^0-9]//g")
 CFLAGS  += -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -DHAVE_EXCEPTIONS=0
@@ -19,8 +19,8 @@ $(PASSLIBNAME): $(OBJS)
        $(QUIET) $(CXX) $(CFLAGS) $(INCLUDES) -c -o $@ $<
 
 install: $(PASSLIBNAME)
-       $(QUIET) -mkdir -p ../lib
-       $(QUIET) $(CP)  $(PASSLIBNAME) ../lib/$(PASSLIBNAME)
+       $(QUIET) -mkdir -p ../../bin
+       $(QUIET) $(CP)  $(PASSLIBNAME) ../../bin/$(PASSLIBNAME)
 
 clean:
        -rm -f *.o *.so
diff --git a/minix/llvm/relink.llvm b/minix/llvm/relink.llvm
new file mode 100755 (executable)
index 0000000..a9a6e9a
--- /dev/null
@@ -0,0 +1,156 @@
+#!/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=
+LIBNAMES=
+STATIC_LIBS=
+LDFLAGS_PLACEHOLDER=" "
+
+# Set default values to essential variables.
+: ${GENERATE_MAP="no"}
+: ${C="hello"}
+
+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 ] && [ -d ./drivers ] && [ -d ./servers ] ; then
+        MINIX_ROOT="${MYPWD}"
+   elif [ -d ../../minix ] && [ -d ../../drivers ] && [ -d ../../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 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 
+
+LIBNAMES="$*"
+
+EXIT_FLAG=no
+for l in ${LIBNAMES}; 
+do
+        if [ ! -f "${INSTALL_DIR}/$l.bcc" ] && [ ! -f "${MINIX_LLVM_BIN_DIR}/$l.bcc" ]; then
+                echo "ERROR: The LLVM pass file \"$l.bcc\" doesn't exit."
+               echo "Searched in: ${INSTALL_DIR} and ${MINIX_LLVM_BIN_DIR}."
+               EXIT_FLAG=yes
+        fi
+done
+
+if [ "${EXIT_FLAG}" == "yes" ]; then
+       exit 2
+fi
+
+# 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.$n=\"${STATIC_LIBS}\""
+       fi
+
+       env "`echo ${LDFLAGS_PLACEHOLDER}`" MKBITCODE=yes  SLOPPY_FLIST=yes \
+       ${TOOLDIR}/nbmake-${ARCH} -C $m
+       echo 
+done
+
+cd ${MYPWD}
+
index dd71d34e6d996f2d12a96422e6437606284726e3..208e74867a8aafbf89ae739878900cff5c460041 100644 (file)
@@ -61,8 +61,8 @@ MKRUMP:=      no
 MKSKEY:=       no
 MKYP:=         no
 
-WEAKALIASOVERRIDEPASS?=${NETBSDSRCDIR}/external/bsd/llvm/passes/lib/WeakAliasModuleOverride.so
-GOLD_PLUGIN?=${NETBSDSRCDIR}/external/bsd/llvm/passes/lib/LLVMgold.so
+WEAKALIASOVERRIDEPASS?=${NETBSDSRCDIR}/minix/llvm/bin/weak-alias-module-override
+GOLD_PLUGIN?=${NETBSDSRCDIR}/minix/llvm/bin/LLVMgold.so
 
 # By default when running LLVM passes:
 #  -  do not run optimization while running LLVM passes
index 222eb38c2e3063e8d7e85ce400aa8b02a3e20b76..3707931372291a57845f5220df1bbf099a9a68dc 100644 (file)
@@ -579,6 +579,9 @@ ${OBJS.${_P}} ${LOBJS.${_P}}: ${DPSRCS}
 .if defined(__MINIX) && ${USE_BITCODE:Uno} == "yes"
 CLEANFILES+= ${_P}.opt.bcl ${_P}.bcl ${_P}.bcl.o
 
+OPTFLAGS.${_P}?= ${OPTFLAGS}
+BITCODE_LD_FLAGS.${_P}+= ${BITCODE_LD_FLAGS}
+
 ${_P}.bcl: .gdbinit ${LIBCRT0} ${LIBCRTI} ${OBJS.${_P}} ${LIBC} ${LIBCRTBEGIN} \
     ${LIBCRTEND} ${_DPADD.${_P}}
        ${_MKTARGET_LINK}
@@ -589,12 +592,12 @@ ${_P}.bcl: .gdbinit ${LIBCRT0} ${LIBCRTI} ${OBJS.${_P}} ${LIBC} ${LIBCRTBEGIN} \
                ${OBJS.${_P}} ${LLVM_LINK_ARGS} ${_LDADD.${_P}:N-shared} \
                ${_LDSTATIC.${_P}} ${_PROGLDOPTS} \
                -Wl,-r \
-               ${BITCODE_LD_FLAGS} \
+               ${BITCODE_LD_FLAGS.${_P}} \
                -Wl,-plugin-opt=emit-llvm
 
 ${_P}.opt.bcl: ${_P}.bcl ${LLVM_PASS}
        ${_MKTARGET_LINK}
-       ${OPT} ${OPTFLAGS} -o ${.TARGET} ${_P}.bcl
+       ${OPT} ${OPTFLAGS.${_P}} -o ${.TARGET} ${_P}.bcl
 
 ${_P}.bcl.o: ${_P}.opt.bcl
        ${_MKTARGET_LINK}
@@ -608,7 +611,7 @@ ${_P}: ${_P}.bcl.o
                -L${DESTDIR}/usr/lib \
                ${_LDSTATIC.${_P}} -o ${.TARGET} \
                ${.TARGET}.bcl.o ${_PROGLDOPTS} ${_LDADD.${_P}} \
-               ${BITCODE_LD_FLAGS} \
+               ${BITCODE_LD_FLAGS.${_P}} \
                -Wl,--allow-multiple-definition
 .endif # !commands(${_P})