Skip to content

Commit

Permalink
fixening
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli committed Jan 8, 2025
1 parent b0dd0de commit 36ee5cd
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions self_hosted/target.jou
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,34 @@ class Target:

global target: Target

def init_target() -> None:
LLVMInitializeX86TargetInfo()
LLVMInitializeX86Target()
LLVMInitializeX86TargetMC()
LLVMInitializeX86AsmParser()
LLVMInitializeX86AsmPrinter()

if MACOS:
# Needed when compiling for new macs with the M1 chip
# This function is a bit of a hack.
#
# Ideally, we would initialize all available targets, or perhaps only the
# native target, but information about supported targets is only in the C
# header files. If we initialize the wrong target, the code will compile, but
# it prints a warning message like this at runtime, every time you invoke the
# Jou compiler:
#
# 'x86-64' is not a recognized processor for this target (ignoring processor)
#
def running_on_arm64_mac() -> bool:
return MACOS and system("test `uname -m` = arm64") == 0


def init_target() -> None:
if running_on_arm64_mac():
LLVMInitializeAArch64TargetInfo()
LLVMInitializeAArch64Target()
LLVMInitializeAArch64TargetMC()
LLVMInitializeAArch64AsmParser()
LLVMInitializeAArch64AsmPrinter()
else:
LLVMInitializeX86TargetInfo()
LLVMInitializeX86Target()
LLVMInitializeX86TargetMC()
LLVMInitializeX86AsmParser()
LLVMInitializeX86AsmPrinter()

if WINDOWS:
# LLVM's default is x86_64-pc-windows-msvc
Expand Down

0 comments on commit 36ee5cd

Please sign in to comment.