genode/repos/dde_rump/patches/build.patch

222 lines
5.8 KiB
Diff
Raw Normal View History

diff --git a/buildrump.sh b/buildrump.sh
index 9cc5457..620dbf1 100755
--- a/buildrump.sh
+++ b/buildrump.sh
@@ -191,8 +191,8 @@ probear ()
{
# Check for GNU/BSD ar
- if ! ${AR} -V 2>/dev/null | egrep '(GNU|BSD) ar' > /dev/null ; then
- die Need GNU or BSD ar "(`type ${AR}`)"
+ if ! ${TOOLS_AR} -V 2>/dev/null | egrep '(GNU|BSD) ar' > /dev/null ; then
+ die Need GNU or BSD ar "(`type ${TOOLS_AR}`)"
fi
}
@@ -223,7 +223,7 @@ doesitbuild ()
warnflags="-Wmissing-prototypes -Wstrict-prototypes -Wimplicit -Werror"
printf "${theprog}" \
- | ${CC} ${warnflags} ${EXTRA_LDFLAGS} ${EXTRA_CFLAGS} \
+ | ${TOOLS_CC} ${warnflags} ${EXTRA_LDFLAGS} ${EXTRA_CFLAGS} -x c - -o /dev/null $* \
-x c - -o /dev/null $* > /dev/null 2>&1
}
@@ -242,13 +242,7 @@ checkcheckout ()
checkcompiler ()
{
-
- if ! ${KERNONLY}; then
- doesitbuild 'int main(void) {return 0;}\n' \
- ${EXTRA_RUMPUSER} ${EXTRA_RUMPCOMMON}
- [ $? -eq 0 ] || ${TITANMODE} || \
- die 'Probe cannot build a binary'
- fi
+ return
}
probe_rumpuserbits ()
@@ -548,7 +542,8 @@ makemake ()
stage=$2
cmd=$3
- env CFLAGS= HOST_LDFLAGS=-L${OBJDIR} ./build.sh \
+ env CC=${BUILD_CC} AR=${BUILD_AR} NM=${BUILD_NM} OBJCOPY=${BUILD_OBJCOPY} \
+ CFLAGS= BUILD_LDFLAGS=-L${OBJDIR} ./build.sh \
-m ${MACHINE} -u \
-D ${stage} -w ${wrapper} \
-T ${BRTOOLDIR} -j ${JNUM} \
@@ -708,10 +703,27 @@ evaltoolchain ()
rm -f ${OBJDIR}/canrun
fi
+ # check for crossbuild with tools running on host
+ : ${BUILD_CC:=}
+ [ ${BUILD_CC} ] && HYBRIDBUILD=true
+
+ if ${HYBRIDBUILD}; then
+ : ${TOOLS_CC:=${BUILD_CC}}
+ : ${TOOLS_AR:=${BUILD_AR}}
+ : ${TOOLS_NM:=${BUILD_NM}}
+ : ${TOOLS_OBJCOPY:=${BUILD_OBJCOPY}}
+ else
+ : ${TOOLS_CC:=${CC}}
+ : ${TOOLS_AR:=${AR}}
+ : ${TOOLS_NM:=${NM}}
+ : ${TOOLS_OBJCOPY:=${OBJCOPY}}
+ fi
+
+
# Check for variant of compiler.
# XXX: why can't all cc's that are gcc actually tell me
# that they're gcc with cc --version?!?
- ccver=$(${CC} --version)
+ ccver=$(${TOOLS_CC} --version)
if echo ${ccver} | grep -q 'Free Software Foundation'; then
CC_FLAVOR=gcc
elif echo ${ccver} | grep -q clang; then
@@ -721,33 +733,21 @@ evaltoolchain ()
CC_FLAVOR=pcc
PCC='-V HAVE_PCC=1'
else
- die Unsupported \${CC} "(`type ${CC}`)"
+ die Unsupported \${TOOLS_CC} "(`type ${TOOLS_CC}`)"
fi
- # Check the arch we're building for so as to work out the necessary
- # NetBSD machine code we need to use. First try -dumpmachine,
- # and if that works, be happy with it. Not all compilers support
- # it (e.g. older versions of clang), so if that doesn't work,
- # try parsing the output of -v
- if ! CC_TARGET=$(${CC} -dumpmachine 2>/dev/null) ; then
- # first check "${CC} -v" ... just in case it fails, we want a
- # sensible return value instead of it being lost in the pipeline
- # (this is easier than adjusting IFS)
- if ${CC} -v >/dev/null 2>&1 ; then
- # then actually process the output of ${CC} -v
- CC_TARGET=$(LC_ALL=C ${CC} -v 2>&1 \
- | sed -n 's/^Target: //p' )
- [ -z "${CC_TARGET}" ] \
- && die failed to probe target of \"${CC}\"
- else
- # this might be pcc
- ${CC} -v 2>&1 | grep pcc > /dev/null || \
- die \"${CC} -v failed\". Check \"${CC}\"
- CC_TARGET=$(${CC} -v 2>&1 \
- | sed -n -e 's/^pcc.*for //' -e 's/,.*//p' )
- fi
+ MACH_ARCH=$(echo ${CC_TARGET} | sed 's/.*-\(.*\)-.*/\1/' )
+ echo "MACH_ARCH cc ${MACH_ARCH}"
+
+
+ if [ "${MACH_ARCH}" = 'x86' ] ; then
+ CC_TARGET=genode-x86
+ MACH_ARCH=x86_64
+ elif [ "${MACH_ARCH}" = 'arm' ] ; then
+ CC_TARGET=genode-arm
+ else
+ die Unsupported architectur ${MACH_ARCH}
fi
- MACH_ARCH=$(echo ${CC_TARGET} | sed 's/-.*//' )
# Set names of tools we're going to use. try to guess them
# for common scenarios
@@ -767,6 +767,9 @@ evaltoolchain ()
done
case ${CC_TARGET} in
+ "genode")
+ RUMPKERN_UNDEF='-U__FreeBSD__'
+ ;;
*-linux*)
RUMPKERN_UNDEF='-Ulinux -U__linux -U__linux__ -U__gnu_linux__'
cppdefines _BIG_ENDIAN \
@@ -793,10 +796,10 @@ evaltoolchain ()
${TITANMODE} || die ELF required as target object format
fi
- if cppdefines __LP64__; then
- THIRTYTWO=false
- else
+ if ${TARGET_IS_32BIT}; then
THIRTYTWO=true
+ else
+ THIRTYTWO=false
fi
# The compiler cannot do %zd/u warnings if the NetBSD kernel
@@ -857,6 +860,9 @@ evalplatform ()
echo '>> Mach-O object format used by OS X is not yet supported'
target_supported=false
;;
+ genode-*)
+ TARGET=genode
+ ;;
*)
target_supported=false
;;
@@ -867,8 +873,8 @@ evalplatform ()
fi
# does target support __thread. if yes, optimize curlwp
- doesitbuild '__thread int lanka; int main(void) {return lanka;}\n'
- [ $? -eq 0 ] && RUMP_CURLWP=__thread
+# doesitbuild '__thread int lanka; int main(void) {return lanka;}\n'
+# [ $? -eq 0 ] && RUMP_CURLWP=__thread
}
# ARM targets require a few extra checks
@@ -880,8 +886,8 @@ probearm ()
MACHINE="evbearm-el"
MACH_ARCH="arm"
else
- MACHINE="evbearm-eb"
- MACH_ARCH="armeb"
+ MACHINE="evbearm"
+ MACH_ARCH="arm"
fi
TOOLABI="elf-eabi"
@@ -893,6 +899,11 @@ probearm ()
if cppdefines __VFP_FP__; then
MKSOFTFLOAT=no
fi
+
+ EXTRA_CFLAGS='-march=armv7-a'
+ EXTRA_AFLAGS='-march=armv7-a'
+ EXTRA_LDFLAGS='-nostdlib'
+ appendvar EXTRA_CWARNFLAGS -Wno-format
}
# aarch64 requires a few checks
@@ -962,6 +973,9 @@ evalmachine ()
MACHINE="i386"
MACH_ARCH="i486"
TOOLABI="elf"
+ appendvar EXTRA_CFLAGS -m32
+ appendvar EXTRA_LDFLAGS -m32
+ appendvar EXTRA_AFLAGS -m32
else
MACHINE="amd64"
MACH_ARCH="x86_64"
@@ -1044,13 +1058,17 @@ parseargs ()
debugginess=0
KERNONLY=false
NATIVENETBSD=false
+ TARGET_IS_32BIT=false
OBJDIR=./obj
DESTDIR=./rump
SRCDIR=./src
JNUM=4
- while getopts 'd:DhHj:kNo:qrs:T:V:F:' opt; do
+ while getopts '3:d:DhHj:kNo:qrs:T:V:F:' opt; do
case "$opt" in
+ 3)
+ TARGET_IS_32BIT=true
+ ;;
d)
DESTDIR=${OPTARG}
;;