diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 56669adf..ba08e897 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -14,16 +14,9 @@ jobs: opt-level: ['-O0', '-O1', '-O2', '-O3'] steps: - uses: actions/checkout@v3 - - run: brew install bash diffutils llvm@{13,14} + - run: brew install bash diffutils llvm@14 - - name: Compile with LLVM 13 - run: LLVM_CONFIG=/usr/local/opt/llvm@13/bin/llvm-config make - - run: ./runtests.sh --verbose --jou-flags "${{ matrix.opt-level }}" - - run: ./runtests.sh --verbose --jou-flags "${{ matrix.opt-level }} --verbose" - - run: make clean - - - name: Compile with LLVM 14 - - run: LLVM_CONFIG=/usr/local/opt/llvm@14/bin/llvm-config make + - run: make - run: ./runtests.sh --verbose --jou-flags "${{ matrix.opt-level }}" - run: ./runtests.sh --verbose --jou-flags "${{ matrix.opt-level }} --verbose" - run: make clean @@ -41,19 +34,13 @@ jobs: timeout-minutes: 5 steps: - uses: actions/checkout@v3 - - run: brew install bash diffutils llvm@{13,14} - - - run: LLVM_CONFIG=/usr/local/opt/llvm@13/bin/llvm-config ./doctest.sh - - run: make clean - - run: LLVM_CONFIG=/usr/local/opt/llvm@14/bin/llvm-config ./doctest.sh + - run: brew install bash diffutils llvm@14 + - run: ./doctest.sh compare-compilers: runs-on: macos-latest timeout-minutes: 5 steps: - uses: actions/checkout@v3 - - run: brew install bash diffutils llvm@{13,14} - - - run: LLVM_CONFIG=/usr/local/opt/llvm@13/bin/llvm-config ./compare_compilers.sh - - run: make clean - - run: LLVM_CONFIG=/usr/local/opt/llvm@14/bin/llvm-config ./compare_compilers.sh + - run: brew install bash diffutils llvm@14 + - run: ./compare_compilers.sh diff --git a/Makefile.posix b/Makefile.posix index 72907ca3..fcbb3f3f 100644 --- a/Makefile.posix +++ b/Makefile.posix @@ -4,10 +4,13 @@ LLVM_CONFIG ?= $(shell \ which llvm-config-14 \ || which /usr/local/opt/llvm@14/bin/llvm-config \ + || which /opt/homebrew/opt/llvm@14/bin/llvm-config \ || which llvm-config-13 \ || which /usr/local/opt/llvm@13/bin/llvm-config \ + || which /opt/homebrew/opt/llvm@13/bin/llvm-config \ || which llvm-config-11 \ || which /usr/local/opt/llvm@11/bin/llvm-config \ + || which /opt/homebrew/opt/llvm@11/bin/llvm-config \ || which /usr/pkg/libexec/libLLVM/llvm-config \ ) CFLAGS += $(shell $(LLVM_CONFIG) --cflags) diff --git a/README.md b/README.md index 9b97068e..92080718 100644 --- a/README.md +++ b/README.md @@ -121,12 +121,12 @@ $ LLVM_CONFIG=llvm-config-11 make MacOS support is new. Please create an issue if something doesn't work. -1. Install Git, make and LLVM 13. +1. Install Git, make and LLVM 14. If you do software development on MacOS, you probably already have Git and make, because they come with Xcode Command Line Tools. - You can use [brew](https://brew.sh/) to install LLVM 13: + You can use [brew](https://brew.sh/) to install LLVM 14: ``` - $ brew install llvm@13 + $ brew install llvm@14 ``` 2. Download and compile Jou. ``` diff --git a/self_hosted/llvm.jou b/self_hosted/llvm.jou index ed5e4342..2ba1c439 100644 --- a/self_hosted/llvm.jou +++ b/self_hosted/llvm.jou @@ -29,6 +29,13 @@ declare LLVMInitializeX86AsmPrinter() -> None declare LLVMInitializeX86AsmParser() -> None declare LLVMInitializeX86Disassembler() -> None +declare LLVMInitializeAArch64TargetInfo() -> None +declare LLVMInitializeAArch64Target() -> None +declare LLVMInitializeAArch64TargetMC() -> None +declare LLVMInitializeAArch64AsmPrinter() -> None +declare LLVMInitializeAArch64AsmParser() -> None +declare LLVMInitializeAArch64Disassembler() -> None + declare LLVMDisposeTargetData(TD: LLVMTargetData*) -> None declare LLVMCopyStringRepOfTargetData(TD: LLVMTargetData*) -> byte* diff --git a/self_hosted/target.jou b/self_hosted/target.jou index 3495d676..cdb02a57 100644 --- a/self_hosted/target.jou +++ b/self_hosted/target.jou @@ -21,6 +21,7 @@ class Target: global target: Target + def init_target() -> None: LLVMInitializeX86TargetInfo() LLVMInitializeX86Target() @@ -28,6 +29,15 @@ def init_target() -> None: 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() + if WINDOWS: # LLVM's default is x86_64-pc-windows-msvc target.triple = "x86_64-pc-windows-gnu" @@ -48,7 +58,7 @@ def init_target() -> None: target.target_machine = LLVMCreateTargetMachine( target.target, target.triple, - "x86-64", + "", "", LLVMCodeGenOptLevel::Default, LLVMRelocMode::PIC,