Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On macOS Sierra, warning: implicit declaration of function 'getentropy' #72862

Closed
gareth-rees mannequin opened this issue Nov 12, 2016 · 3 comments
Closed

On macOS Sierra, warning: implicit declaration of function 'getentropy' #72862

gareth-rees mannequin opened this issue Nov 12, 2016 · 3 comments
Labels
3.7 only security fixes build The build process and cross-build OS-mac

Comments

@gareth-rees
Copy link
Mannequin

gareth-rees mannequin commented Nov 12, 2016

BPO 28676
Nosy @ronaldoussoren, @ned-deily, @gareth-rees
PRs
  • [Do Not Merge] Convert Misc/NEWS so that it is managed by towncrier #552
  • Files
  • getentropy.patch
  • 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 2016-11-12.21:43:39.843>
    created_at = <Date 2016-11-12.19:30:20.896>
    labels = ['OS-mac', 'build', '3.7']
    title = "On macOS Sierra, warning: implicit declaration of function 'getentropy'"
    updated_at = <Date 2017-03-31.16:36:38.720>
    user = 'https://github.com/gareth-rees'

    bugs.python.org fields:

    activity = <Date 2017-03-31.16:36:38.720>
    actor = 'dstufft'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-11-12.21:43:39.843>
    closer = 'ned.deily'
    components = ['Build', 'macOS']
    creation = <Date 2016-11-12.19:30:20.896>
    creator = 'gdr@garethrees.org'
    dependencies = []
    files = ['45465']
    hgrepos = []
    issue_num = 28676
    keywords = ['patch']
    message_count = 3.0
    messages = ['280669', '280672', '280674']
    nosy_count = 4.0
    nosy_names = ['ronaldoussoren', 'ned.deily', 'python-dev', 'gdr@garethrees.org']
    pr_nums = ['552']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'compile error'
    url = 'https://bugs.python.org/issue28676'
    versions = ['Python 2.7', 'Python 3.5', 'Python 3.6', 'Python 3.7']

    @gareth-rees
    Copy link
    Mannequin Author

    gareth-rees mannequin commented Nov 12, 2016

    On macOS Sierra (OSX 10.12.1):

        $ ./configure --with-pydebug && make
        [... lots of output omitted ...]
        gcc -c -Wno-unused-result -Wsign-compare -g -O0 -Wall -Wstrict-prototypes    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers   -I. -I./Include    -DPy_BUILD_CORE -o Python/random.o Python/random.c
        Python/random.c:97:19: warning: implicit declaration of function 'getentropy' is
              invalid in C99 [-Wimplicit-function-declaration]
                    res = getentropy(buffer, len);
                          ^
        1 warning generated.

    This is because OSX 10.12.1 has getentropy() but does not have
    getrandom(). You can see this in pyconfig.h:

        /* Define to 1 if you have the `getentropy' function. */
        #define HAVE_GETENTROPY 1
    /* Define to 1 if the getrandom() function is available */
    /* #undef HAVE_GETRANDOM */
    

    and this means that in Python/random.c the header <sys/random.h> is
    not included:

    #  ifdef HAVE_GETRANDOM
    #    include <sys/random.h>
    #  elif defined(HAVE_GETRANDOM_SYSCALL)
    #    include <sys/syscall.h>
    #  endif
    

    It's necessary include <sys/random.h> if either HAVE_GETRANDOM or
    HAVE_GETENTROPY is defined.

    @gareth-rees gareth-rees mannequin added 3.7 only security fixes build The build process and cross-build OS-mac labels Nov 12, 2016
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 12, 2016

    New changeset 828251c2bccf by Ned Deily in branch '2.7':
    Issue bpo-28676: Prevent missing 'getentropy' declaration warning on macOS.
    https://hg.python.org/cpython/rev/828251c2bccf

    New changeset 0efd48d4c47c by Ned Deily in branch '3.5':
    Issue bpo-28676: Prevent missing 'getentropy' declaration warning on macOS.
    https://hg.python.org/cpython/rev/0efd48d4c47c

    New changeset e2faa8a22b69 by Ned Deily in branch '3.6':
    Issue bpo-28676: merge from 3.5
    https://hg.python.org/cpython/rev/e2faa8a22b69

    New changeset b31a7efd8b31 by Ned Deily in branch 'default':
    Issue bpo-28676: merge from 3.6
    https://hg.python.org/cpython/rev/b31a7efd8b31

    @ned-deily
    Copy link
    Member

    Thanks for the patch, Gareth! Pushed for release in 2.7.13, 3.5.3, 3.6.0b4, and 3.7.0.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 only security fixes build The build process and cross-build OS-mac
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant