classification
Title: setup.py not compiling with NDEBUG in non-debug builds
Type: compile error Stage: needs patch
Components: Build Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, eric.araujo, ned.deily, python-dev
Priority: normal Keywords: 3.3regression

Created on 2012-10-28 02:32 by brett.cannon, last changed 2012-10-28 15:50 by brett.cannon. This issue is now closed.

Messages (6)
msg173992 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-10-28 02:32
Discovered on OS X 10.8 with clang 3.1, I'm having build failures for _json, _md5, _sha1, _sha256, _sha3, and _sha512 because _PyUnicode_CheckConsistency() is only defined when defined(Py_DEBUG) && !defined(Py_LIMITED_API) even though it is only used in assert() calls (like the one below). If you read the comment in Include/Python.h where assert.h is included it explicitly says that:

/* CAUTION:  Build setups should ensure that NDEBUG is defined on the
 * compiler command line when building Python in release mode; else
 * assert() calls won't be removed.
 */

Based on the output below that is not currently happening in setup.py. Not sure if that is a failure of setup.py or distutils of not specifying the flag.



building '_json' extension
/Users/bcannon/Developer/bin/clang -Wno-unused-result -g -O0 -Wall -Wstrict-prototypes -Wno-unused-value -Wno-empty-body -Qunused-arguments -Wno-unused-value -Wno-empty-body -Qunused-arguments -I./Include -I. -I/Users/bcannon/Developer/include -I/Users/bcannon/Developer/Cellar/readline/6.2.2/include -I/Users/bcannon/Developer/repo/cpython/py3.3/Include -I/Users/bcannon/Developer/repo/cpython/py3.3 -c /Users/bcannon/Developer/repo/cpython/py3.3/Modules/_json.c -o build/temp.macosx-10.8-x86_64-3.3/Users/bcannon/Developer/repo/cpython/py3.3/Modules/_json.o
/Users/bcannon/Developer/repo/cpython/py3.3/Modules/_json.c:249:12: warning: implicit declaration of function
      '_PyUnicode_CheckConsistency' is invalid in C99 [-Wimplicit-function-declaration]
    assert(_PyUnicode_CheckConsistency(rval, 1));
           ^
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
1 warning generated.
/Users/bcannon/Developer/bin/clang -bundle -undefined dynamic_lookup -L /Users/bcannon/Developer/lib -L/Users/bcannon/Developer/Cellar/readline/6.2.2/lib -L /Users/bcannon/Developer/lib -L/Users/bcannon/Developer/Cellar/readline/6.2.2/lib -L /Users/bcannon/Developer/lib -L/Users/bcannon/Developer/Cellar/readline/6.2.2/lib -Wno-unused-value -Wno-empty-body -Qunused-arguments -I /Users/bcannon/Developer/include -I/Users/bcannon/Developer/Cellar/readline/6.2.2/include build/temp.macosx-10.8-x86_64-3.3/Users/bcannon/Developer/repo/cpython/py3.3/Modules/_json.o -L/Users/bcannon/Developer/lib -L/Users/bcannon/Developer/Cellar/readline/6.2.2/lib -o build/lib.macosx-10.8-x86_64-3.3/_json.so
*** WARNING: renaming "_json" since importing it failed: dlopen(build/lib.macosx-10.8-x86_64-3.3/_json.so, 2): Symbol not found: __PyUnicode_CheckConsistency
  Referenced from: build/lib.macosx-10.8-x86_64-3.3/_json.so
  Expected in: flat namespace
 in build/lib.macosx-10.8-x86_64-3.3/_json.so
msg173993 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-10-28 02:54
I can't reproduce this on 10.8 with Apple clang 4.1.  Your compile options look a little funky, including a missing -fwrapv.  It looks like that option and -DNDEBUG are normally passed from ./configure into the Makefile through the OPT variable.  Are you by any chance overriding $OPT?
msg174051 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-10-28 14:51
Just to double-check I didn't screw up, I ran ``make distclean; ./configure; make -j8`` and the problem persists.

It is *only* files compiled through setup.py and not by the Makefile. I do not have OPT set, but I do have CFLAGS defined. But even if I explicitly unset CFLAGS, OPT,CPPFLAGS, LDFLAGS, and use a different shell the problem persists.



Something compiled by the Makefile:

/Users/bcannon/Developer/bin/clang -c -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes     -I. -IInclude -I./Include -I /Users/bcannon/Developer/include -I/Users/bcannon/Developer/Cellar/readline/6.2.2/include -I /Users/bcannon/Developer/include -I/Users/bcannon/Developer/Cellar/readline/6.2.2/include  -DPy_BUILD_CORE -o Python/frozen.o Python/frozen.c



Something compiled by setup.py:

/Users/bcannon/Developer/bin/clang -Wno-unused-result -g -O0 -Wall -Wstrict-prototypes -Wno-unused-value -Wno-empty-body -Qunused-arguments -Wno-unused-value -Wno-empty-body -Qunused-arguments -I./Include -I. -I/Users/bcannon/Developer/include -I/Users/bcannon/Developer/Cellar/readline/6.2.2/include -I/Users/bcannon/Developer/repo/cpython/py3.3/Include -I/Users/bcannon/Developer/repo/cpython/py3.3 -c /Users/bcannon/Developer/repo/cpython/py3.3/Modules/sha512module.c -o build/temp.macosx-10.8-x86_64-3.3/Users/bcannon/Developer/repo/cpython/py3.3/Modules/sha512module.o
/Users/bcannon/Developer/repo/cpython/py3.3/Modules/sha512module.c:535:12: warning: implicit declaration of function '_PyUnicode_CheckConsistency' is invalid in C99 [-Wimplicit-function-declaration]
    assert(_PyUnicode_CheckConsistency(retval, 1));
           ^
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
1 warning generated.
msg174052 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-10-28 15:21
I managed to fix it, but I did such a large swath of fixes that I need a little time to narrow down what did it. Report back later.
msg174053 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-10-28 15:49
New changeset a2b7a3e1ce66 by Brett Cannon in branch '3.3':
Issue #16342: Lib/_sysconfigdata.py is no longer put into Lib, so
http://hg.python.org/cpython/rev/a2b7a3e1ce66
msg174054 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-10-28 15:50
Well that was extremely frustrating to find out. Turns out a copy of Lib/_sysconfigdata.py was lingering in my checkout and .hgignore was hiding that fact from me. Fixed .hgignore, deleted the wayward file, and everything is now fine.
History
Date User Action Args
2012-10-28 15:50:27brett.cannonsetstatus: open -> closed
resolution: fixed
messages: + msg174054
2012-10-28 15:49:12python-devsetnosy: + python-dev
messages: + msg174053
2012-10-28 15:21:06brett.cannonsetmessages: + msg174052
2012-10-28 14:51:45brett.cannonsetmessages: + msg174051
2012-10-28 02:54:33ned.deilysetnosy: + ned.deily
messages: + msg173993
2012-10-28 02:32:19brett.cannoncreate