diff --git a/self_hosted/target.jou b/self_hosted/target.jou index 491fe16a..cdb02a57 100644 --- a/self_hosted/target.jou +++ b/self_hosted/target.jou @@ -22,50 +22,27 @@ class Target: global target: Target -# 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(): + LLVMInitializeX86TargetInfo() + LLVMInitializeX86Target() + LLVMInitializeX86TargetMC() + LLVMInitializeX86AsmParser() + LLVMInitializeX86AsmPrinter() + + if MACOS: + # Support the new M1 macs. This will enable the target also on x86_64 + # macs, but it doesn't matter. LLVMInitializeAArch64TargetInfo() LLVMInitializeAArch64Target() LLVMInitializeAArch64TargetMC() LLVMInitializeAArch64AsmParser() LLVMInitializeAArch64AsmPrinter() - else: - LLVMInitializeX86TargetInfo() - LLVMInitializeX86Target() - LLVMInitializeX86TargetMC() - LLVMInitializeX86AsmParser() - LLVMInitializeX86AsmPrinter() if WINDOWS: # LLVM's default is x86_64-pc-windows-msvc target.triple = "x86_64-pc-windows-gnu" else: - system("uname -m") - fflush(stdout) - fflush(stderr) - printf("system(...) returns %d\n", system("test `uname -m` = arm64")) - fflush(stdout) - fflush(stderr) triple = LLVMGetDefaultTargetTriple() - fflush(stdout) - fflush(stderr) - printf("triple=\"%s\"\n", triple) - fflush(stdout) - fflush(stderr) assert strlen(triple) < sizeof target.triple strcpy(target.triple, triple) LLVMDisposeMessage(triple) @@ -78,15 +55,10 @@ def init_target() -> None: assert error == NULL assert target.target != NULL - if running_on_arm64_mac(): - arch = "arm64" - else: - arch = "x86-64" - target.target_machine = LLVMCreateTargetMachine( target.target, target.triple, - arch, + "", "", LLVMCodeGenOptLevel::Default, LLVMRelocMode::PIC,