Tutorial Time
Mark Butcher
M_J_BUTCHER@compuserve.com
Wed Jun 12 15:48:00 GMT 2002
Hi All
This is both a request for help and a discussion of internal workings.
The background is that I am (still) having problems building a cross
compiler for the Mcore target and have decided to learn as much as possible
about the procedure and environment so that I can solve them myself (still
beginner status with regards to just about everything).
I have configured to build c and c++ and the build is failing while
configuring internally to build the c++ library "libstdc++".
Here is the script which is failing while trying to identify the exception
model:
/************************************ beginning of script part causing
error ************************************************/
echo $ac_n "checking for exception model to use""... $ac_c" 1>&6
echo "configure:3700: checking for exception model to use" >&5
ac_ext=C
# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS
conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cxx_cross
# Check whether --enable-sjlj-exceptions or --disable-sjlj-exceptions was
given.
if test "${enable_sjlj_exceptions+set}" = set; then
enableval="$enable_sjlj_exceptions"
:
else
cat > conftest.$ac_ext << EOF
#line 3715 "configure"
struct S { ~S(); };
void bar();
void foo()
{
S s;
bar();
}
EOF
old_CXXFLAGS="$CXXFLAGS"
CXXFLAGS=-S
if { (eval echo configure:3726: \"$ac_compile\") 1>&5; (eval
$ac_compile) 2>&5; }; then
if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
enable_sjlj_exceptions=yes
elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
enable_sjlj_exceptions=no
fi
fi
CXXFLAGS="$old_CXXFLAGS"
rm -f conftest*
fi
if test x$enable_sjlj_exceptions = xyes; then
cat >> confdefs.h <<\EOF
#define _GLIBCPP_SJLJ_EXCEPTIONS 1
EOF
ac_exception_model_name=sjlj
elif test x$enable_sjlj_exceptions = xno; then
ac_exception_model_name="call frame"
else
{ echo "configure: error: unable to detect exception model" 1>&2; exit
1; }
fi
/************************************ end of script part causing error
************************************************/
After analysing this I have identified that a test file called conftest.c
is temporarily created with the following contents
#line 3715 "configure"
struct S { ~S(); };
void bar();
void foo()
{
S s;
bar();
}
This is then compiled to test what the compiler generates - the exact
command being:
/usr/local/src/gnu/BUILD/gcc/gcc/xgcc -B/usr/local/src/gnu/BUILD/gcc/gcc/
-nostdinc++ -L/usr/local/src/gnu/BUILD/gcc/mcore-elf/libstdc++-v3/src
-L/usr/local/src/gnu/BUILD/gcc/mcore-elf/libstdc++-v3/src/.libs
-B/usr/local/mcore/mcore-elf/bin/ -B/usr/local/mcore/mcore-elf/lib/
-isystem /usr/local/mcore/mcore-elf/include -c -S conftest.C
Now, if I actually compile this file with the said command I see that the
generated assembler file is correct for the desired target (Mcore) - the
content is:
.file "conftest.c"
.text
.align 1
.export _Z3foov
.type _Z3foov,@function
_Z3foov:
subi sp,16
stw r15,(sp,8)
stw r8,(sp,12)
mov r8,sp
jbsr _Z3barv
mov r2,r8
jbsr _ZN1SD1Ev
mov sp,r8
ldw r15,(sp,8)
ldw r8,(sp,12)
addi sp,16
jmp r15
.Lfe1:
.size _Z3foov,.Lfe1-_Z3foov
.ident "GCC: (GNU) 3.0.4"
If I am correctly interpreting the script, grep is used to search for
information about two possible exception models, either the string
_Unwind_SjLj_Resume or
_Unwind_Resume
should be somewhere in the S-file.
Since none of these are in the file, the configuration can not identify the
model and aborts.
Now to the questions:
1. Are these strings (which are searched for) added by some compilers and
not by the mcore cross compiler ?
2. Could this error be avoided by configuring with
"--disable-sjlj-exceptions"
3. What does sjij mean ?
4. Can anyone explain what this 'exception' model is, or where to get the
necessary details about it ?
5. I have scanned various documents and have not yet found a mention of the
Motorola Mcore being supported by GCC (I didn't find anything in the latest
version of the gcc compiler manual). Have I missed something or is this
really the case ?
6. Does anyone know details about the target configuration (for example use
of --disable-sjlj-exceptions, if necessary) ? I checked out lists of test
reports and found no mention of the Mcore there.
7. Am I mad ? (if not, certainly on the way...)
Thanks for any remarks
Cheers
Mark in Switzerland
More information about the Gcc-help
mailing list