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

M1 Python #1547

Closed
Tracked by #1299
DanAlbert opened this issue Jul 26, 2021 · 6 comments
Closed
Tracked by #1299

M1 Python #1547

DanAlbert opened this issue Jul 26, 2021 · 6 comments

Comments

@DanAlbert
Copy link
Member

Subtask for #1299

@rprichard
Copy link
Collaborator

I think our Python3 is already a fat binary:

$ file /x/ndk/prebuilts/python3/darwin/bin/python3.9
/x/ndk/prebuilts/python3/darwin/bin/python3.9: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>] [arm64:Mach-O 64-bit arm64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>]

https://android.googlesource.com/platform/external/python/cpython3/+/24cdfe16599af4bed00f790584d696493c45afab/kokoro/build.py#57:

    if host == Host.Darwin:
        sdkroot = env.get('SDKROOT')
        if sdkroot:
            print("Using SDK {}".format(sdkroot))
            config_cmd.append('--enable-universalsdk={}'.format(sdkroot))
        else:
            config_cmd.append('--enable-universalsdk')
        config_cmd.append('--with-universal-archs=universal2')

        MAC_MIN_VERSION = '10.9'
        cflags.append('-mmacosx-version-min={}'.format(MAC_MIN_VERSION))
        cflags.append('-DMACOSX_DEPLOYMENT_TARGET={}'.format(MAC_MIN_VERSION))
        cflags.extend(['-arch', 'arm64'])
        cflags.extend(['-arch', 'x86_64'])
        env['MACOSX_DEPLOYMENT_TARGET'] = MAC_MIN_VERSION
        ldflags.append("-Wl,-rpath,'@loader_path/../lib'")

@DanAlbert
Copy link
Member Author

We're shipping the one from prebuilts/ndk/python

$ file ../prebuilts/ndk/python/darwin-x86_64/bin/python
../prebuilts/ndk/python/darwin-x86_64/bin/python: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>

It's also still Python 2 to support GDB. In r24 we can drop that since we dropped GDB. For r23 we may need to ship both, or just allow the small part of the build where ndk-build is running Python to be Rosetta.

@enh-google
Copy link
Collaborator

For r23 we may need to ship both, or just allow the small part of the build where ndk-build is running Python to be Rosetta.

are you planning on "backporting" all the universal binaries to the r23 LTS then? i was actually assuming we wouldn't (unless something drastic happens, like devices shipping without Rosetta2 while r23 is still "the" LTS)?

or did you just mean "r23 will have both python2 and python3 for different reasons" and i'm reading too much into this because of the specific bug title? :-)

@DanAlbert
Copy link
Member Author

are you planning on "backporting" all the universal binaries to the r23 LTS then?

I was planning on at least trying. We have a compatible toolchain available. Unless making make/cmake/ninja M1 compatible ends up being invasive getting those four components to support M1 does most of what anyone actually cares about, I think. The rest of them are less interesting though since they're not in the build hot path.

@DanAlbert
Copy link
Member Author

We have python 3 in the NDK already at toolchains/llvm/prebuilt/linux-x86_64/python3/bin/python3, so we should be able to fix ndk-build to use that instead of python 2.

@DanAlbert
Copy link
Member Author

I think the only change we need to cherry pick for r23c is https://android-review.googlesource.com/c/platform/ndk/+/1892798

foxsen pushed a commit to android-la64/platform-ndk that referenced this issue Oct 10, 2024
Test: None
Bug: android/ndk#1547
Change-Id: I4b59e4c3d5a97c647e986dded23532e45a4308f2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants