bugMyPaint - Bugs: bug #20754, brushlib: cannot set optimization...

Show feedback again

You are not allowed to post comments on this tracker with your current authentification level.

bug #20754: brushlib: cannot set optimization level during build - command line option ordering problems

Submitted by:  Andrew Chadwick <achadwick>
Submitted on:  Sun Apr 21 20:30:26 2013  
Severity: 2 - MinorPriority: 5 - Normal
Status: FixedPrivacy: Public
Assigned to: NoneOpen/Closed: Closed
Release: 1.1.0+git 8ae515aPlanned Release: None
Operating System: Linux unstable/Sid @now

Wed Jun 25 19:32:58 2014, comment #4:

This should be fixed in https://github.com/mypaint/mypaint/commit/bb8e660a908e22d2923fde7d68955914eee6ca35 - thanks for the hint about how to fix it!

[We're moving bug tracking over to github so if there's any fallout from this bug, please report it at https://github.com/mypaint from now on. Many thanks!]

Andrew Chadwick <achadwick>
Project Administrator
Sun Dec 1 08:36:44 2013, comment #3:

It all was because python:2.7 was built with the debug information, so `python-config --cflags` returned -O0 among the other flags.

The following patch fixed that for me.

--- mypaint-1.1.0.orig/lib/SConscript 2013-01-01 00:03:38.000000000 +0700
+++ mypaint-1.1.0/lib/SConscript 2013-12-01 15:32:16.570748951 +0700
@@ -101,6 +100,9 @@
# make sure assertions are enabled

+env['CCFLAGS'] = ([o for o in env['CCFLAGS'] if not o.startswith('-O')] +
+ [o for o in env['CCFLAGS'] if o.startswith('-O')][:1])
# python extension module
src = 'mypaintlib_wrap.cpp'
module = build_py_module(env, '../_mypaintlib', Split(src), SHLIBPREFIX="")

unknown <unknown>
Sat Oct 12 15:32:12 2013, comment #2:

I cannot build mypaint-1.1.0 or mypaint-git for months now. No matter which CFLAGS and CXXFLAGS I use (-O2, -O1 or -O0), the application does not start, saying:

ImportError: /home/unknown/tmp/mypaint/mypaint-1.1.0/_mypaintlib.so: undefined symbol: _ZN10BufferCompIL20BufferCompOutputType1ELj16384E15DarkenBlendModeE9blendfuncE

I execute the following command before running scons:
where N = 0, 1, 2
The log of -O2 build: http://bpaste.net/show/139911/
The log of -O0 build: http://bpaste.net/show/139912/
(Here I used a patch to make scons respect the environment, but vanilla builds are all the same.)

Note that despite the specified -O2 flags, there is -O0 in the first log, and it is the latest -O option, supplied to gcc. I don't know how it got there, there seem to be no -O0 options (short of debug build) in the sources.

I'm totally desperate now.

unknown <unknown>
Mon Apr 22 00:34:43 2013, comment #1:

Correction: hilarity (and linker failures at runtime) ensues with -O0. -O1 is fine.

Hopefully partly addressed in https://gitorious.org/mypaint/mypaint/commit/c006e4e35d1354b4de4c9bed8f742d00468c4ef4 , which at least allows similar inconsistencies relating to Debian build hardening to be fixed: http://bugs.debian.org/704927

This bug is still In Progress rather than Fixed because simply throwing more options at it doesn't allow a -O0 build:

since it gets overridden by (json-c's?) later config options for pretty much everything in brushlib/.

Retitling this bug.

Andrew Chadwick <achadwick>
Project Administrator
Sun Apr 21 20:30:26 2013, original submission:

If MyPaint is compiled and run with CFLAGS=-O1, hilarity ensues:

(Not sure if my over-clever templating stuff for genericizing blend modes is at fault here. If somebody with better C++ chops than me could have a look at it, I'd be much obliged.)

This was in essence reported in Debian bug http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=704935 , and I'm working on a fix for stable 1.1.0 downstream. Presumably it's due to inconsistent use of optimization flags.

Chasing the cause of the error reveals a few facts:

1. the bulk of brushlib, and its tests, do not respect CFLAGS, and just uses the default -O3 for that type of build
2. CFLAGS are respected when building mypaint's _mypaintlib.so (and that's it).

This is inconsistent and breaks some downstream builds, albeit not in a way that can't be worked around downstream too.

(As an aside, should we go the route of


, i.e. using Environment(**ARGUMENTS) - trailing command-line options to scons - instead of os.environ? If we're calling third part apps like scons, presumably we have no option.)

Andrew Chadwick <achadwick>
Project Administrator


No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by unknown (Posted a comment)
  • -unavailable- added by unknown (Voted in favor of this item)
  • -unavailable- added by achadwick (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Error: not logged in



    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed Jun 25 19:32:58 2014achadwickStatusIn Progress=>Fixed
    Sat Oct 12 15:32:12 2013unknownCarbon-Copy-=>Added unknown
    Mon Apr 22 00:34:43 2013achadwickStatusNone=>In Progress
      Summarybrushlib: CFLAGS not respected (more generally, we need a consistent way of passing CFLAGS, LDFLAGS etc.)=>brushlib: cannot set optimization level during build - command line option ordering problems
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup