Bad includes generated by snapcraft scons plugin

Bug #1587289 reported by Mark Shuttleworth
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
Invalid
Medium
Sergio Schvezov

Bug Description

This part fails to build:

  gpsd:
    plugin: scons
    source: http://download-mirror.savannah.gnu.org/releases/gpsd/gpsd-3.16.tar.gz
    scons-options: [ prefix=/usr/, python=no, qt=no ]
    stage-packages: [ libncurses5-dev, libtinfo-dev ]

The final error is this:

gcc -o ais_json.os -c -I/home/mark/software/timesink/parts/gpsd/install/usr/include -I/home/mark/software/timesink/parts/gpsd/install/usr/include/x86_64-linux-gnu -Wextra -Wall -Wno-uninitialized -Wno-missing-field-initializers -Wcast-align -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -Wreturn-type -pthread -Wmissing-declarations -O2 -fPIC " -I/home/mark/software/timesink/parts/gpsd/install/usr/include -I/home/mark/software/timesink/parts/gpsd/install/usr/include/x86_64-linux-gnu" ais_json.c

And the issue appears to be the " " around the double -I sections, which make GCC think that there is supposed to be a file called " -I ... -I ..."

Changed in snapcraft:
milestone: none → 2.11
assignee: nobody → Sergio Schvezov (sergiusens)
importance: Undecided → Medium
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

We export include directories for the staging area and staged packages (from `stage-packages`) to allow building this. What we do is for CPPFLAGS, CFLAGS and CXXFLAGS is to add -I directives for the canonical include directories which are on non standard paths.

It seems the SConstruct file for gpsd treats CPPFLAGS differently:

- SConstruct:261 for CFLAGS
- SConstruct:265 for CPPFLAGS

Where the former does a proper split while the latter does a plain join. Given that CPPFLAGS is really the proper way to declare includes (and we use the others for some compatibility with a plethora of build systems) I feel reluctant to just remove CPPFLAGS here.

That said, to unblock you quickly you can change those `stage-packages` to `build-packages`

Does my assessment sound fair?

Changed in snapcraft:
status: New → Incomplete
Revision history for this message
Mark Shuttleworth (sabdfl) wrote : Re: [Bug 1587289] Re: Bad includes generated by snapcraft scons plugin

Well, somehow Scons is ending up telling GCC to '"-I X -I Y"' (note the
double set of quotes). That's a bug :)

I bet if the "" were removed it would work. I just don't know where in
the stack it's coming from.

Mark

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

El 06/06/16 a las 16:42, Mark Shuttleworth escribió:
> Well, somehow Scons is ending up telling GCC to '"-I X -I Y"' (note the
> double set of quotes). That's a bug :)
>
> I bet if the "" were removed it would work. I just don't know where in
> the stack it's coming from.

The SConstruct file is part of gpsd's source code.
The current sources you are using have:
        env.MergeFlags({flag : [os.getenv(flag)]})

I just checked upstream's latest and greatest[1] and I see it seems to
have been corrected:
        env.MergeFlags({flag: Split(os.getenv(flag))})

So I rolled in the git tree as a source, replacing the tarball, and it
all works fine.

I am marking this invalid, if you feel that is wrong, feel free to
reopen it. But the fact is, we are just passing an envvar of the form
CLFAGS="$CFLAGS -I/usr/include -I/usr/include/..." and the SConstruct
was grabbing that envvar incorrectly.

[1] http://git.savannah.gnu.org/cgit/gpsd.git/tree/SConstruct#n311

Changed in snapcraft:
status: Incomplete → Invalid
Revision history for this message
Mark Shuttleworth (sabdfl) wrote :

Perfect, thank you!

Changed in snapcraft:
milestone: 2.12 → 2.13
milestone: 2.13 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.