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

request to reopen Issue837046 - pyport.h redeclares gethostname() if SOLARIS is defined #63760

Closed
risto3 mannequin opened this issue Nov 12, 2013 · 11 comments
Closed

request to reopen Issue837046 - pyport.h redeclares gethostname() if SOLARIS is defined #63760

risto3 mannequin opened this issue Nov 12, 2013 · 11 comments
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes build The build process and cross-build

Comments

@risto3
Copy link
Mannequin

risto3 mannequin commented Nov 12, 2013

BPO 19561
Nosy @jcea, @bitdancer, @0-wiz-0, @kulikjak
PRs
  • bpo-19561: Remove unnecessary gethostname() prototype for Solaris #23208
  • Files
  • Python26-10-gethostname.patch
  • tp.cpp: test program
  • 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 = None
    created_at = <Date 2013-11-12.14:39:41.350>
    labels = ['build', '3.8', '3.9', '3.10']
    title = 'request to reopen Issue837046 - pyport.h redeclares gethostname() if SOLARIS is defined'
    updated_at = <Date 2020-12-22.16:36:14.544>
    user = 'https://bugs.python.org/risto3'

    bugs.python.org fields:

    activity = <Date 2020-12-22.16:36:14.544>
    actor = 'kulikjak'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Build']
    creation = <Date 2013-11-12.14:39:41.350>
    creator = 'risto3'
    dependencies = []
    files = ['32584', '32592']
    hgrepos = []
    issue_num = 19561
    keywords = ['patch']
    message_count = 8.0
    messages = ['202690', '202715', '202718', '202723', '202730', '240296', '380584', '380585']
    nosy_count = 7.0
    nosy_names = ['jcea', 'r.david.murray', 'wiz', 'python-dev', 'risto3', 'jbeck', 'kulikjak']
    pr_nums = ['23208']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'compile error'
    url = 'https://bugs.python.org/issue19561'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    Linked PRs

    @risto3
    Copy link
    Mannequin Author

    risto3 mannequin commented Nov 12, 2013

    I'd like to have reopened this previous issue as it is still very much the case.

    I believe as well that the common distros (I can easily verify OpenIndiana and OmniOS) patch it out (patch file attached).
    Upstream/oracle/userland-gate seems to as well.

    It is time to retire this check, or at least take into consideration the parametrization from unistd.h:

    #if defined(_XPG4_2)
    extern int gethostname(char *, size_t);
    #elif  !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
    extern int gethostname(char *, int);
    #endif

    @risto3 risto3 mannequin added build The build process and cross-build labels Nov 12, 2013
    @bitdancer
    Copy link
    Member

    We have an OpenIndian buildbot that compiles from our source, so no distro changes. Can you sort out why this isn't a problem on the buildbut but is for you? Your patch files says 2.6, so is it possible it is fixed in 2.7?

    @risto3
    Copy link
    Mannequin Author

    risto3 mannequin commented Nov 12, 2013

    I don't believe the problem is a question solely of building the python sources, but also certain dependent application sources...

    I know of at least libreoffice building against python and this problem has come up.

    The workaround was to apply the patch indicated (here, on python3.3).

    @bitdancer
    Copy link
    Member

    Libreoffice is a big thing to compile as a test...do you know of any smaller packages that exhibit the bug?

    I've added jcea to nosy, he set up the OpenIndiana buildbots and may be able to help clarify the issue. I'm not willing to opine on it since I don't know what effect modifying those directives might have on other platforms.

    @bitdancer bitdancer assigned jcea and unassigned jcea Nov 12, 2013
    @risto3
    Copy link
    Mannequin Author

    risto3 mannequin commented Nov 13, 2013

    Sure, attached is a simple test found on the internet, compiled with the following reproduces the problem:

    richard@devzone:~/src$ /opt/local/gcc48/bin/g++ -o tp tp.cpp -DSOLARIS -I/opt/local/include/python2.7 -L/opt/local/lib -lpython2.7
    In file included from /opt/local/include/python2.7/Python.h:58:0,
    from tp.cpp:1:
    /opt/local/include/python2.7/pyport.h:645:35: error: declaration of C function 'int gethostname(char*, int)' conflicts with
    extern int gethostname(char *, int);
    ^
    In file included from /opt/local/include/python2.7/Python.h:44:0,
    from tp.cpp:1:
    /usr/include/unistd.h:351:12: error: previous declaration 'int gethostname(char*, uint_t)' here
    extern int gethostname(char *, size_t);

    @jbeck
    Copy link
    Mannequin

    jbeck mannequin commented Apr 9, 2015

    We (Solaris engineering) have hit this issue after migrating from 2.6
    being our default version of Python to 2.7 being the default. The
    specific component that broke was vim (version 7.4), trying to compile
    if_python.c:

    "/usr/include/python2.7/pyport.h", line 645: identifier redeclared:
    gethostname
    current : function(pointer to char, int) returning int
    previous: function(pointer to char, unsigned long) returning int :
    "/usr/include/unistd.h", line 412

    We had this patched out in Python 2.6's Include/pyport.h:

    -#ifdef SOLARIS
    -/* Unchecked */
    -extern int gethostname(char *, int);
    -#endif

    but for some reason that patch was not propagated to our 2.7 line.
    Until today, that is; I will be applying that patch shortly to both
    2.7 and 3.4.

    @kulikjak
    Copy link
    Mannequin

    kulikjak mannequin commented Nov 9, 2020

    I think this code should be removed.

    It was added in its current form more than 20 years ago with the intention to add function declarations missing from system include files:
    1e0c2f4

    Today, every Solaris system should have gethostname() available in unistd.h. I am not sure when exactly was it added, but it was available in the OpenSolaris since the first commit (year 2005):
    https://github.com/illumos/illumos-gate/blame/master/usr/src/head/unistd.h#L344

    Also, AFAIK, 'SOLARIS' macro is not predefined on Solaris systems in compiler preprocessors today *; hence, unless compiled with -DSOLARIS, this code has no effect.

    *) I tested this with several GCC [7|9|10] and Solaris studio and neither of those defined it. It seems like it might have worked many years ago, but it certainly isn't a way to #ifdef Solaris today.

    @kulikjak kulikjak mannequin added 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes labels Dec 22, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @vstinner
    Copy link
    Member

    vstinner commented Sep 2, 2023

    @kulikjak proposed at PR: #23208

    vstinner added a commit to vstinner/cpython that referenced this issue Sep 2, 2023
    vstinner added a commit to vstinner/cpython that referenced this issue Sep 2, 2023
    vstinner added a commit to vstinner/cpython that referenced this issue Sep 2, 2023
    Since at least 2013, Oracle Solaris defines gethostname().
    socketmodule.c no longer has to define gethostname() for Solaris.
    
    Oracle Solaris and OpenSolaris have patches to remove the
    gethostname() definition in Python:
    
    * https://github.com/oracle/solaris-userland/blob/master/components/python/python37/patches/15-gethostname.patch
    * https://github.com/OpenIndiana/oi-userland/blob/oi/hipster/components/python/python37/patches/15-gethostname.patch
    * https://github.com/omniosorg/omnios-build/blob/master/build/python27/patches/24-gethostname.patch
    
    Co-Authored-by: Jakub Kulík <Kulikjak@gmail.com>
    vstinner added a commit to vstinner/cpython that referenced this issue Sep 2, 2023
    Since 2005, Solaris defines gethostname(). socketmodule.c no longer
    has to define gethostname() for Solaris.
    
    Oracle Solaris and OpenSolaris have patches to remove the
    gethostname() definition in Python:
    
    * https://github.com/oracle/solaris-userland/blob/master/components/python/python37/patches/15-gethostname.patch
    * https://github.com/OpenIndiana/oi-userland/blob/oi/hipster/components/python/python37/patches/15-gethostname.patch
    * https://github.com/omniosorg/omnios-build/blob/master/build/python27/patches/24-gethostname.patch
    
    Co-Authored-by: Jakub Kulík <Kulikjak@gmail.com>
    vstinner added a commit that referenced this issue Sep 2, 2023
    Since 2005, Solaris defines gethostname(). socketmodule.c no longer
    has to define gethostname() for Solaris.
    
    Oracle Solaris and OpenSolaris have patches to remove the
    gethostname() definition in Python:
    
    * https://github.com/oracle/solaris-userland/blob/master/components/python/python37/patches/15-gethostname.patch
    * https://github.com/OpenIndiana/oi-userland/blob/oi/hipster/components/python/python37/patches/15-gethostname.patch
    * https://github.com/omniosorg/omnios-build/blob/master/build/python27/patches/24-gethostname.patch
    
    Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
    vstinner added a commit to vstinner/cpython that referenced this issue Sep 2, 2023
    Since 2005, Solaris defines gethostname(). socketmodule.c no longer
    has to define gethostname() for Solaris.
    
    Oracle Solaris and OpenSolaris have patches to remove the
    gethostname() definition in Python:
    
    * https://github.com/oracle/solaris-userland/blob/master/components/python/python37/patches/15-gethostname.patch
    * https://github.com/OpenIndiana/oi-userland/blob/oi/hipster/components/python/python37/patches/15-gethostname.patch
    * https://github.com/omniosorg/omnios-build/blob/master/build/python27/patches/24-gethostname.patch
    
    Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
    (cherry picked from commit 0e6d582)
    Yhg1s pushed a commit that referenced this issue Sep 2, 2023
    …08824)
    
    gh-63760: Don't declare gethostname() on Solaris (#108817)
    
    Since 2005, Solaris defines gethostname(). socketmodule.c no longer
    has to define gethostname() for Solaris.
    
    Oracle Solaris and OpenSolaris have patches to remove the
    gethostname() definition in Python:
    
    * https://github.com/oracle/solaris-userland/blob/master/components/python/python37/patches/15-gethostname.patch
    * https://github.com/OpenIndiana/oi-userland/blob/oi/hipster/components/python/python37/patches/15-gethostname.patch
    * https://github.com/omniosorg/omnios-build/blob/master/build/python27/patches/24-gethostname.patch
    
    Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
    (cherry picked from commit 0e6d582)
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 2, 2023
    …GH-108817) (pythonGH-108824)
    
    pythongh-63760: Don't declare gethostname() on Solaris (pythonGH-108817)
    
    Since 2005, Solaris defines gethostname(). socketmodule.c no longer
    has to define gethostname() for Solaris.
    
    Oracle Solaris and OpenSolaris have patches to remove the
    gethostname() definition in Python:
    
    * https://github.com/oracle/solaris-userland/blob/master/components/python/python37/patches/15-gethostname.patch
    * https://github.com/OpenIndiana/oi-userland/blob/oi/hipster/components/python/python37/patches/15-gethostname.patch
    * https://github.com/omniosorg/omnios-build/blob/master/build/python27/patches/24-gethostname.patch
    
    (cherry picked from commit 7269916)
    
    Co-authored-by: Victor Stinner <vstinner@python.org>
    Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
    (cherry picked from commit 0e6d582)
    vstinner added a commit that referenced this issue Sep 3, 2023
    …8817) (GH-108824) (#108832)
    
    [3.12] gh-63760: Don't declare gethostname() on Solaris (GH-108817) (GH-108824)
    
    gh-63760: Don't declare gethostname() on Solaris (GH-108817)
    
    Since 2005, Solaris defines gethostname(). socketmodule.c no longer
    has to define gethostname() for Solaris.
    
    Oracle Solaris and OpenSolaris have patches to remove the
    gethostname() definition in Python:
    
    * https://github.com/oracle/solaris-userland/blob/master/components/python/python37/patches/15-gethostname.patch
    * https://github.com/OpenIndiana/oi-userland/blob/oi/hipster/components/python/python37/patches/15-gethostname.patch
    * https://github.com/omniosorg/omnios-build/blob/master/build/python27/patches/24-gethostname.patch
    
    (cherry picked from commit 7269916)
    
    Co-authored-by: Victor Stinner <vstinner@python.org>
    Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
    (cherry picked from commit 0e6d582)
    
    Co-authored-by: Victor Stinner <vstinner@python.org>
    @vstinner
    Copy link
    Member

    vstinner commented Sep 3, 2023

    Thanks for the fix @kulikjak, it's now merged in the 3 maintained branches.

    @vstinner vstinner closed this as completed Sep 3, 2023
    @vstinner
    Copy link
    Member

    vstinner commented Sep 7, 2023

    See also issue #78469: Declare sethostname in socketmodule.c for SOLARIS.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes 3.10 only security fixes build The build process and cross-build
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants