Fri 27 Mar 2015 11:34:52 AM UTC, original submission:
Problem description
GPSD won't build if CCFLAGS (or maybe another variable) contains switches that are incompatible with the local compiler (even though they are intended for the cross compiler).
Background
Using build.txt as information source I set the CCFLAGS as described in the "Notes on Android" section (with minor changes) since this also is cross platform building (or can be).
CCFLAGS
export CCFLAGS="-march=armv7-a -mtune=cortex-a9 -mfpu=vfp"
Commandline for building
scons ncurses=no dbus_export=no target=arm-xilinx-linux-gnueabi
Running Ubuntu/Linux on x86_64 processor so my gcc is different from the arm/xilinx one.
Failing command line
x86_64-linux-gnu-gcc -pthread -o gpsclient-py_2_7_6_final_0.so -c -fno-strict-aliasing -march=armv7-a -mtune=cortex-a9 -mfpu=vfp -pthread -fPIC -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -I/usr/include/python2.7 gpsclient.c
Error report
x86_64-linux-gnu-gcc: error: unrecognized command line option '-mfpu=vfp'
scons: *** [gpsclient-py_2_7_6_final_0.so] Error 1
scons: building terminated because of errors.
Your branch is up-to-date with 'origin/master'.
The unrecognised option originated from the CCFLAGS variable. It could have been any of the options.
==Solution/Workaround==
I do not know what this scan-build section is for, but it seems to change compilers. When changing compilers, it does not remove the CCFLAGS variables set for the previous (target) compiler.
I do not know if the solution indicated below is the perfect one (probably not), but it works (for me at least).
diff --git a/SConstruct b/SConstruct
index 5c9d8eb..d108080 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1119,10 +1119,23 @@ else:
# ensure that we build the python modules with scan-build, too
if env['CC'] is None or env['CC'].find('scan-build') < 0:
python_env['CC'] = cc
+
+ # As we seem to be changing compilers we must assume that the CCFLAGS are
+ # incompatible with the new compiler. If we should use other flags, the
+ # variable or the variable for this should be predefined.
+ if cc.split()[0] != env['CC']:
+ python_env['CCFLAGS']=''
else:
python_env['CC'] = ' '.join([env['CC']] + cc.split()[1:])
if env['CXX'] is None or env['CXX'].find('scan-build') < 0:
python_env['CXX'] = cxx
+
+ # As we seem to be changing compilers we must assume that the CCFLAGS or CXXFLAGS are
+ # incompatible with the new compiler. If we should use other flags, the
+ # variable or the variable for this should be predefined.
+ if cxx.split()[0] != env['CXX']:
+ python_env['CCFLAGS']=''
+ python_env['CXXFLAGS']=''
else:
python_env['CXX'] = ' '.join([env['CXX']] + cxx.split()[1:])
==First introduced according to git bisect==
fba8d442eb2aa51f3c28a90e545855c3b7d88589 is the first bad commit
commit fba8d442eb2aa51f3c28a90e545855c3b7d88589
Author: Eric S. Raymond <esr@thyrsus.com>
Date: Thu Apr 14 12:36:34 2011 -0400
Fold in Davev Taht's start on a cross-development environment.
:100644 100644 dbf228ccb42d5be1e4ea8e8acda5ac9ebb68f56c 4da3c47dc236062832b5ba643838b0c8503b06b3 M SConstruct
Test script
I used a script that I ran via git bisect run (place the script outside the gpsd folder!):
#!/bin/sh
scons ncurses=no dbus_export=no target=arm-xilinx-linux-gnueabi
ES=$?
#cleanup
git ls-files -o | xargs rm
#if any versioned files changed
git ls-files -m -d | xargs git co
echo "************************************************************************"
echo "$0: Exit state: $ES"
[ $ES = '0' ] && echo "$0: Exit state GOOD!" || echo "$0: Exit state BAD!"
echo "************************************************************************"
exit $ES
|