Title: -Werror=declaration-after-statement expat build failure on Python 3.5
Type: compile error Stage: resolved
Components: Versions: Python 3.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: larry, ncoghlan, vstinner
Priority: low Keywords: patch

Created on 2018-01-16 05:14 by ncoghlan, last changed 2018-03-30 08:30 by ncoghlan. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 5201 merged ncoghlan, 2018-01-16 10:50
Messages (6)
msg310037 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2018-01-16 05:14
A fresh Python 3.5 checkout failed to build the embedded expat XML library for me, due to the configure check that adds "-Werror=declaration-after-statement" to the compiler flags.

I'm guessing this was introduced via the expat code changes brought in for

That configure check is gone in 3.6 and 3.7, but it's still there in 3.5.

Locally, I've worked around the problem by removing the configure check, but I'm not sure that's the right answer, as I believe we still promise that 3.5 will build under C89.
msg310038 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2018-01-16 05:50
Details of the compilation failure:

building 'pyexpat' extension
gcc -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Werror=declaration-after-statement -DHAVE_EXPAT_CONFIG_H=1 -DXML_POOR_ENTROPY=1 -DUSE_PYEXPAT_CAPI -I/home/ncoghlan/devel/py35/Modules/expat -I./Include -I. -I/usr/local/include -I/home/ncoghlan/devel/py35/Include -I/home/ncoghlan/devel/py35 -c /home/ncoghlan/devel/py35/Modules/pyexpat.c -o build/temp.linux-x86_64-3.5/home/ncoghlan/devel/py35/Modules/pyexpat.o
gcc -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Werror=declaration-after-statement -DHAVE_EXPAT_CONFIG_H=1 -DXML_POOR_ENTROPY=1 -DUSE_PYEXPAT_CAPI -I/home/ncoghlan/devel/py35/Modules/expat -I./Include -I. -I/usr/local/include -I/home/ncoghlan/devel/py35/Include -I/home/ncoghlan/devel/py35 -c /home/ncoghlan/devel/py35/Modules/expat/xmlparse.c -o build/temp.linux-x86_64-3.5/home/ncoghlan/devel/py35/Modules/expat/xmlparse.o
gcc -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Werror=declaration-after-statement -DHAVE_EXPAT_CONFIG_H=1 -DXML_POOR_ENTROPY=1 -DUSE_PYEXPAT_CAPI -I/home/ncoghlan/devel/py35/Modules/expat -I./Include -I. -I/usr/local/include -I/home/ncoghlan/devel/py35/Include -I/home/ncoghlan/devel/py35 -c /home/ncoghlan/devel/py35/Modules/expat/xmlrole.c -o build/temp.linux-x86_64-3.5/home/ncoghlan/devel/py35/Modules/expat/xmlrole.o
gcc -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Werror=declaration-after-statement -DHAVE_EXPAT_CONFIG_H=1 -DXML_POOR_ENTROPY=1 -DUSE_PYEXPAT_CAPI -I/home/ncoghlan/devel/py35/Modules/expat -I./Include -I. -I/usr/local/include -I/home/ncoghlan/devel/py35/Include -I/home/ncoghlan/devel/py35 -c /home/ncoghlan/devel/py35/Modules/expat/xmltok.c -o build/temp.linux-x86_64-3.5/home/ncoghlan/devel/py35/Modules/expat/xmltok.o
/home/ncoghlan/devel/py35/Modules/expat/xmltok.c: In function ‘utf8_toUtf8’:
/home/ncoghlan/devel/py35/Modules/expat/xmltok.c:408:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
   const char * const fromLimBefore = fromLim;
/home/ncoghlan/devel/py35/Modules/expat/xmltok.c:414:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
   const ptrdiff_t bytesToCopy = fromLim - *fromP;
cc1: some warnings being treated as errors
msg310066 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-01-16 09:47
Hum, I backported a fix to 3.4 but I forgot Python 3.5.

My fix for Python 3.4 is made of multiple bugfixes: 8b11e8de7aedacfbbcc8c780f3c4097396f1d1a3

For Python 3.5, you want at least this change I think:
msg310074 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2018-01-16 10:53
I couldn't persuade git to pull the upstream patch in directly, so I just made the same change downstream:
msg310491 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2018-01-23 10:24
New changeset 57fa0ab8911a70d91e5b60b8dc91f1085442a9e7 by larryhastings (Nick Coghlan) in branch '3.5':
[3.5] bpo-32563: Get expat to compile under C89 (#5201)
msg314683 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2018-03-30 08:30
Tidying up old git branches, and I noticed this was still open even though Larry had long ago merged the PR.
Date User Action Args
2018-03-30 08:30:19ncoghlansetstatus: open -> closed
versions: + Python 3.5
messages: + msg314683

resolution: fixed
stage: patch review -> resolved
2018-01-23 10:24:46larrysetmessages: + msg310491
2018-01-16 10:53:10ncoghlansetmessages: + msg310074
2018-01-16 10:50:58ncoghlansetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request5055
2018-01-16 09:47:05vstinnersetmessages: + msg310066
2018-01-16 05:50:40ncoghlansetmessages: + msg310038
2018-01-16 05:14:41ncoghlancreate