After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 660160 - gir-scanner fails if $CC includes arguments
gir-scanner fails if $CC includes arguments
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
: 660162 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-09-26 18:29 UTC by John Ralls
Modified: 2015-02-07 17:00 UTC
See Also:
GNOME target: ---
GNOME version: 3.1/3.2


Attachments
0001-scanner-split-CC-environment-variable.patch (1011 bytes, patch)
2011-10-10 13:44 UTC, ncopa
committed Details | Review

Description John Ralls 2011-09-26 18:29:26 UTC
With a diagnostic print added at sourcescanner.py line 280:
['/usr/bin/gcc-4.2 -std=gnu99', '-E', '-C', '-I.', '-', '-I..', '-I../gdk', '-I/usr/local/gtk-unstable-3/inst/include/glib-2.0', '-I/usr/local/gtk-unstable-3/inst/lib/glib-2.0/include', '-I/usr/local/gtk-unstable-3/inst/include/pango-1.0', '-I/usr/local/gtk-unstable-3/inst/include/cairo', '-I/usr/local/gtk-unstable-3/inst/include/pixman-1', '-I/usr/local/gtk-unstable-3/inst/include/freetype2', '-I/usr/local/gtk-unstable-3/inst/include/libpng12', '-I/usr/local/gtk-unstable-3/inst/include/gdk-pixbuf-2.0', '-I/usr/local/gtk-unstable-3/inst/include/gio-unix-2.0/', '-DG_LOG_DOMAIN="Gdk"', '-DGDK_COMPILATION', '-DG_DISABLE_CAST_CHECKS', '-D_REENTRANT']
Traceback (most recent call last):
  • File "/usr/local/gtk-unstable-3/inst/bin/g-ir-scanner", line 46 in <module>
    sys.exit(scanner_main(sys.argv))
  • File "/usr/local/gtk-unstable-3/inst/lib/gobject-introspection/giscanner/scannermain.py", line 407 in scanner_main
    ss = create_source_scanner(options, args)
  • File "/usr/local/gtk-unstable-3/inst/lib/gobject-introspection/giscanner/scannermain.py", line 332 in create_source_scanner
    ss.parse_files(filenames)
  • File "/usr/local/gtk-unstable-3/inst/lib/gobject-introspection/giscanner/sourcescanner.py", line 249 in parse_files
    self._parse(headers)
  • File "/usr/local/gtk-unstable-3/inst/lib/gobject-introspection/giscanner/sourcescanner.py", line 283 in _parse
    stdout=subprocess.PIPE)
  • File "/usr/local/gtk-unstable-3/inst/lib/python2.7/subprocess.py", line 672 in __init__
    errread, errwrite)
  • File "/usr/local/gtk-unstable-3/inst/lib/python2.7/subprocess.py", line 1202 in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

diff --git a/giscanner/sourcescanner.py b/giscanner/sourcescanner.py
index 5f0ec2d..f7d4879 100644
--- a/giscanner/sourcescanner.py
+++ b/giscanner/sourcescanner.py
@@ -274,7 +274,7 @@ class SourceScanner(object):
 
         defines = ['__GI_SCANNER__']
         undefs = []
-        cpp_args = [os.environ.get('CC', 'cc'), '-E', '-C', '-I.', '-']
+        cpp_args = os.environ.get('CC', 'cc').split() + '-E', '-C', '-I.', '-']
 
         cpp_args += self._cpp_options
         proc = subprocess.Popen(cpp_args,

Fixes the problem.
Comment 1 Javier Jardón (IRC: jjardon) 2011-09-27 12:11:26 UTC
*** Bug 660162 has been marked as a duplicate of this bug. ***
Comment 2 David Ronis 2011-09-27 16:34:03 UTC
With the patch added gobject-introspection doesn't build:

Traceback (most recent call last):
  • File "./g-ir-scanner", line 44 in <module>
    from giscanner.scannermain import scanner_main
  • File "./giscanner/scannermain.py", line 34 in <module>
    from giscanner.dumper import compile_introspection_binary
  • File "./giscanner/dumper.py", line 28 in <module>
    from .gdumpparser import IntrospectionBinary
  • File "./giscanner/gdumpparser.py", line 31 in <module>
    from .transformer import TransformerException
  • File "./giscanner/transformer.py", line 28 in <module>
    from .sourcescanner import (
  • File "./giscanner/sourcescanner.py", line 277
    cpp_args = os.environ.get('CC', 'cc').split() + '-E', '-C', '-I.', '-']

Comment 3 John Ralls 2011-09-27 16:37:30 UTC
Sorry, the line should be 
+        cpp_args = os.environ.get('CC', 'cc').split() + ['-E', '-C', '-I.',
'-']
Comment 4 David Ronis 2011-09-27 16:54:03 UTC
Even with the 2nd patch, it doesn't build:

 GICOMP gir/cairo-1.0.gir
Traceback (most recent call last):
  • File "./g-ir-scanner", line 46 in <module>
    sys.exit(scanner_main(sys.argv))
  • File "./giscanner/scannermain.py", line 407 in scanner_main
    ss = create_source_scanner(options, args)
  • File "./giscanner/scannermain.py", line 332 in create_source_scanner
    ss.parse_files(filenames)
  • File "./giscanner/sourcescanner.py", line 249 in parse_files
    self._parse(headers)
  • File "./giscanner/sourcescanner.py", line 279 in _parse
    cpp_args += self._cpp_options
TypeError: can only concatenate tuple (not "list") to tuple
make[3]: *** [GLib-2.0.gir] Error 1
Comment 5 John Ralls 2011-09-27 17:06:59 UTC
What version of Python are you using that you're getting a tuple instead of a list from string.split()?
Comment 6 David Ronis 2011-09-27 17:11:01 UTC
I'm using python-2.6.6  (slackware).   I got g-i to compile by changing the line to:

 +    cpp_args = [os.environ.get('CC', 'cc').split() + '-E', '-C', '-I.', '-']

The result still dies; e.g., in gdk-pixbuf-2.24.0:

make[5]: Entering directory `/home/ronis/Project/notar/GNOME/garnome/platform/gdk-pixbuf/work/main.d/gdk-pixbuf-2.24.0/gdk-pixbuf'
/opt/garnome-svn-3.2.0/bin/g-ir-scanner   --namespace=GdkPixbuf --nsversion=2.0 --libtool="/bin/sh ../libtool"  --include=GModule-2.0 --include=Gio-2.0 --pkg-export=gdk-pixbuf-2.0  --library=libgdk_pixbuf-2.0.la --warn-all --strip-prefix=Gdk --c-include="gdk-pixbuf/gdk-pixbuf.h" -DGDK_PIXBUF_COMPILATION -I.. -I.. -I../gdk-pixbuf -I../gdk-pixbuf -pthread -I/opt/garnome-svn-3.2.0/include/glib-2.0 -I/opt/garnome-svn-3.2.0/lib/glib-2.0/include -I/usr/include/libpng14     gdk-pixbuf.h gdk-pixbuf-core.h gdk-pixbuf-transform.h gdk-pixbuf-io.h gdk-pixbuf-animation.h gdk-pixbuf-simple-anim.h gdk-pixbuf-loader.h gdk-pixbuf-enum-types.h gdk-pixbuf-marshal.h gdk-pixbuf-features.h gdk-pixdata.h gdk-pixbuf-i18n.h gdk-pixbuf.c gdk-pixbuf-animation.c gdk-pixbuf-data.c gdk-pixbuf-io.c gdk-pixbuf-loader.c gdk-pixbuf-scale.c gdk-pixbuf-simple-anim.c gdk-pixbuf-scaled-anim.c gdk-pixbuf-util.c gdk-pixdata.c gdk-pixbuf-enum-types.c libgdk_pixbuf-2.0.la Makefile --output GdkPixbuf-2.0.gir
g-ir-scanner: warning: Option --strip-prefix has been deprecated;
see --identifier-prefix and --symbol-prefix.
Traceback (most recent call last):
  • File "/opt/garnome-svn-3.2.0/bin/g-ir-scanner", line 46 in <module>
    sys.exit(scanner_main(sys.argv))
  • File "/opt/garnome-svn-3.2.0/lib/gobject-introspection/giscanner/scannermain.py", line 407 in scanner_main
    ss = create_source_scanner(options, args)
  • File "/opt/garnome-svn-3.2.0/lib/gobject-introspection/giscanner/scannermain.py", line 332 in create_source_scanner
    ss.parse_files(filenames)
  • File "/opt/garnome-svn-3.2.0/lib/gobject-introspection/giscanner/sourcescanner.py", line 249 in parse_files
    self._parse(headers)
  • File "/opt/garnome-svn-3.2.0/lib/gobject-introspection/giscanner/sourcescanner.py", line 282 in _parse
    stdout=subprocess.PIPE)
  • File "/usr/lib/python2.6/subprocess.py", line 623 in __init__
    errread, errwrite)
  • File "/usr/lib/python2.6/subprocess.py", line 1141 in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
make[5]: *** [GdkPixbuf-2.0.gir] Error 1
Comment 7 John Ralls 2011-09-27 17:42:20 UTC
It's still not splitting out correctly, then.

Put this in after the assignment of cpp_args:
      print cpp_args

You want a single list that looks something like
     ['/usr/bin/gcc', '-first_arg', '-E', '-C', '-I.', '-']
but you're probably getting
    [('/usr/bin/gcc', '-first_arg'), '-E', '-C', '-I.', '-'] 
because your (defective) python is returning that tuple.

I think you can fix it with 
    cpp_args = list(os.environ.get('CC', 'cc')) + ['-E', '-C', '-I.','-']
which is harmless in properly working pythons which return a list from string.split() as documented.
Comment 8 David Ronis 2011-09-27 17:46:20 UTC
Strange, I purged the directories and rebuilt.   The form of the patch I
suggested in comment 6 now fails, while yours in comment 3 or 7 

cpp_args = list(os.environ.get('CC', 'cc')) + ['-E', '-C', '-I.','-']

now works, and gdk-pixbuf  builds without complaint.

Thanks.
Comment 9 ncopa 2011-10-10 13:44:52 UTC
Created attachment 198714 [details] [review]
0001-scanner-split-CC-environment-variable.patch
Comment 10 Colin Walters 2011-10-10 14:58:33 UTC
Review of attachment 198714 [details] [review]:

This isn't going to work if the environment variable contains quoted whitespace, like:

export CC="'/home/walters/Source Code/gcc'".  On the other hand, make doesn't work either.  So...I guess we can just do this.
Comment 11 André Klapper 2015-02-07 17:00:58 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]