Bug 3819 - Duplicate definition of global pygtk symbols
Summary: Duplicate definition of global pygtk symbols
Status: RESOLVED FIXED
Alias: None
Product: Claws Mail (GTK 2)
Classification: Unclassified
Component: Other (show other bugs)
Version: other
Hardware: PC Linux
: P3 normal
Assignee: users
URL:
Depends on:
Blocks:
 
Reported: 2017-04-29 21:23 UTC by Hanno Boeck
Modified: 2017-05-05 00:24 UTC (History)
0 users

See Also:


Attachments
claws-mail-3.15.0-fix-no-common.patch (355 bytes, patch)
2017-04-29 21:23 UTC, Hanno Boeck
no flags Details | Diff

Description Hanno Boeck 2017-04-29 21:23:52 UTC
Created attachment 1748 [details]
claws-mail-3.15.0-fix-no-common.patch

When including the pygtk headers they create some global symbols. See e.g. this in pygtk.h:
#if defined(NO_IMPORT) || defined(NO_IMPORT_PYGTK)
extern struct _PyGtk_FunctionStruct *_PyGtk_API;
#else
struct _PyGtk_FunctionStruct *_PyGtk_API;
#endif

If these headers get included multiple times then the symbol is defined multiple times, which is not strictly correct C. Other files using the same global symbol have to mark it with "extern". pygtk does that if some #define commands are set. claws includes these headers in two files (src/plugins/python/clawsmailmodule.c, src/plugins/python/python-hooks.c).

Now by default gcc is lax with this and will accept duplicate symbols. However it can be turned into a more strict mode with the "-fno-common" flag. To reproduce:

./configure CFLAGS="-O2 -fno-common"; make

It will show an error like this:
.libs/python_la-python-hooks.o:(.bss+0x8): multiple definition of `_PyGObject_API'
.libs/python_la-clawsmailmodule.o:(.bss+0x8): first defined here
.libs/python_la-python-hooks.o:(.bss+0x0): multiple definition of `_PyGtk_API'
.libs/python_la-clawsmailmodule.o:(.bss+0x0): first defined here


To fix this the proper #define commands need to be set in one of the files including the pygtk headers. I have attached a patch to do that in clawsmailmodule.c. Please apply.
Comment 1 users 2017-05-05 00:23:03 UTC
Changes related to this bug have been committed.
Please check latest Git and update the bug accordingly.
You can also get the patch from:
http://git.claws-mail.org/

++ ChangeLog	2017-05-05 00:23:03.072329821 +0200
http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=27757159aa97b7e2c6892abb21cdd8716fb5116f
Merge: e877161 f6c690e
Author: Colin Leroy <colin@colino.net>
Date:   Fri May 5 00:23:02 2017 +0200

    Merge branch 'master' of file:///home/git/claws

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=f6c690e3c9928eb3694c033ee081fecb2e57a4a1
Author: Ricardo Mones <ricardo@mones.org>
Date:   Fri May 5 00:20:39 2017 +0200

    Fix bug #3819 “Duplicate definition of global pygtk symbols”
    
    Patch by Hanno Boeck (thanks! :)

Note You need to log in before you can comment on or make changes to this bug.