Skip to content

Commit

Permalink
Use -fplt just for AArch64 Linux
Browse files Browse the repository at this point in the history
With the upgrade to clang-19, trampolines are not anymore emitted.
We need to pass -fplt to make use of them.
diegorusso committed Jan 22, 2025

Verified

This commit was signed with the committer’s verified signature.
1 parent a16ded1 commit 707b019
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Tools/jit/_targets.py
Original file line number Diff line number Diff line change
@@ -130,10 +130,6 @@ async def _compile(
"-fno-asynchronous-unwind-tables",
# Don't call built-in functions that we can't find or patch:
"-fno-builtin",
# Emit relaxable 64-bit calls/jumps, so we don't have to worry about
# about emitting in-range trampolines for out-of-range targets.
# We can probably remove this and emit trampolines in the future:
"-fno-plt",
# Don't call stack-smashing canaries that we can't find or patch:
"-fno-stack-protector",
"-std=c11",
@@ -488,12 +484,14 @@ def get_target(host: str) -> _COFF | _ELF | _MachO:
"""Build a _Target for the given host "triple" and options."""
target: _COFF | _ELF | _MachO
if re.fullmatch(r"aarch64-apple-darwin.*", host):
target = _MachO(host, alignment=8, prefix="_")
args = ["-fno-plt"]
target = _MachO(host, alignment=8, args=args, prefix="_")
elif re.fullmatch(r"aarch64-pc-windows-msvc", host):
args = ["-fms-runtime-lib=dll"]
args = ["-fms-runtime-lib=dll", "-fno-plt"]
target = _COFF(host, alignment=8, args=args)
elif re.fullmatch(r"aarch64-.*-linux-gnu", host):
args = [
"-fplt",
"-fpic",
# On aarch64 Linux, intrinsics were being emitted and this flag
# was required to disable them.
@@ -502,18 +500,20 @@ def get_target(host: str) -> _COFF | _ELF | _MachO:
target = _ELF(host, alignment=8, args=args)
elif re.fullmatch(r"i686-pc-windows-msvc", host):
args = [
"-fno-plt",
"-DPy_NO_ENABLE_SHARED",
# __attribute__((preserve_none)) is not supported
"-Wno-ignored-attributes",
]
target = _COFF(host, args=args, prefix="_")
elif re.fullmatch(r"x86_64-apple-darwin.*", host):
target = _MachO(host, prefix="_")
args = ["-fno-plt"]
target = _MachO(host, args=args, prefix="_")
elif re.fullmatch(r"x86_64-pc-windows-msvc", host):
args = ["-fms-runtime-lib=dll"]
args = ["-fms-runtime-lib=dll", "-fno-plt"]
target = _COFF(host, args=args)
elif re.fullmatch(r"x86_64-.*-linux-gnu", host):
args = ["-fpic"]
args = ["-fpic", "-fno-plt"]
target = _ELF(host, args=args)
else:
raise ValueError(host)

0 comments on commit 707b019

Please sign in to comment.