Skip to content

Commit 081ee86

Browse files
fno-pic
1 parent 57c44ee commit 081ee86

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

Python/jit.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,9 @@ patch_32r(unsigned char *location, uint64_t value)
217217
// Check that we're not out of range of 32 signed bits:
218218
assert((int64_t)value >= -(1LL << 31));
219219
#if defined(__APPLE__) && defined(Py_DEBUG)
220-
// On macOS debug builds with LLVM 20, external symbols may be out of range.
221-
// This is handled by GOT indirection, so we allow the truncation here.
222-
// Release builds (-O3) don't have this issue due to better optimization.
220+
// LLVM 20 on macOS debug builds: GOT entries may exceed ±2GB PC-relative
221+
// range. Truncation is safe as the target is a GOT trampoline.
223222
if ((int64_t)value >= (1LL << 31)) {
224-
// Truncate to 32-bit; the GOT entry will handle the indirection
225223
value = (uint32_t)value;
226224
}
227225
#else

Tools/jit/_targets.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,9 @@ def get_target(host: str) -> _COFF32 | _COFF64 | _ELF | _MachO:
585585
elif re.fullmatch(r"x86_64-apple-darwin.*", host):
586586
host = "x86_64-apple-darwin"
587587
condition = "defined(__x86_64__) && defined(__APPLE__)"
588+
args = ["-fno-pic"]
588589
optimizer = _optimizers.OptimizerX86
589-
target = _MachO(host, condition, optimizer=optimizer)
590+
target = _MachO(host, condition, args=args, optimizer=optimizer)
590591
elif re.fullmatch(r"x86_64-pc-windows-msvc", host):
591592
host = "x86_64-pc-windows-msvc"
592593
condition = "defined(_M_X64)"

0 commit comments

Comments
 (0)