bugGPSD - Bugs: bug #44648, GPSD won't build if CCFLAGS...

 
 

bug #44648: GPSD won't build if CCFLAGS contains options that are only compatible with the cross-compiler

Submitter:  Per Olav Kroka <perok>
Submitted:  Fri 27 Mar 2015 11:34:52 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  esr
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 02 Dec 2015 09:24:49 AM UTC, comment #1: 

NOTE: The commit indexes referenced under Solution/Workaround are from my own commits to my own git which I have lost (sorry).

Commit 5e24bd130a5456d2f5b3b1c6bb2d7222b9613180 is compatible.

Per Olav Kroka <perok>
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



Per Olav Kroka <perok>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by esr (Updated the item)
  • -email is unavailable- added by perok (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-09-07 esr Open/ClosedOpen Closed
    2016-01-04 esr StatusNone Fixed
        Assigned toNone esr

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code