[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [microblaze-uclinux] C++ output problems
Hi Joshua,
Joshua Moore-Oliva wrote:
>>Hmm, so building C++ programs for mb-uclinux? Although I have to
>>wonder, if they make no output, how you know they work? A philosophical
>>question perhaps? :)
>
> Well.. they compile and execute silently, with no error messages. To move this out of the realms of faith, I guess I could try putting one into an infinite loop and watching top.
>>Those complaints about the toolchain are ancient - these days building
>>mb-gcc and friensd is a lot easier (under a Linux box at least - haven't
>>tried lately under Windows). I have a script that I wrote that does
>>most of it automagically, I'll dig it out and send it to the list.
>
>
> That sounds very useful, I'll be waiting for it. I have about two weeks left in the research position I'm working on so there may just be enough time to fix a few things.
The script build-mbgcc is attached. It's been a while since I tried it,
and I think that was on an EDK6.3-era gcc (2.95.x, not 3.4.x). From
memory you run it from the directory in which you've expanded Xilinx's
gcc source tarball.
>>My feeling is that there's not much if anything you'll need to do in the
>>compiler, so much as getting STL port and all of the build environmetn
>>stuff in uClinux-dist working for Microblaze. Also there's the init and
>>fini preamble/postamble support in the uClibc runtime libraries as well.
>
> It wasn't the compiler as much as the custom libc.a and gcclib.a in the microblaze-elf-tools directory that I wanted to work with, as that is where the current conflicts appear to reside,
> and I'm guessing somewhere in there is where I need to define inbyte and outbyte. Anyways, being able to with with the libraries and get simple C style output working will be a first
> step towards larger STL implementations.
In a standalone microblaze software system,. inbyte and outbyte are
provided by the low-level driver code for the chosen in/out peripheral
(uartlite, mdm_uart, ...).
When building uClinux apps, if the linker complains about not finiding
inbyte or outbyte it usually means your erroneously referenced one of
Xilinx's IO library functions (print instead of printf is a classic one).
So, instead of trying to implement inbyte/outbyte, you really need to
find out why the linker is looking for them in the first place - it
shouldn't be.
Cheers,
John
#!/bin/sh
# Routine to handle building GNU newlib
build_libs() {
echo -n $"Building libs"
cd ${EDKSRC}/newlib/microblaze
# first we build libc and libm.
# there are 4 combinations for various combos of hard and soft
# multipliers and barrel shifters
# Make the soft-mult, soft-shift versions
make clean
make EXTRA_CFLAGS="-mxl-soft-mul" MULT=_soft
# Make the soft-mult, hard-shift versions
make clean
make EXTRA_CFLAGS="-mxl-soft-mul -mxl-barrel-shift" MULT=_soft SHIFT=_shift
# Make the hard-mult, hard-shift versions
make clean
make EXTRA_CFLAGS="-mno-xl-soft-mul" MULT=_hard
# Make the hard-mult, hard-shift versions
make clean
make EXTRA_CFLAGS="-mno-xl-soft-mul -mxl-barrel-shift" MULT=_hard SHIFT=_shift
# copy the libc_XX.a and libm_XX.a to where they belong
cp libc_*.a libm_*.a ${RELDIR}/microblaze/lib
cp libc_soft.a ${RELDIR}/microblaze/lib/libc.a
cp libm_soft.a ${RELDIR}/microblaze/lib/libm.a
# copy the C runtime startup libraries
cp libgloss/microblaze/crt*.o ${RELDIR}/microblaze/lib
}
# set up directories
setup_directories() {
# where is the source
export EDKSRC=`pwd`
# release (target) directory
if [ ! $RELDIR ]
then
export RELDIR=${EDKSRC}/reldir
fi
# where can we copy existing header files from?
if [ ! $HEADERDIR ]
then
export HEADERDIR=${EDKSRC}/mb-gcc-headers
fi
# make release directory
mkdir -p ${RELDIR}
}
# first build binutils:
build_binutils() {
cd ${EDKSRC}/binutils/microblaze
# build in a different directory than the sources
# - easy to make clean distribution
mkdir build
cd build
../configure --target=microblaze --prefix=${RELDIR}
make all CFLAGS="-O2 -g -DMICROBLAZE -DEDK" CXXFLAGS="-O2 -g -DMICROBLAZE -DEDK"
make install
# rename microblaze-as to mb-as
#mv ${RELDIR}/bin/microblaze-as ${RELDIR}/bin/mb-as
#mv ${RELDIR}/bin/microblaze-ld ${RELDIR}/bin/mb-ld
#mv ${RELDIR}/bin/microblaze-ar ${RELDIR}/bin/mb-ar
#mv ${RELDIR}/bin/microblaze-ranlib ${RELDIR}/bin/mb-ranlib
#mv ${RELDIR}/bin/microblaze-nm ${RELDIR}/bin/mb-nm
# add newly created binutils to the path
# put it first, to preceded any older tools
export PATH=${RELDIR}/bin/:${PATH}
}
# copy header files from install directory into new release directory
copy_headers() {
if [ ! -d ${RELDIR}/microblaze/include/ ]
then
mkdir -p ${RELDIR}/microblaze/include/
fi
cp -R ${HEADERDIR}/* ${RELDIR}/microblaze/include/
}
# build gcc
build_gcc () {
echo "Building gcc"
cd ${EDKSRC}/gcc
# keep object files in differnt directory to avoid strange errors
mkdir build
cd build
../configure --prefix=${RELDIR} --target=microblaze \
--nfp -v --enable-languages="c++" --with-newlib
make all CFLAGS="-O2 -g -DMICROBLAZE -DEDK" CXXFLAGS="-O2 -g -DMICROBLAZE -DEDK"
make install
}
build_gdb() {
echo "Building gdb"
cd ${EDKSRC}/gdb/microblaze
mkdir build
cd build
../configure --target=microblaze --prefix=${RELDIR}
make all CFLAGS="-O2 -g -DMICROBLAZE -DEDK" CXXFLAGS="-O2 -g -DMICROBLAZE -DEDK"
make install
}
build_elf2flt() {
echo -n $"Buildling elf2flt"
cd ${EDKSRC}
if [ -e elf2flt ]; then
cd elf2flt
if [ -e CVS ]; then
cvs update
fi
else
cvs -d:pserver:anonymous@cvs.uclinux.org:/var/cvs co elf2flt
fi;
cd ${EDKSRC}/elf2flt
mkdir build
cd build
if [ -e Makefile ]; then
make clean;
fi
# Get the bfd.h into somewhere we can find it
# otherwise we pick up an old version in /usr/include - bad
cp ${EDKSRC}/binutils/microblaze/build/bfd/bfd.h \
${EDKSRC}/binutils/microblaze/include
../configure --target=microblaze --prefix=${RELDIR} \
--with-libbfd=${RELDIR}/lib/libbfd.a \
--with-libiberty=${RELDIR}/lib/libiberty.a \
--with-bfd-include-dir=${EDKSRC}/binutils/microblaze/include
#--with-bfd-include-dir=${RELDIR}/include
make all
make install
}
build_genromfs() {
echo -n $"Buildling genromfs"
cd ${EDKSRC}
if [ -e genromfs ]; then
cd genromfs
if [ -e CVS ]; then
cvs update
fi
else
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/romfs co genromfs
fi
cd ${EDKSRC}/genromfs
make
cp ${EDKSRC}/genromfs/genromfs ${RELDIR}/bin
}
# need to rename these all as mb- for compatibility
# note we do cp, rather than mv, because, well, it's not as clean
# as it should be. We come through leater and delete the
# unneeded microblaze- files
rename_binaries() {
cd ${RELDIR}/bin
for f in microblaze-* ;
do
ff="mb-`echo $f | cut -d '-' -f 2`";
cp $f $ff;
done
}
# remove microblaze- binaries (all have been renamed to mb-)
remove_long_binaries() {
cd ${RELDIR}/bin
rm microblaze-*
}
# turn on debugging
# set -x
ORIG_DIR=`pwd`
setup_directories
build_binutils
build_gcc
rename_binaries
#build_gdb
build_elf2flt
rename_binaries
build_genromfs
rename_binaries
remove_long_binaries
build_libs
cd ${ORIG_DIR}