Skip to content

setup.py not compiling with NDEBUG in non-debug builds #60546

Closed

Description

@brettcannon
BPO 16342
Nosy @brettcannon, @ned-deily, @merwok

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 = None
closed_at = <Date 2012-10-28.15:50:27.430>
created_at = <Date 2012-10-28.02:32:19.911>
labels = ['build']
title = 'setup.py not compiling with NDEBUG in non-debug builds'
updated_at = <Date 2012-10-28.15:50:27.428>
user = 'https://github.com/brettcannon'

bugs.python.org fields:

activity = <Date 2012-10-28.15:50:27.428>
actor = 'brett.cannon'
assignee = 'none'
closed = True
closed_date = <Date 2012-10-28.15:50:27.430>
closer = 'brett.cannon'
components = ['Build']
creation = <Date 2012-10-28.02:32:19.911>
creator = 'brett.cannon'
dependencies = []
files = []
hgrepos = []
issue_num = 16342
keywords = ['3.3regression']
message_count = 6.0
messages = ['173992', '173993', '174051', '174052', '174053', '174054']
nosy_count = 4.0
nosy_names = ['brett.cannon', 'ned.deily', 'eric.araujo', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'needs patch'
status = 'closed'
superseder = None
type = 'compile error'
url = 'https://bugs.python.org/issue16342'
versions = ['Python 3.3', 'Python 3.4']

Activity

  1. brettcannon commented on Oct 28, 2012

    @brettcannon
    MemberAuthor

    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

  2. ned-deily commented on Oct 28, 2012

    @ned-deily
    Member

    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?

  3. brettcannon commented on Oct 28, 2012

    @brettcannon
    MemberAuthor

    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.

  4. brettcannon commented on Oct 28, 2012

    @brettcannon
    MemberAuthor

    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.

  5. python-dev commented on Oct 28, 2012

    python-devmannequin
    Mannequin

    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

  6. brettcannon commented on Oct 28, 2012

    @brettcannon
    MemberAuthor

    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.

  7. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildThe build process and cross-build

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions