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

Enable darwin-host cross compilation. Tested with build=linux, host=darwin #60495

Open
mingwandroid mannequin opened this issue Oct 20, 2012 · 6 comments
Open

Enable darwin-host cross compilation. Tested with build=linux, host=darwin #60495

mingwandroid mannequin opened this issue Oct 20, 2012 · 6 comments
Labels
build The build process and cross-build type-feature A feature request or enhancement

Comments

@mingwandroid
Copy link
Mannequin

mingwandroid mannequin commented Oct 20, 2012

BPO 16291
Nosy @doko42, @jcea, @ronaldoussoren, @ned-deily, @mingwandroid
Files
  • 0010-cross-darwin-feature.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 = None
    created_at = <Date 2012-10-20.22:09:37.693>
    labels = ['type-feature', 'build']
    title = 'Enable darwin-host cross compilation. Tested with build=linux, host=darwin'
    updated_at = <Date 2012-10-22.12:00:55.702>
    user = 'https://github.com/mingwandroid'

    bugs.python.org fields:

    activity = <Date 2012-10-22.12:00:55.702>
    actor = 'jcea'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Cross-Build']
    creation = <Date 2012-10-20.22:09:37.693>
    creator = 'Ray.Donnelly'
    dependencies = []
    files = ['27647']
    hgrepos = []
    issue_num = 16291
    keywords = ['patch']
    message_count = 6.0
    messages = ['173420', '173422', '173424', '173444', '173499', '173504']
    nosy_count = 5.0
    nosy_names = ['doko', 'jcea', 'ronaldoussoren', 'ned.deily', 'Ray.Donnelly']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue16291'
    versions = ['Python 3.4']

    @mingwandroid
    Copy link
    Mannequin Author

    mingwandroid mannequin commented Oct 20, 2012

    I've fixed up the very few missing configure bits and one issue with PYTHON_FOR_BUILD using srcdir instead of builddir. I also rolled in a simple warning fix that I ran into (the #ifdef HAVE_CHROOT added to posixmodule.c)

    configured with:
    $srcdir/configure --prefix=$PWD/install/darwin-x86_64/python-3.4.x --build=x86_64-linux-gnu --host=x86_64-apple-darwin11

    using these compilers:
    http://mingw-and-ndk.googlecode.com/files/multiarch-darwin11-cctools127.2-gcc42-5666.3-llvmgcc42-2336.1-Linux-120724.tar.xz

    and MacOSX10.7.sdk,

    I can successfully build Python for Mac OS X on Linux.

    @mingwandroid mingwandroid mannequin added build The build process and cross-build type-feature A feature request or enhancement labels Oct 20, 2012
    @ned-deily
    Copy link
    Member

    I'm curious as to what value there would be in adding support for cross building an OS X variant of Python on Linux. It seems to me that such an animal would be fragile and incomplete at best. For example, normal Python builds on OS X normally require certain OS X frameworks outside of those included with the compiler. It's difficult enough to support native builds on a wide range of OS X releases and hardware configurations. Why would we want to officially support this particular variant of cross building on another platform?

    @mingwandroid
    Copy link
    Mannequin Author

    mingwandroid mannequin commented Oct 20, 2012

    It seems to me that such an animal would be fragile and incomplete at best.

    There's no reason for it to be either fragile or incomplete. My cross builds have a goal of being comprehensive.

    Python builds on OS X normally require certain OS X frameworks outside of those included with the compiler.

    If the user supplies the Apple Mac OS X SDK then the frameworks are correctly detected and used. To enable this, I use a set of wrapper scripts to enable this, here's the contents of x86_64-apple-darwin11-gcc:

    #!/bin/sh
    # Auto-generated, do not edit
    /home/ray/darwin-cross/apple-osx/bin/i686-apple-darwin11-gcc -isysroot /home/ray/darwin-cross/MacOSX10.7.sdk -mmacosx-version-min=10.5 -DMAXOSX_DEPLOYEMENT_TARGET=10.5 -m64 "$@"

    Why would we want to officially support this particular variant of cross building on another platform?

    There's 3 separate issues merged into this patch, general cross compilation fixes, the new darwin cross compilation feature and a few darwin warning fixes (that apply equally to cross and native). I shouldn't have done that, and am in the process of splitting this issue up so that each part can be judged in isolation. Please see the new issue I've made for the general cross compilation issues: http://bugs.python.org/issue16292
    ..later I'll work on a new patch for this issue.

    @mingwandroid
    Copy link
    Mannequin Author

    mingwandroid mannequin commented Oct 21, 2012

    Here's the darwin cross enabling portion. I've also removed the warnings fixes from it as they're not relevant.

    @mingwandroid mingwandroid mannequin changed the title Fix some general cross compile issues and some darwin specific ones. Tested with build=linux, host=darwin Enable darwin-host cross compilation. Tested with build=linux, host=darwin Oct 21, 2012
    @ronaldoussoren
    Copy link
    Contributor

    The patch itself looks fine, but I wonder how useful it will be.

    A small question about the patch, why this case in the cross_arch function:

    + x86_64*darwin*)
    + echo i386

    That doesn't look correct.

    Back to the more important issue of the usefulness of this patch:

    • Why is cross-compiling to OSX useful at all? You still have to test
      if the output of the compilation works, and for that you need
      an OSX system.

    • The patch will only help with cross-compiling C code, it won't compile
      resource files (like the NIB file in Python Launcher)

      This is not a problem right now because that project currently contains
      older NIB files that can be used for editting and running, but would
      make it harder to move to the more modern XIB files that were introduced
      with Xcode 4.

    • This will make support harder, I already get support questions where
      the answer depends on the way Python was build and that will likely
      get worse with cross-compiling.

    • Where would users get the SDK? I'm not a lawyer (or even familiar with
      US law), but the Xcode license seems to indicate that it can only
      be used on Apple systems.

    @mingwandroid
    Copy link
    Mannequin Author

    mingwandroid mannequin commented Oct 22, 2012

    A small question about the patch, why this case in the cross_arch function:

    From a real Mac Book Pro:

    $ uname -a
    Darwin MACBOOKPRO.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64
    $ /usr/bin/arch
    i386
    $ uname -m
    x86_64

    It would seem arch on OS X can only be used to determine PPC vs Intel (which is all that configure uses it for anyway).

    Why is cross-compiling to OSX useful at all?

    Cross compiling is always useful for build engineers who have to target multiple hosts.

    You still have to test if the output of the compilation works, and for that you need an OSX system.

    Ideally yes, or a Virtual Machine with OSX on it or confidence based on the results of a previous test built with the same sources or maloader (...though maybe not, I've never personally tried maloader).

    The patch will only help with cross-compiling C code, it won't compile resource files (like the NIB file in Python Launcher)

    My personal interest is for having Python embedded in other things (GDB) and using it from the command-line. Python Launcher is not part of the scope.

    This will make support harder, I already get support questions where the answer depends on the way Python was build and that will likely get worse with cross-compiling.

    I'd be happy to do whatever I can to help out with this. If we could identify in the build that it was built via cross compilation somehow or have my email address in the help would that make it more palatable?

    • Where would users get the SDK? I'm not a lawyer (or even familiar with US law), but the Xcode license seems to indicate that it can only be used on Apple systems.

    The users would get the SDK from being registered as a developer with Apple. As for the license, while also not being a lawyer, my interpretation is this:

    In the Xcode License.rtf file (and the Command Line tools license), the relevant part is "you are granted a limited, non-exclusive license to use the Developer Software on Apple-branded computers to develop and test application and other software". This doesn't say anything about the OS that's running on said Apple-branded computer, and my interpretation is that you could install a Linux distro on an Apple computer or on a VM on an Apple computer and still be compliant with that license.

    @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 type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants