You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
setup.py not compiling with NDEBUG in non-debug builds #60546
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2012-10-28.15:50:27.430>created_at=<Date2012-10-28.02:32:19.911>labels= ['build']
title='setup.py not compiling with NDEBUG in non-debug builds'updated_at=<Date2012-10-28.15:50:27.428>user='https://github.com/brettcannon'
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
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?
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.
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.
Activity
brettcannon commentedon Oct 28, 2012
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
*/
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
ned-deily commentedon Oct 28, 2012
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?
brettcannon commentedon Oct 28, 2012
Just to double-check I didn't screw up, I ran
make distclean; ./configure; make -j8and 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.
brettcannon commentedon Oct 28, 2012
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.
python-dev commentedon Oct 28, 2012
New changeset a2b7a3e1ce66 by Brett Cannon in branch '3.3':
Issue bpo-16342: Lib/_sysconfigdata.py is no longer put into Lib, so
http://hg.python.org/cpython/rev/a2b7a3e1ce66
brettcannon commentedon Oct 28, 2012
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.