[Barrelfish-users] Cross Compiler Support

Simon Gerber simon.gerber at inf.ethz.ch
Wed Nov 29 10:55:33 CET 2017


Hi Daniel,

Unfortunately, no-one has used this method to build software for Barrelfish in quite a while, and I assume that you might run into unforeseen complications due to a divergence of compiler versions, etc.

At ETHZ we tend to use two different approaches to build software for Barrelfish:
1. Place the software in the Barrelfish source tree somewhere in usr/ and write a Hakefile to compile it using the regular Barrelfish build infrastructure
2. Use the attached GCC wrapper script with SRCPATH and BUILDPATH set to your Barrelfish source and build directories, respectively. Symlink the wrapper script to each of x86_64-barrelfish-none-{ar,g++,gcc,ld,ranlib}, and tell the software's build system to use the toolchain with prefix x86_64-barrelfish-none (e.g. by setting CC=x86_64-barrelfish-none-gcc).

Ideally we would like our build system (hake) to generate the attached wrapper script with correctly filled-in directories, extra libraries, and compiler flags, but we haven't gotten around to actually implementing this.

Best,
-- Simon

PS: I've added a .txt to the wrapper script file name to hopefully avoid the wrath of the mail filter :)
 
On 29.11.2017 10:28, Grumberg, Daniel wrote:
> Hi all,
> 
> Not sure this is the right place to ask this but here we go.
> 
> I am trying to build a cross compiling tool-chain for Barrelfish. I am following the instructions on the wiki page, from a clean Ubuntu 16.04 LTS VM (it only contains barrelfish and its dependencies).
> 
> I am using the recommended versions of binutils (2.24) and gcc (4.9.2) and the associated patches. However, I get a bunch of errors along the lines of:
> 
> libstdc++-v3/include/cr16-elf/bits/ctype_base.h:48: error: '_U' was not declared in this scope
> 
> This seems to be due to gcc using the default system headers when compiling libstdc++-v3 which is fair enough since we have not told it not too. The source tree does seem to specify an obvious sysroot (the source tree's usr/ directory does not contain include files), I assumed the system headers to be in the include/ directory of the source tree. As far as I have understood (I am probably wrong) they are meant to be a port of newlib to barrelfish. However even after configuring the build with |--with-native-system-header-dir="${BARRELFISH_SOURCE}/include"| the error persists. After examining these files they do not implement a newlib style ctype.h and thus do not define the above macros.
> 
> Is this a known-issue and is there a known workaround? Are the headers in include/ not a port of newlib in which case the configure option --with-new-lib is not correct? In short what am I doing wrong?
> 
> Again, sorry to bother everyone with trivial matters.
> 
> - Daniel
> 
> 
> 
> 
> _______________________________________________
> Barrelfish-users mailing list
> Barrelfish-users at lists.inf.ethz.ch
> https://lists.inf.ethz.ch/mailman/listinfo/barrelfish-users
> 
-------------- next part --------------
#!/bin/bash
#
# Barrelfish x86-64 cross compilation wrapper
# Copyright (c) 2011 Simon Peter <speter at inf.ethz.ch>
# Copyright (c) 2015 Simon Gerber <simon.gerber at inf.ethz.ch>
#
# Set SRCPATH and BUILDPATH to your Barrelfish source and build paths,
# respectively, and create symlinks to this file, like this:
#
# ln -s barrelfish-cc-wrapper x86_64-barrelfish-none-gcc
#
# You can set EXTRALIBS to link to libraries needed on Barrelfish that
# are not easily figured out by Autoconf or passable as LDFLAGS on the
# commandline.

# echo "invoked with: $*" >> debug.out

#set -x

SRCPATH=/local2/gerbesim/upstream/barrelfish
BUILDPATH=/local2/gerbesim/upstream/build-x86_64-trace
EXTRALIBS="$BUILDPATH/x86_64/lib/libtrace.a $BUILDPATH/x86_64/lib/libposixcompat.a $BUILDPATH/x86_64/lib/libvfs.a $BUILDPATH/x86_64/lib/libahci.a $BUILDPATH/x86_64/lib/libnfs.a $BUILDPATH/x86_64/lib/liblwip.a $BUILDPATH/x86_64/lib/libtimer.a $BUILDPATH/x86_64/lib/libcontmng.a $BUILDPATH/x86_64/lib/liboctopus.a $BUILDPATH/x86_64/lib/libbarrelfish.a $BUILDPATH/x86_64/lib/libterm_client.a $BUILDPATH/x86_64/lib/liboctopus_parser.a $BUILDPATH/x86_64/lib/libcollections.a $BUILDPATH/x86_64/errors/errno.o $BUILDPATH/x86_64/lib/libc.a"
EXTRALIBS_CXX="$BUILDPATH/x86_64/lib/libcxx.a $EXTRALIBS"

mode=unknown
prog=${0##*-}

# Copy commandline arguments
argi=0
for a in "$@"; do
    args[$argi]=$a
    argi=$((argi + 1))
done

case $prog in
    gcc)
	mode=compilelink
	;;
    g++)
	mode=compilelink++
	;;
    ld)
	mode=link
	;;

    ar)
	mode=archive
	;;

    ranlib)
	mode=ranlib
	;;

    *)
	echo "$0: Unknown program ($prog)" > /dev/stderr
	exit 1
	;;
esac

argi=0
for arg in "$@"; do
    case $arg in
	-print-prog-name=*)
	    # Print executable name for cross compiler if asked to do so
	    echo x86_64-barrelfish-none-${arg#-print-prog-name=}
	    exit 0
	    ;;

	-c|-E)
	    # We solely compile when -c is given
	    if [ $mode = compilelink ]; then
		mode=compile
            elif [ $mode = compilelink++ ]; then
                mode=compile++
	    fi
	    ;;

	-lm)
	    args[$argi]="$BUILDPATH/x86_64/lib/libmsun.a"
	    ;;

	-shared)
	    echo $0: Shared objects not supported by Barrelfish! >/dev/stderr
	    exit 1
	    ;;
    esac

    argi=$((argi + 1))
done

INCLUDES="-I$SRCPATH/include -I$SRCPATH/include/arch/x86_64 -I$SRCPATH/include/target/x86_64 -I$SRCPATH/lib/lwip/src/include/ipv4 -I$SRCPATH/lib/lwip/src/include -I$BUILDPATH/x86_64/include -I$SRCPATH/include/immintrin"

FLAGS_COMMON="-O2 -fno-builtin -g -m64 -nostdinc -fno-builtin -fno-stack-protector -fno-omit-frame-pointer -fPIE -mno-red-zone -m64 -mno-red-zone -U__linux__ -Ulinux -U__STRICT_ANSI__ -DBARRELFISH -DCONFIG_LAZY_THC -DCONFIG_NEWLIB -DUSE_KALUGA_DVM -DCONFIG_INTERCONNECT_DRIVER_LMP -DCONFIG_INTERCONNECT_DRIVER_UMP -DCONFIG_INTERCONNECT_DRIVER_MULTIHOP -DCONFIG_FLOUNDER_BACKEND_LMP -DCONFIG_FLOUNDER_BACKEND_UMP -DCONFIG_FLOUNDER_BACKEND_MULTIHOP -DCONFIG_TRACE $INCLUDES"

FLAGS_C="$FLAGS_COMMON -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes -Wno-attributes -std=c99"

FLAGS_CXX="$FLAGS_COMMON -DLIBCXX_CXX_ABI=libcxxabi -I$SRCPATH/include/cxx -fasynchronous-unwind-tables -fexceptions -nodefaultlibs -nostdinc++ -std=gnu++11" 

FLAGS_LD="-Wl,--build-id=none -Wl,-z,max-page-size=0x1000 -fno-builtin -g -m64 -nostdlib -static"

CC=gcc
CXX=g++

case $mode in
    compile)
	$CC $FLAGS_C "${args[@]}"
	;;

    compile++)
	$CXX $FLAGS_CXX "${args[@]}"
	;;

    compilelink)
	echo $CC $BUILDPATH/x86_64/lib/crt0.o $BUILDPATH/x86_64/lib/crtbegin.o $FLAGS_C $FLAGS_LD "${args[@]}" $EXTRALIBS $BUILDPATH/x86_64/lib/crtend.o
	$CC $BUILDPATH/x86_64/lib/crt0.o $BUILDPATH/x86_64/lib/crtbegin.o $FLAGS_C $FLAGS_LD "${args[@]}" $EXTRALIBS $BUILDPATH/x86_64/lib/crtend.o
	;;
    compilelink++)
	$CXX $BUILDPATH/x86_64/lib/crt0.o $BUILDPATH/x86_64/lib/crtbegin.o $FLAGS_CXX $FLAGS_LD "${args[@]}" $EXTRALIBS_CXX $BUILDPATH/x86_64/lib/crtend.o
	;;

    link)
	ld "${args[@]}"
	;;

    archive)
	ar "${args[@]}"
	;;

    ranlib)
	ranlib "${args[@]}"
	;;

    *)
	echo "$0: Internal cross-compilation wrapper error (mode $mode)!" > /dev/stderr
	exit 1
	;;
esac


More information about the Barrelfish-users mailing list