10000 GH-114809: Add support for macOS multi-arch builds with the JIT enabled by savannahostrowski · Pull Request #131751 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-114809: Add support for macOS multi-arch builds with the JIT enabled #131751

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

Merged
merged 27 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
efd5863
First draft of supporting fat builds on macOS with the experimental JIT
ronaldoussoren Feb 20, 2024
4f493cd
merge conflict
savannahostrowski Sep 25, 2024
a55268e
fix up merge
savannahostrowski Sep 25, 2024
bce7980
add fix for CI?;
savannahostrowski Sep 25, 2024
b606b48
Fix up to make generic
savannahostrowski Sep 25, 2024
a382a44
Fix up conditions
savannahostrowski Sep 27, 2024
ff3d363
Save state before merge
savannahostrowski Mar 26, 2025
3bc2820
Merge main and fix conflicts
savannahostrowski Mar 26, 2025
348f2b6
Fix event loop binding error for _CORES in FAT builds
savannahostrowski Mar 26, 2025
4b31a30
📜🤖 Added by blurb_it.
blurb-it[bot] Mar 26, 2025
4564bc4
Try using weakref?
savannahostrowski Mar 26, 2025
2d381ca
Merge branch 'og_fat_build' of https://github.com/savannahostrowski/c…
savannahostrowski Mar 26, 2025
49f86a1
Remove weakref and lazily instantiate cores
savannahostrowski Mar 27, 2025
467ffe1
use Runner
savannahostrowski Apr 3, 2025
fd858bc
Merge branch 'main' into og_fat_build
savannahostrowski Apr 3, 2025
58649ff
Remove conditional and fix indentation in stencils
savannahostrowski Apr 11, 2025
182612c
Merge branch 'og_fat_build' of https://github.com/savannahostrowski/c…
savannahostrowski Apr 11, 2025
30a4d99
Merge branch 'main' into og_fat_build
savannahostrowski Apr 11, 2025
b172a41
CI updates
savannahostrowski Apr 11, 2025
18e77f2
Merge branch 'og_fat_build' of https://github.com/savannahostrowski/c…
savannahostrowski Apr 11, 2025
de3f896
Remove extra space
savannahostrowski Apr 11, 2025
7c22761
Fix condition typo
savannahostrowski Apr 11, 2025
c54250b
undo
savannahostrowski Apr 11, 2025
c21573f
Update jit.yml
savannahostrowski Apr 11, 2025
4332f10
Merge branch 'main' into og_fat_build
savannahostrowski Apr 16, 2025
dd5f196
Merge branch 'main' into og_fat_build
brandtbucher Apr 28, 2025
cdc4bfb
Merge branch 'main' into og_fat_build
savannahostrowski Apr 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Try using weakref?
  • Loading branch information
savannahostrowski committed Mar 26, 2025
commit 4564bc4b4a30e8813cf625df26601cd5d87ec2d0
13 changes: 8 additions & 5 deletions Tools/jit/_llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import shlex
import subprocess
import typing
import weakref

_LLVM_VERSION = 19
_LLVM_VERSION_PATTERN = re.compile(rf"version\s+{_LLVM_VERSION}\.\d+\.\d+\S*\s+")
Expand All @@ -32,14 +33,16 @@ async def wrapper(
return wrapper


_CORES: asyncio.BoundedSemaphore | None = None
_CORES_BY_LOOP: weakref.WeakKeyDictionary[
asyncio.AbstractEventLoop, asyncio.BoundedSemaphore
] = weakref.WeakKeyDictionary()


def _get_cores() -> asyncio.BoundedSemaphore:
global _CORES
if _CORES is None:
_CORES = asyncio.BoundedSemaphore(os.cpu_count() or 1)
return _CORES
loop = asyncio.get_running_loop()
if loop not in _CORES_BY_LOOP:
_CORES_BY_LOOP[loop] = asyncio.BoundedSemaphore(os.cpu_count())
return _CORES_BY_LOOP[loop]


async def _run(tool: str, args: typing.Iterable[str], echo: bool = False) -> str | None:
Expand Down
7 changes: 4 additions & 3 deletions Tools/jit/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
args = parser.parse_args()

if len(args.target) == 1:
args.target.debug = args.debug
args.target.verbose = args.verbose
args.target.build(pathlib.Path.cwd(), comment=comment, force=args.force)
target = args.target[0]
target.debug = args.debug
target.verbose = args.verbose
target.build(pathlib.Path.cwd(), comment=comment, force=args.force)

else:
# Build for multiple targets (e.g. universal2)
Expand Down
18 changes: 9 additions & 9 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2617,50 +2617,50 @@ AS_VAR_IF([ac_cv_gcc_compat], [yes], [
UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
LIPO_32BIT_FLAGS=""
ARCH_RUN_32BIT=""
ARCH_TRIPLES=`echo {ppc,i386}-apple-darwin`
ARCH_TRIPLES=`echo {ppc,i386}-apple-darwin`
;;
64-bit)
UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
LIPO_32BIT_FLAGS=""
ARCH_RUN_32BIT="true"
ARCH_TRIPLES=`echo {ppc64,x86_64}-apple-darwin`
ARCH_TRIPLES=`echo {ppc64,x86_64}-apple-darwin`
;;
all)
UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
ARCH_TRIPLES=`echo {i386,ppc,ppc64,x86_64}-apple-darwin`
ARCH_TRIPLES=`echo {i386,ppc,ppc64,x86_64}-apple-darwin`
;;
universal2)
UNIVERSAL_ARCH_FLAGS="-arch arm64 -arch x86_64"
LIPO_32BIT_FLAGS=""
LIPO_INTEL64_FLAGS="-extract x86_64"
ARCH_RUN_32BIT="true"
ARCH_TRIPLES=`echo {aarch64,x86_64}-apple-darwin`
ARCH_TRIPLES=`echo {aarch64,x86_64}-apple-darwin`
;;
intel)
UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
LIPO_32BIT_FLAGS="-extract i386"
ARCH_RUN_32BIT="/usr/bin/arch -i386"
ARCH_TRIPLES=`echo {i386,x86_64}-apple-darwin`
ARCH_TRIPLES=`echo {i386,x86_64}-apple-darwin`
;;
intel-32)
UNIVERSAL_ARCH_FLAGS="-arch i386"
LIPO_32BIT_FLAGS=""
ARCH_RUN_32BIT=""
ARCH_TRIPLES=i386-apple-darwin
ARCH_TRIPLES=i386-apple-darwin
;;
intel-64)
UNIVERSAL_ARCH_FLAGS="-arch x86_64"
LIPO_32BIT_FLAGS=""
ARCH_RUN_32BIT="true"
ARCH_TRIPLES=x86_64-apple-darwin
ARCH_TRIPLES=x86_64-apple-darwin
;;
3-way)
UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
ARCH_TRIPLES=`echo {i386,ppc,x86_64}-apple-darwin`
ARCH_TRIPLES=`echo {i386,ppc,x86_64}-apple-darwin`
;;
*)
AC_MSG_ERROR([proper usage is --with-universal-arch=universal2|32-bit|64-bit|all|intel|3-way])
Expand Down Expand Up @@ -2776,7 +2776,7 @@ AS_VAR_IF([jit_flags],
[],
[AS_VAR_APPEND([CFLAGS_NODIST], [" $jit_flags"])
AS_VAR_SET([REGEN_JIT_COMMAND],
["\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py ${ARCH_TRIPLES:-host}"])
["\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py ${ARCH_TRIPLES:-$host}"])
AS_VAR_SET([JIT_STENCILS_H], ["jit_stencils.h"])
AS_VAR_IF([Py_DEBUG],
[true],
Expand Down
0