Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 145206 - python's distutils does not respect CXXFLAGS
Summary: python's distutils does not respect CXXFLAGS
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 212178
  Show dependency tree
 
Reported: 2006-08-26 15:11 UTC by SpanKY
Modified: 2008-04-19 14:46 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
distutils uses CXXFLAGS instead of CFLAGS for C++ files (python-2.5.2-distutils-cxxflags.patch,3.54 KB, patch)
2008-04-03 07:50 UTC, Markus Peloquin
Details | Diff
fixed some strange things in my last patch (irrelevant code) (python-2.5.2-distutils-cxxflags.patch,3.14 KB, patch)
2008-04-03 08:02 UTC, Markus Peloquin
Details | Diff
Better language detection (python-2.5.2-distutils-cxxflags.patch,4.11 KB, patch)
2008-04-07 06:18 UTC, Markus Peloquin
Details | Diff
The difference between last two revisions I made. (diff-between-revisions.patch,1.88 KB, patch)
2008-04-07 06:20 UTC, Markus Peloquin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description SpanKY gentoo-dev 2006-08-26 15:11:02 UTC
the wxpython package compiles a lot of C++ code using $(CFLAGS) instead of $(CXXFLAGS)

# portageq envvar -v CFLAGS CXXFLAGS
CFLAGS='-O2 -march=k8 -pipe -Wimplicit-function-declaration'
CXXFLAGS='-O2 -march=k8 -pipe'

# emerge wxpython
...
x86_64-pc-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -march=k8 -pipe -Wimplicit-function-
declaration -fPIC -DSWIG_TYPE_TABLE=_wxPython_table -DHAVE_CONFIG_H -DWXP_USE_THREAD=1 -UNDEBUG -DGTK_N
O_CHECK_CASTS -D__WXGTK__ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -DNO_GCC_PRAGMA -Iinclude -Isrc -I/usr/
lib64/wx/include/gtk2-ansi-release-2.6 -I/usr/include/wx-2.6 -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.
0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 
-I/usr/lib64/glib-2.0/include -I/usr/include/python2.4 -c src/gtk/grid_wrap.cpp -o build-gtk2/temp.linu
x-x86_64-2.4/src/gtk/grid_wrap.o
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for
 C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for
 C++
...
Comment 1 Ryan Hill (RETIRED) gentoo-dev 2007-12-28 20:40:38 UTC
i took a look at this and i can't find where CFLAGS gets picked up by the build system.   the only place that it seems to even look is in config.py:

cflags = os.popen(WX_CONFIG + ' --cxxflags', 'r').read()[:-1]

which still wouldn't use CFLAGS.  unless it gets this info from swig somehow.
Comment 2 SpanKY gentoo-dev 2007-12-29 10:06:45 UTC
i'm guessing this is distutils failing

/usr/lib/python2.5/distutils/sysconfig.py

this checks CFLAGS, CPPFLAGS, and LDFLAGS -- no CXXFLAGS
Comment 3 Markus Peloquin 2008-04-03 07:50:42 UTC
Created attachment 148178 [details, diff]
distutils uses CXXFLAGS instead of CFLAGS for C++ files

I added "-include killcpp.h" to CFLAGS, where killcpp.h contained illegal c++ code, but valid c.  emerge finished, so I'm pretty sure my solution worked :)  I'm pretty sure it's correct, but I hope somebody with more python skills can look it over.

I hope nobody minds that I patched against python-2.5.2, but that's what I have installed, and I need some sleep.
Comment 4 Markus Peloquin 2008-04-03 08:01:32 UTC
Comment on attachment 148178 [details, diff]
distutils uses CXXFLAGS instead of CFLAGS for C++ files

strangeness crept in
Comment 5 Markus Peloquin 2008-04-03 08:02:58 UTC
Created attachment 148180 [details, diff]
fixed some strange things in my last patch (irrelevant code)
Comment 6 Tiziano Müller (RETIRED) gentoo-dev 2008-04-03 13:00:12 UTC
@Mark: nice job. The patch I started working on was meant to do the same but you were a bit faster.
I guess it can be included as it is.
Comment 7 SpanKY gentoo-dev 2008-04-07 02:03:28 UTC
where did you get the .c/.m list of types ?  there are other types which should go through the C compiler, but i think it may be saner to flip the logic ... hard code the list for C++, and have everything else go through C ...

otherwise, thanks, it looks good :)
Comment 8 Markus Peloquin 2008-04-07 06:18:36 UTC
Created attachment 148946 [details, diff]
Better language detection

Maybe this is more what you're looking for.  I found a function detect_language() that uses a map of extension -> language.  Below is a patch from my previous revision to this one.
Comment 9 Markus Peloquin 2008-04-07 06:20:21 UTC
Created attachment 148947 [details, diff]
The difference between last two revisions I made.
Comment 10 SpanKY gentoo-dev 2008-04-07 21:33:46 UTC
ah, very nice ... that looks good to me
Comment 11 Ali Polatel (RETIRED) gentoo-dev 2008-04-18 14:31:49 UTC
+*python-2.5.2 (18 Apr 2008)
+*python-2.4.4-r10 (18 Apr 2008)
+*python-2.3.6-r5 (18 Apr 2008)
+
+  18 Apr 2008; Ali Polatel <hawking@gentoo.org> +python-2.3.6-r5.ebuild,
+  +python-2.4.4-r10.ebuild, +python-2.5.2.ebuild:
+  Version bumps. Updated patchsets to fix buffer overflow in zlib extension
+  (CVE-2008-1721) bug 217221 and unsafe PyString_FromStringAndSize(). Added
+  patch by Mark Peloquin for distutils to respect CXXFLAGS, bug 145206. Add
+  wininst USE flag to conditionally install MS Windows executables, bug
+  198021. Use EAPI=1, rename nothreads and nocxx USE flags to threads and
+  cxx.
+

Thanks Mark, I've included your patch to our patchset.
Comment 12 Darren Dale 2008-04-19 13:48:13 UTC
Yikes, this patch breaks distutils if CXXFLAGS is not defined. I discovered it when I tried to compile matplotlib outside of portage. Distutils fails with the following traceback:

Traceback (most recent call last):
  File "setup.py", line 277, in <module>
    **additional_params
  File "/usr/lib64/python2.5/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib64/python2.5/distutils/dist.py", line 974, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.5/distutils/dist.py", line 994, in run_command
    cmd_obj.run()
  File "/usr/lib64/python2.5/distutils/command/build.py", line 112, in run
    self.run_command(cmd_name)
  File "/usr/lib64/python2.5/distutils/cmd.py", line 333, in run_command
    self.distribution.run_command(command)
  File "/usr/lib64/python2.5/distutils/dist.py", line 994, in run_command
    cmd_obj.run()
  File "/usr/lib64/python2.5/distutils/command/build_ext.py", line 265, in run
    customize_compiler(self.compiler)
  File "/usr/lib64/python2.5/distutils/sysconfig.py", line 177, in customize_compiler
    cxx_cmd = cxx + ' ' + cxxflags
TypeError: cannot concatenate 'str' and 'NoneType' objects

If I define CXXFLAGS, I can compile again.
Comment 13 Ali Polatel (RETIRED) gentoo-dev 2008-04-19 14:46:35 UTC
2.5.2-r2 and 2.4.4-r11 fixes that.