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

fcntl extension fails to build on AIX 6.1 #48276

Closed
drj11 mannequin opened this issue Oct 3, 2008 · 22 comments
Closed

fcntl extension fails to build on AIX 6.1 #48276

drj11 mannequin opened this issue Oct 3, 2008 · 22 comments
Labels
build The build process and cross-build

Comments

@drj11
Copy link
Mannequin

drj11 mannequin commented Oct 3, 2008

BPO 4026
Nosy @pitrou, @drj11, @haubi
Files
  • py26aix61script2
  • Python-2.6.6_flock_AIX.diff
  • Python-2.7_flock_AIX.diff
  • flock-check-py3k.patch
  • patch_Michael_Haubenwallner_flock_msg115868.diff
  • 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 2010-09-10.18:48:12.965>
    created_at = <Date 2008-10-03.08:32:41.719>
    labels = ['build']
    title = 'fcntl extension fails to build on AIX 6.1'
    updated_at = <Date 2010-09-10.18:48:12.964>
    user = 'https://github.com/drj11'

    bugs.python.org fields:

    activity = <Date 2010-09-10.18:48:12.964>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-09-10.18:48:12.965>
    closer = 'pitrou'
    components = []
    creation = <Date 2008-10-03.08:32:41.719>
    creator = 'drj'
    dependencies = []
    files = ['11688', '18709', '18766', '18787', '18830']
    hgrepos = []
    issue_num = 4026
    keywords = ['patch']
    message_count = 22.0
    messages = ['74231', '75260', '79289', '79340', '102526', '102529', '115377', '115706', '115711', '115732', '115733', '115744', '115768', '115770', '115789', '115796', '115801', '115805', '115868', '115886', '116016', '116035']
    nosy_count = 6.0
    nosy_names = ['pitrou', 'sable', 'drj', 'inkblotter', 'darkside', 'haubi']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'compile error'
    url = 'https://bugs.python.org/issue4026'
    versions = ['Python 3.1', 'Python 2.7', 'Python 3.2']

    @drj11
    Copy link
    Mannequin Author

    drj11 mannequin commented Oct 3, 2008

    After hacking the configure script to work around the issues http://bugs.python.org/issue4025 and http://bugs.python.org/issue1633863
    the build still fails:

    building 'fcntl' extension
    xlc_r -DNDEBUG -O -I. -I/home/u0006584/Python-2.6/./Include -I. -
    IInclude -I./Include -I/home/u0006584/Python-2.6/Include -
    I/home/u0006584/Python-2.6 -c /home/u0006584/Python-
    2.6/Modules/fcntlmodule.c -o build/temp.aix-6.1-
    2.6/home/u0006584/Python-2.6/Modules/fcntlmodule.o
    ./Modules/ld_so_aix xlc_r -bI:Modules/python.exp build/temp.aix-6.1-
    2.6/home/u0006584/Python-2.6/Modules/fcntlmodule.o -o build/lib.aix-6.1-
    2.6/fcntl.so
    ld: 0711-317 ERROR: Undefined symbol: .flock
    ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
    information.
    *** WARNING: renaming "fcntl" since importing it failed: 0509-022
    Cannot load module build/lib.aix-6.1-2.6.
    0509-026 System error: A file or directory in the path name does
    not exist.
    error: No such file or directory
    make: 1254-004 The error code from the last command is 1.

    (Full transcript attached)

    I'm mystified and I can't log in to the AIX box right now.

    This does not appear to be the same as http://bugs.python.org/issue1756343 and http://bugs.python.org/issue1694442 which both appear to be the same,
    but documenting a differen AIX build problem.

    @drj11 drj11 mannequin added the build The build process and cross-build label Oct 3, 2008
    @inkblotter
    Copy link
    Mannequin

    inkblotter mannequin commented Oct 27, 2008

    This occurs because it must link with -lbsd on AIX 6.1. If you hand
    link the failing module by adding -lbsd it builds quietly.

    If you build the prerequisites for the _tkinter module on AIX 6.1, you
    will also encounter an error becuase this module is not linked with the
    -lXext library. Again, you can hand link it with that library.

    Notice that the modules ignore these two libraries when they are passed
    to the python build. The modules should build against the libraries
    that are mentioned in the --with-libs=LIBS argument to python configure.

    I will eventually figure out how to modify setup.py so that these two
    failures no longer occur on AIX 6.1.

    @darkside
    Copy link
    Mannequin

    darkside mannequin commented Jan 6, 2009

    This also happens with Python 2.5.2 (not the latest 2.5 series, I know)
    on AIX 6.1.

    @darkside
    Copy link
    Mannequin

    darkside mannequin commented Jan 7, 2009

    I have now confirmed that the fix described here1 works as desired. I
    don't know if this is proper or not but it matches what inkblotter said.

    @haubi
    Copy link
    Mannequin

    haubi mannequin commented Apr 7, 2010

    This very same problem happens (with Python-2.6.2) on AIX5.3 now too, after upgrading to:
    $ oslevel -s
    5300-08-09-1013

    Unlike before (comparing with old build logs), this AIX5.3 now provides flock() in <sys/file.h> and libbsd.a[shr.o] like AIX6.1.

    Interesting enough, /usr/lib/libbsd.a contains 32bit shared objects only, so -lbsd does not help in 64bit mode (don't know if python actually supports 64bit on AIX). I don't have an AIX6.1 to check this.

    Because of this, upgrading "checking for flock" from compile- to link-check (eventually trying -lbsd a second time) might help?

    @haubi
    Copy link
    Mannequin

    haubi mannequin commented Apr 7, 2010

    Ohw, looking on another machine, being AIX5.3 TL6:
    $ oslevel -s
    5300-06-00-0000

    Here flock() is provided in libbsd.a(shr.o) (32bit only) too, but it isn't declared in any header-file. So that recent AIX5.3 patchset just adds the flock() declaration, not the function itself (is already there).

    @sable
    Copy link
    Mannequin

    sable mannequin commented Sep 2, 2010

    Hi,

    Here is a patch that solves this problem. It was tested with Python 2.6.6 on AIX 6.1.

    The same problem applies to Python 2.7 and 3.x, but since the syntax has been changed in configure.in for Python 2.7 and 3.x, I need to adapt a little bit my patch (coming soon).

    regards

    @sable
    Copy link
    Mannequin

    sable mannequin commented Sep 6, 2010

    Here is the version of the patch for Python 2.7.
    I had to change AC_TRY_COMPILE to AC_COMPILE_IFELSE and AC_TRY_LINK to AC_LINK_IFELSE.

    The syntax in configure.in is the same between Python 2.7 and the trunk. It is also the same between Python 2.6.6 and Python 3.1.2.

    So this patch can be applied on the trunk and the patch Python-2.6.6_flock_AIX.diff can be applied on Python 3.1.2.

    @haubi
    Copy link
    Mannequin

    haubi mannequin commented Sep 6, 2010

    While I've not tested these patches myself, I do think there still is an unhandled case: building a 64bit python.
    As libbsd.a contains 32bit objects only, there is no 64bit flock().
    So AC_CHECK_LIB(bsd,flock) may still fail, which should result in have_flock=no then.
    Thank you!

    @sable
    Copy link
    Mannequin

    sable mannequin commented Sep 6, 2010

    [rant: grrr, AIX is really a crappy platform; no consistency between releases; there are dozens of obvious bugs like that... anyway...]

    The fact that there is no 64 bits objects in libbsd.a on AIX 6.1 is a documented bug:
    http://www-01.ibm.com/support/docview.wss?uid=isg1IZ45155

    They recommend to install patch APAR IZ45155.

    I suppose there is nothing more we can do if the function is not available on the system. Maybe we could display a warning or error message and suggest to upgrade to a more recent patchlevel if we are on AIX and flock cannot be found?

    Though if the installation is relatively up to date, there should be no problem.

    @pitrou
    Copy link
    Member

    pitrou commented Sep 6, 2010

    Well, I suppose if flock needs libbsd on AIX (which is quite weird in itself), and AIX fails to ship libbsd for some executable formats, then it's AIX's problem.

    @haubi
    Copy link
    Mannequin

    haubi mannequin commented Sep 7, 2010

    While I do agree this being an AIX bug, it is not a blocker here:
    fcntl extension does not _depend_ on flock, it just does _prefer_ flock:
    If not available, fcntl extension uses something else (fcntl IIRC), as it did (even without linking libbsd) before the AIX5.3-patch, which just added flock to the headers (the implementation in libbsd already has been there before the patch).
    The problem after that AIX5.3-patch was that the compile-check found flock, and then fcntl extension failed to link due to missing libbsd.
    So it's just for how to detect flock, where the most safe variant is both the compile- and link-check. When one of them fails, flock should not be flagged as available and the alternative gets used.

    @sable
    Copy link
    Mannequin

    sable mannequin commented Sep 7, 2010

    Here is a new test for flock. HAVE_FLOCK is defined if we can link a C application calling flock, or if flock is defined in libbsd.
    FLOCK_NEEDS_LIBBSD is also defined in the second case.

    AC_MSG_CHECKING(for flock)
    have_flock=no
    AC_TRY_LINK([
    #include "confdefs.h" 
    #include <sys/file.h>
    ], [void* p = flock; flock(0, 0)],
      [AC_CHECK_LIB(bsd,flock, [
        AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
        have_flock=yes
        ])],
      [have_flock=yes]
    )
    if test "$have_flock" = yes ; then
      AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
    fi
    AC_MSG_RESULT($have_flock)

    I think that this new test would also cover your case with a broken AIX libbsd? [I haven't actually tried to compile it yet, if the behavior is OK I will test it in both autoconf formats and provide some new patches tomorrow]

    @pitrou
    Copy link
    Member

    pitrou commented Sep 7, 2010

    I've just merged Sébastien's patches in r84584 (3.x), r84585 (2.7) and r84586 (3.1). If you'd like to improve the fixes (as per your latest message), please say so, otherwise I'll close the issue.

    (and thanks for your contributions!)

    @haubi
    Copy link
    Mannequin

    haubi mannequin commented Sep 7, 2010

    Sorry to be pedantic - but it looks like (don't have a build environment at hand at the moment) it will fail to build as 64bit on the not-so-up-to-date AIX with missing 64bit flock implementation:
    There, the compile-check will succeed and define HAVE_FLOCK, but the link-check will fail - which really should reset have_flock to 'no'.
    IMO, HAVE_FLOCK should be defined when _both_ checks succeed only, not upon the compile-check only as it is done now.
    Thank you!

    @pitrou
    Copy link
    Member

    pitrou commented Sep 7, 2010

    Sorry to be pedantic - but it looks like (don't have a build
    environment at hand at the moment) it will fail to build as 64bit on
    the not-so-up-to-date AIX with missing 64bit flock implementation:
    There, the compile-check will succeed and define HAVE_FLOCK, but the
    link-check will fail - which really should reset have_flock to 'no'.
    IMO, HAVE_FLOCK should be defined when _both_ checks succeed only, not
    upon the compile-check only as it is done now.

    It might be better indeed. Patches against the current SVN branches are
    welcome (I don't have an AIX system to test them on, and besides I'm not
    an autoconf expert).

    @haubi
    Copy link
    Mannequin

    haubi mannequin commented Sep 7, 2010

    Using this patch based on current py3k branch I've been able now to build the fcntl module for 32bit aix5.3 (with flock) and 64bit aix5.3 (without flock), both using an old gcc-3.3.6, as well as for 64bit linux.
    If necessary, I should be able to create a similar patch for the other branches tomorrow.

    @sable
    Copy link
    Mannequin

    sable mannequin commented Sep 7, 2010

    I inverted the actions in the test I proposed in msg115768 (quick note from home, should have tested at work before posting). It should be:

    AC_MSG_CHECKING(for flock)
    have_flock=no
    AC_TRY_LINK([
    #include "confdefs.h" 
    #include <sys/file.h>
    ], [void* p = flock; flock(0, 0)],
      [have_flock=yes],
      [AC_CHECK_LIB(bsd,flock, [
        AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
        have_flock=yes
        ])]
    )
    if test "$have_flock" = yes ; then
      AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
    fi
    AC_MSG_RESULT($have_flock)

    Mickael, does that new test works for you? I am not sure I follow your explanation: there is no more 'compile-check' (AC_TRY_COMPILE) in the new test I provided; just a 'link-check' (AC_TRY_LINK - which tests that compilation and link did work).
    HAVE_FLOCK is undefined by default.
    If the link-check succeeds, then HAVE_FLOCK is defined.
    If it fails, then we try to look for flock in libbsd; if that test works, then HAVE_FLOCK is defined as well as FLOCK_NEEDS_LIBBSD.

    In the case of broken AIX 64 bits, the link-check will fail (no flock in default C libraries); then the test to find flock in libbsd will also fail (no 64 bits objets in libbsd). So HAVE_FLOCK will be undefined, which is what you expect.

    m4/autoconf is quite unintuitive so I may have made a mistake, or it may be easily misunderstood. But I intend my test to define HAVE_FLOCK only if compilation _and_ linking works, like you expect.

    @haubi
    Copy link
    Mannequin

    haubi mannequin commented Sep 8, 2010

    Sébastien, while this gives expected results on the AIX box here, it still has one subtle problem:
    AC_TRY_LINK may fail due to missing declaration in <sys/file.h> _or_ due to missing implementation in libc.
    The subsequent AC_CHECK_LIB won't fail when the implementation is in libbsd but the declaration is missing - this is the case on not-so-recent AIX5.3 (and the reason python worked there before).

    Another minor nit is configure's output when libbsd is needed:

    checking for flock... checking for flock in -lbsd... yes
    yes

    Anyway - I've hacked up another variant (with recent autoconf manual at hand), which really should cover all known situations now (additionally using cache-checks):

    AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
    [AC_COMPILE_IFELSE(
    [AC_LANG_PROGRAM(
    [#include <sys/file.h>],
    [void* p = flock]
    )],
    [ac_cv_flock_decl=yes],
    [ac_cv_flock_decl=no]
    )
    ])
    if test "x${ac_cv_flock_decl}" = xyes; then
    AC_CHECK_FUNCS(flock,,
    AC_CHECK_LIB(bsd,flock,
    [AC_DEFINE(HAVE_FLOCK)
    AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
    ])
    )
    fi

    Thank you anyway!

    @sable
    Copy link
    Mannequin

    sable mannequin commented Sep 8, 2010

    Thanks Michael, your new test looks fine to me.

    I wanted to test it on my AIX system with branch py3k but I had some other issues (bpo-9799), but I will test it tomorrow.

    @sable
    Copy link
    Mannequin

    sable mannequin commented Sep 10, 2010

    I tested Michael test in msg115868 on my AIX system (AIX 6.1 with flock correctly present in libbsd) with py3k and it works fine:

    checking for flock declaration... yes
    checking for flock... no
    checking for flock in -lbsd... yes

    [103/344] test_fcntl
    = OK

    I attach it as a patch against py3k.

    @pitrou
    Copy link
    Member

    pitrou commented Sep 10, 2010

    Ok, thank you. The improvement has been committed in all three branches (3.2, 3.1, 2.7).

    @pitrou pitrou closed this as completed Sep 10, 2010
    @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
    build The build process and cross-build
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant