Skip to content

Cannot build CPython3.6 with module “testcapimodule” statically #74552

Description

@Nan-Zhang
mannequin
BPO 30367
Nosy @vstinner, @pganssle, @Nan-Zhang
PRs
  • bpo-30367: fix _testcapi to work when statically linked into Cpython3 #1658
  • 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 2019-09-17.20:46:01.204>
    created_at = <Date 2017-05-15.02:55:39.506>
    labels = ['build', '3.8', '3.9']
    title = 'Cannot build CPython3.6 with module \xe2\x80\x9ctestcapimodule\xe2\x80\x9d statically'
    updated_at = <Date 2019-09-17.20:46:01.193>
    user = 'https://github.com/Nan-Zhang'

    bugs.python.org fields:

    activity = <Date 2019-09-17.20:46:01.193>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-09-17.20:46:01.204>
    closer = 'vstinner'
    components = ['Build']
    creation = <Date 2017-05-15.02:55:39.506>
    creator = 'Nan Zhang'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30367
    keywords = []
    message_count = 3.0
    messages = ['293664', '352638', '352662']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'p-ganssle', 'Nan Zhang']
    pr_nums = ['1658']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'compile error'
    url = 'https://bugs.python.org/issue30367'
    versions = ['Python 3.8', 'Python 3.9']

    Activity

    1. Nan-Zhang commented on May 15, 2017

      Nan-Zhangmannequin
      MannequinAuthor

      up vote
      0
      down vote
      favorite
      I am trying to build CPython3.6 from GitHub statically with the Documentation below:

      https://wiki.python.org/moin/BuildStatically

      Changed *shared* to *static*

      And only uncommented the module "testcapimodule" in Modules/Setup file:

      _testcapi _testcapimodule.c # Python C API test module

      And ran with 'make LINKFORSHARED=" "'

      However I got errors that:

          gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers   -I. -I./Include    -DPy_BUILD_CORE  -c ./Modules/_testcapimodule.c -o Modules/_testcapimodule.o
      ./Modules/_testcapimodule.c: In function ‘test_datetime_capi’:
              ./Modules/_testcapimodule.c:2191:9: error: ‘PyDateTimeAPI’ undeclared (first use in this function)
                   if (PyDateTimeAPI) {
                       ^
              ./Modules/_testcapimodule.c:2191:9: note: each undeclared identifier is reported only once for each function it appears in
              ./Modules/_testcapimodule.c:2203:5: error: ‘PyDateTime_IMPORT’ undeclared (first use in this function)
                   PyDateTime_IMPORT;
                   ^
              ./Modules/_testcapimodule.c:2208:1: warning: control reaches end of non-void function [-Wreturn-type]
               }
               ^
              make: *** [Modules/_testcapimodule.o] Error 1

      But when I build Cpython3.6 with *shared*, it can succeed.

    2. pganssle commented on Sep 17, 2019

      @pganssle
      Member

      Is this issue only in Python 3.6? I believe Python 3.6 is only receiving security fixes at the moment, so this could only be fixed in 3.7, 3.8 and 3.9.

    3. vstinner commented on Sep 17, 2019

      @vstinner
      Member

      It seems like this issue has been fixed in 3.8 and master branches (I didn't test Python 3.7): see below.

      I close the issue. Reopen/comment the issue if you consider that Python 3.7 should be fixed as well.

      I made this change:

      $ git diff
      diff --git a/Modules/Setup b/Modules/Setup
      index 983fa014ec..ff2fd14857 100644
      --- a/Modules/Setup
      +++ b/Modules/Setup
      @@ -151,6 +151,10 @@ _symtable symtablemodule.c
       # modules are to be built as shared libraries (see above for more
       # detail; also note that *static* or *disabled* cancels this effect):
       
      +*static*
      +
      +_datetime _datetimemodule.c    # datetime accelerator
      +
       #*shared*
       
       # GNU readline.  Unlike previous Python incarnations, GNU readline is
      @@ -177,7 +181,6 @@ _symtable symtablemodule.c
       #_random _randommodule.c       # Random number generator
       #_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c        # elementtree accelerator
       #_pickle _pickle.c     # pickle accelerator
      -#_datetime _datetimemodule.c   # datetime accelerator
       #_bisect _bisectmodule.c       # Bisection algorithms
       #_heapq _heapqmodule.c # Heap queue algorithm
       #_asyncio _asynciomodule.c  # Fast asyncio Future

      I built Python: it works as expected, _datetime is a built-in module:

      $ ./python
      Python 3.9.0a0 (heads/master-dirty:46b0b81220, Sep 17 2019, 22:42:19) 
      [GCC 9.2.1 20190827 (Red Hat 9.2.1-1)] on linux
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import _datetime
      >>> _datetime
      <module '_datetime' (built-in)>

      Note:

      $ make
      ...
      The following modules found by detect_modules() in setup.py, have been
      built by the Makefile instead, as configured by the Setup files:
      _abc                  _datetime             atexit             
      pwd                   time                                     
      ...
    4. 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

      3.8 (EOL)end of life3.9 (EOL)end of lifebuildThe build process and cross-build

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions