Skip to content

gh-131999: Add support for tvOS, visionOS and watchOS. - #159944

Open
freakboy3742 wants to merge 2 commits into
python:mainfrom
freakboy3742:tvos-watchos-visionos
Open

freakboy3742 wants to merge 2 commits into
python:mainfrom
freakboy3742:tvos-watchos-visionos

Conversation

@freakboy3742

@freakboy3742 freakboy3742 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Adds support for Apple's tvOS, visionOS and watchOS platforms. I've been maintaining these patches independently for a while; I figured I'd try to contribute them upstream.

The support is essentially identical to iOS support, but with different platform identifiers:

  • tvOS -> appletvos and appletvsimulator
  • visionOS -> xros and xrsimulator
  • watchOS -> watchos and watchsimulator

watchOS devices use an arm64_32 architecture that has 32 bit pointers, but 64 bit registers. tvOS and watchOS support both x86_64 and arm64 simulators; visionOS only supports arm64 simulators.

The bulk of the patch (by volume) is the testbed projects and framework skeletons for each new platform.

Usage of the Platform scripts is the same as for iOS; e.g.:

  • python3 Platforms/Apple build tvOS all - build all architectures for tvOS
  • python3 Platforms/Apple test watchOS arm64-apple-watchos-simulator - test for a watchOS simulator
  • python3 Platforms/Apple ci visionOS --fast-ci - Run a fast CI pass (building and running tests) for visionOS.

@corona10

Copy link
Copy Markdown
Member

cc @DinoV It touches the mimalloc codebase also.

// but system registers are 64 bits.
uint64_t tp; MI_UNUSED(ofs);
#if defined(__APPLE__) // M1, issue #343
__asm__ volatile ("mrs %0, tpidrro_el0\nbic %0, %0, #7" : "=r" (tcb));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add comment when you adding downstream code here

Something like:
// CPython: blahblahblach

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this when we upgrade mimalloc to the latest version

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also any chance you could try and upstream this to mimalloc? It seems like it's moved around a little but I think it's here now: https://github.com/microsoft/mimalloc/blob/dev3/include/mimalloc/prim/prim-tls.h#L103C15-L103C19

If we can get it upstreamed into the v3 branch then when we upgrade it'll just be there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a comment; and I've submitted microsoft/mimalloc#1444 to upstream the equivalent change in mimalloc v3.

Comment thread Include/internal/mimalloc/mimalloc/prim.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants