Passing complier output to bash

anneranch

Member
This is one of those "it works fine until...".

Background:
I am executing bash script to build a C++ library.
From options passed to the script it supposedly verify that selected crosscomplier is OK to use.

To aid development the compiler is optioned with " -v -V -qversion " in " do ...unit done " style loop.

I understand and use "-v" verbose option often.
I do not know why -V and -qversion are used since they are invalid options,
But that is NOT the problem, I can read an error log to identify the issue of invalid options.


Problem:
AT present the bash script output give no indication of failure.
Only the log file has the compiler verbose output in it.

How do I pass the compiler error or full verbose message BACK to bash script?
Or is it even possible ?

I would hope some kind of redirection would work, but I am not that verse in redirecting bash outputs.
I hope somebody in this group can help to figure it out.

I am enclosing the relevant part of the script and part of the log file.


bash script

# Provide some information about the compiler.
$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
set X $ac_compile
ac_compiler=$2
echo "@line $LINENO BUG checkiin for -V and -qversion "
for ac_option in --version -v -V -qversion; do
{ { ac_try="$ac_compiler $ac_option >&5"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_compiler $ac_option >&5") 2>conftest.err
ac_status=$?

*************** ??
if test -s conftest.err; then
sed '10a\
... rest of stderr output deleted ...
10q' conftest.err >conftest.er1
cat conftest.er1 >&5
************** ??
fi
rm -f conftest.er1 conftest.err
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
done

The answer MAY be in indicated part - I just do not know.



This is part of debug output in log file

configure:3532: $? = 0
configure:3521: arm-linux-gnueabihf-gcc -v >&5
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabihf/5/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-armhf-cross/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-armhf-cross --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-armhf-cross --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libgcj --enable-objc-gc --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-multilib --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabihf --program-prefix=arm-linux-gnueabihf- --includedir=/usr/arm-linux-gnueabihf/include
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9)
configure:3532: $? = 0
configure:3521: arm-linux-gnueabihf-gcc -V >&5

this is the output - from compiler itself - I like to also see in bash script

arm-linux-gnueabihf-gcc: error: unrecognized command line option '-V'
arm-linux-gnueabihf-gcc: fatal error: no input files
compilation terminated.
configure:3532: $? = 1
 


kenJackson

Member
You're trying to read a package configure script and the log file it creates. I've spent a lot of time doing that. It's frustrating.

But one thing you need to understand is that it has lots and lots of little tests, each of which answer one particular little question. A point of confusion is that sometimes the little test is successful when the compilation fails. That is, sometimes it does something the wrong way to be sure it fails.

Other times, a failure isn't fatal, but just means they have to exclude a particular feature.

In the case you cited, it loops through --version -v -V and -qversion to find the right switch to get the compiler version. Apparently there is some compiler somewhere on earth that takes a -qversion switch. I've never seen it. But once they encounter something, they add it to the bag of tricks so that if they ever encounter it again, the script will do the right thing.

If you're not sure if it succeeded or not, try the make file. That is, just run the make command and see if it compiles.
 

anneranch

Member
You're trying to read a package configure script and the log file it creates. I've spent a lot of time doing that. It's frustrating.

But one thing you need to understand is that it has lots and lots of little tests, each of which answer one particular little question. A point of confusion is that sometimes the little test is successful when the compilation fails. That is, sometimes it does something the wrong way to be sure it fails.

Other times, a failure isn't fatal, but just means they have to exclude a particular feature.

In the case you cited, it loops through --version -v -V and -qversion to find the right switch to get the compiler version. Apparently there is some compiler somewhere on earth that takes a -qversion switch. I've never seen it. But once they encounter something, they add it to the bag of tricks so that if they ever encounter it again, the script will do the right thing.

If you're not sure if it succeeded or not, try the make file. That is, just run the make command and see if it compiles.
Thanks for reply.
I feel it would be pointless to analyze the way blues configure works.

But I concur with your assessment - this particular code is "just there because".
I am actually going out on the limb to say this may not be the actual compile , just a very weird way to check if the compiler will do anything useful at all.
So if option "-v" passes and -V and -gversion does not it may not be that important.

I have yet another issue to resolve before I can do "make".
 

Members online


Latest posts

Top