This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: ./pyconfig.h:1438:0: warning: "_GNU_SOURCE" redefined [enabled by default]
Type: Stage: resolved
Components: Build Versions: Python 3.7, Python 3.6, Python 3.3, Python 3.4, Python 3.5, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: vstinner Nosy List: Segev Finer, ned.deily, vstinner
Priority: normal Keywords:

Created on 2017-06-28 22:24 by Segev Finer, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 2615 merged ned.deily, 2017-07-07 05:14
PR 2670 merged Segev Finer, 2017-07-11 18:00
PR 2671 merged Segev Finer, 2017-07-11 21:56
PR 2672 merged Segev Finer, 2017-07-11 21:57
Messages (7)
msg297238 - (view) Author: Segev Finer (Segev Finer) * Date: 2017-06-28 22:24
This is caused by _GNU_SOURCE being defined here:, But also getting defined by AC_USE_SYSTEM_EXTENSIONS (

AC_USE_SYSTEM_EXTENSIONS does use an #ifndef but Python's AC_DEFINE seems to be getting order after it.
msg297860 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2017-07-07 05:31
New changeset 05b72ede95521b2d897cb4c7b034139b5437c592 by Ned Deily in branch '3.6':
bpo-30797, bpo-30694: Avoid _GNU_SOURCE redefined warning in xmlparse.c (#2615)
msg297861 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2017-07-07 05:53
Thanks for the report.  This warning is currently visible on many/all of the buildbots on all branches.  The conflict is caused by the upgrade of the bundled to libexpat to version 2.2.1 (bpo-30694). 2.2.1 introduced a define of _GNU_SOURCE into Modules/expat/xmlparse.c.  The definition in xmlparse is simply:

#define _GNU_SOURCE

But Python, in pyconfig.h, which ./configure generates from, may already have defined _GNU_SOURCE thusly:

#define _GNU_SOURCE 1

pyconfig.h gets included into our copy of Modules/expat/expat_config.h which is included later in xmlparse.c causing the compile warning.

The simplest way to avoid the warning is to just change the definition in xmlparse.c to match that in pyconfig.h; the compilers don't complain if the definition is identical.  I have now merged that fix into the 3.6 branch so builders of 3.6.2 won't see the warning.  I will leave this open for @haypo to review and to handle merging into the other branches affected by bpo-30694 (master, 3.5, 2.7, 3.4, 3.3).
msg297871 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2017-07-07 08:37
One more thing: building with a recent gcc on Linux:
$ gcc --version
gcc (Debian 6.3.0-18) 6.3.0 20170516

also gives an "unused but set variable" warning.

./Modules/expat/xmlparse.c: In function ‘gather_time_entropy’:
./Modules/expat/xmlparse.c:780:7: warning: variable ‘gettimeofday_res’ set but not used [-Wunused-but-set-variable]
   int gettimeofday_res;

Since I didn't see it in time, I didn't try to fix this for 3.6.2 but it would be best to silence it going forward.
msg297931 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2017-07-08 04:51
New changeset bdabd7666032ce356d550da21c35e4bee5b3448c by Ned Deily in branch '3.6':
bpo-30797, bpo-30694: Avoid _GNU_SOURCE redefined warning in xmlparse.c (#2615)
msg298185 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-07-11 22:16
New changeset 884c4ca33ab84b9fc57338cf59f79e0436d3da43 by Victor Stinner (Segev Finer) in branch '2.7':
[2.7] bpo-30797: Avoid _GNU_SOURCE redefined warning in xmlparse.c (GH-2670) (#2672)
msg298236 - (view) Author: Segev Finer (Segev Finer) * Date: 2017-07-12 17:11
The fix is now in 3.5-3.7 and 2.7, unless you intend to also back port to 3.4 and 3.3, this can be closed.
Date User Action Args
2022-04-11 14:58:48adminsetgithub: 74980
2017-07-16 08:55:23ned.deilysetstatus: open -> closed
resolution: fixed
stage: backport needed -> resolved
2017-07-12 17:11:11Segev Finersetmessages: + msg298236
2017-07-11 22:16:30vstinnersetmessages: + msg298185
2017-07-11 21:57:25Segev Finersetpull_requests: + pull_request2740
2017-07-11 21:56:31Segev Finersetpull_requests: + pull_request2739
2017-07-11 18:00:20Segev Finersetpull_requests: + pull_request2736
2017-07-08 04:51:39ned.deilysetmessages: + msg297931
2017-07-07 08:37:04ned.deilysetmessages: + msg297871
2017-07-07 05:53:16ned.deilysetassignee: vstinner
type: compile error ->
versions: + Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6
nosy: + vstinner

messages: + msg297861
stage: backport needed
2017-07-07 05:31:46ned.deilysetnosy: + ned.deily
messages: + msg297860
2017-07-07 05:14:18ned.deilysetpull_requests: + pull_request2680
2017-06-28 22:24:05Segev Finercreate