From 949a3e52e5066fa20261216a5dc377095200bf70 Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Sun, 5 Jul 2015 18:01:13 +0200 Subject: [PATCH] Break loose from llvm-apps entirely Change-Id: I532f5f44c785c1a72407b504568d54fc6cbabf8f --- minix/llvm/build.llvm | 5 +- minix/llvm/common.inc.default | 13 ----- minix/llvm/configure.llvm | 78 ++++++++++++++-------------- minix/llvm/generate_gold_plugin.sh | 6 +++ minix/llvm/relink.llvm | 15 ++++-- minix/llvm/static/Makefile.settings | 4 -- minix/llvm/static/magic/Makefile.inc | 1 + 7 files changed, 58 insertions(+), 64 deletions(-) delete mode 100644 minix/llvm/common.inc.default diff --git a/minix/llvm/build.llvm b/minix/llvm/build.llvm index 913a3114a..ff45a93d3 100755 --- a/minix/llvm/build.llvm +++ b/minix/llvm/build.llvm @@ -13,7 +13,6 @@ set -o errexit MYPWD=`pwd` MINIX_ROOT= MINIX_LLVM_DIR= -LLVMPASS= LLVMARGS= LLVMPASS_PATHS= TARGET_MODULES= @@ -98,9 +97,7 @@ function check_args() #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 -[ ! -f ${ROOT}/apps/scripts/include/configure.llvm.inc ] || . ${ROOT}/apps/scripts/include/configure.llvm.inc # Arguments check check_args "$@" @@ -132,7 +129,7 @@ done # Show info echo "Build.llvm: Executing with following parameters..." -echo "LLVM pass : ${LLVMPASS}" +echo "LLVM pass : $@" echo "LLVM pass arguments : ${LLVMARGS}" echo "Target Minix modules : ${MINIX_MODS}" echo "OPTFLAGS value : ${OPTFLAGS}" diff --git a/minix/llvm/common.inc.default b/minix/llvm/common.inc.default deleted file mode 100644 index 155649f4b..000000000 --- a/minix/llvm/common.inc.default +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################## -# COMMON 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="/nonexistent" - diff --git a/minix/llvm/configure.llvm b/minix/llvm/configure.llvm index 6f11aca3f..723f2ee0b 100755 --- a/minix/llvm/configure.llvm +++ b/minix/llvm/configure.llvm @@ -15,10 +15,10 @@ set -o errexit MYPWD="`pwd`" +ARCH=i386 MINIX_ROOT= MINIX_LLVM_DIR= GOLD_DEST_DIR= -DEFAULT_LLVM_ROOT= EXITCODE=0 function check_current_dir() @@ -38,48 +38,38 @@ function check_current_dir() MINIX_LLVM_DIR="${MINIX_ROOT}/minix/llvm" GOLD_DEST_DIR="${MINIX_ROOT}/minix/llvm/bin" - DEFAULT_LLVM_ROOT="${MINIX_ROOT}/../../llvm-apps" + + 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 -# 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." - if [ "$INTERACTIVE" = "no" ]; then - response="" - else - read response - fi - - 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 -[ -f ${MINIX_LLVM_DIR}/common.inc ] || cp ${MINIX_LLVM_DIR}/common.inc.default ${MINIX_LLVM_DIR}/common.inc -ROOT_1=`echo ${ROOT} | sed "s/\\\//\\\\\\\\\//g"` -sed -i "s/ROOT=.*$/ROOT=\"${ROOT_1}\"/g" ${MINIX_LLVM_DIR}/common.inc -. ${MINIX_LLVM_DIR}/minix.inc - -if [ ! -d ${ROOT}/.tmp ]; then - mkdir ${ROOT}/.tmp 2>/dev/null || true +# 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 +STATIC_DIR="${MINIX_LLVM_DIR}/static" + +if [ ! -f ${STATIC_DIR}/Makefile.common.inc ]; then + echo "# This file was automatically generated by configure.llvm" > ${STATIC_DIR}/Makefile.common.inc + echo "_MINIX_ARCH=${ARCH}" >> ${STATIC_DIR}/Makefile.common.inc + echo "_MINIX_ROOT=${MINIX_ROOT_1}" >> ${STATIC_DIR}/Makefile.common.inc + echo "_MINIX_TOOLS_DIR=${MINIX_TOOLS_DIR}" >> ${STATIC_DIR}/Makefile.common.inc +fi + +. ${MINIX_LLVM_DIR}/minix.inc + # Set default values for essential variables : ${JOBS=1} : ${GEN_GOLD_PLUGIN="yes"} : ${REBUILD_MINIX="yes"} +: ${GEN_STATIC_MAGIC="yes"} ######################## # Generate Gold Plugin @@ -119,7 +109,8 @@ if [ "${REBUILD_MINIX}" == "yes" ]; then ./releasetools/x86_hdimage.sh -b || EXITCODE=1 cd ${MYPWD} if [ "$EXITCODE" != "0" ]; then - echo "Error: Failed building Minix source code." + echo "Error: Failed building Minix source code." + exit $EXITCODE else echo "Completed building Minix source code." fi @@ -127,10 +118,19 @@ else echo "Building Minix: NO" fi -# Configure llvm-apps -cp ${ROOT}/conf/common.overrides.llvm-minix.inc ${ROOT}/common.overrides.llvm.inc -MINIX_ROOT_1=`readlink -f ${MINIX_ROOT}` -MINIX_TOOLS_DIR=$(readlink -f ${MINIX_ROOT}/../obj.i386/tooldir.*) -echo "_MINIX_ROOT=\"${MINIX_ROOT_1}\"" > ${ROOT}/common.overrides.minix.inc -echo "_MINIX_TOOLS_DIR=\"${MINIX_TOOLS_DIR}\"" >> ${ROOT}/common.overrides.minix.inc +if [ "${GEN_STATIC_MAGIC}" == "yes" ]; then + echo "Building static magic library..." + cd ${STATIC_DIR}/magic + make install || EXITCODE=1 + cd ${MYPWD} + if [ "$EXITCODE" != "0" ]; then + echo "Error: Failed building static magic library." + exit $EXITCODE + else + echo "Completed building static magic library." + fi +else + echo "Building static magic library: NO" +fi + exit $EXITCODE diff --git a/minix/llvm/generate_gold_plugin.sh b/minix/llvm/generate_gold_plugin.sh index e1b471867..b78bd1147 100755 --- a/minix/llvm/generate_gold_plugin.sh +++ b/minix/llvm/generate_gold_plugin.sh @@ -65,3 +65,9 @@ make install cd ${NETBSDSRCDIR}/minix/llvm/passes/hello make install + +cd ${NETBSDSRCDIR}/minix/llvm/passes/sectionify +make install + +cd ${NETBSDSRCDIR}/minix/llvm/passes/magic +make install diff --git a/minix/llvm/relink.llvm b/minix/llvm/relink.llvm index 06efa2071..ffa650c68 100755 --- a/minix/llvm/relink.llvm +++ b/minix/llvm/relink.llvm @@ -50,6 +50,17 @@ function check_current_dir() 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 1 -name ${a}\*.bcc | xargs`" + done + echo $LIBS +} + function find_static_libs() { local stat_libs_llvmapps= @@ -77,12 +88,8 @@ if [ "$1" == "--help" ] || [ "$1" == "-h" ]; then 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" diff --git a/minix/llvm/static/Makefile.settings b/minix/llvm/static/Makefile.settings index 56b705745..b87edf9e7 100644 --- a/minix/llvm/static/Makefile.settings +++ b/minix/llvm/static/Makefile.settings @@ -1,8 +1,4 @@ # THIS FILE IS AN EDITED VERSION OF A FILE GENERATED BY LLVM-APPS -# XXX EDIT AT LEAST THIS PART -_MINIX_ARCH=i386 -_MINIX_ROOT=/home/myname/path/to/minix -_MINIX_TOOLS_DIR=/home/myname/path/to/obj.i386/tooldir.Linux-myversion ########################################################### # llvm-apps settings for Minix binary instrumentation diff --git a/minix/llvm/static/magic/Makefile.inc b/minix/llvm/static/magic/Makefile.inc index 91b99e08f..258bdfd4b 100644 --- a/minix/llvm/static/magic/Makefile.inc +++ b/minix/llvm/static/magic/Makefile.inc @@ -1,4 +1,5 @@ +include ../Makefile.common.inc include ../Makefile.settings MODULE_NAME=$(MODULE).bcc