Skip to content

Commit

Permalink
MacOS fixes (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli authored Jan 8, 2025
1 parent dd5ef57 commit 73067fd
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 23 deletions.
25 changes: 6 additions & 19 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
3 changes: 3 additions & 0 deletions Makefile.posix
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
```
Expand Down
7 changes: 7 additions & 0 deletions self_hosted/llvm.jou
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down
12 changes: 11 additions & 1 deletion self_hosted/target.jou
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,23 @@ class Target:

global target: Target


def init_target() -> None:
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()

if WINDOWS:
# LLVM's default is x86_64-pc-windows-msvc
target.triple = "x86_64-pc-windows-gnu"
Expand All @@ -48,7 +58,7 @@ def init_target() -> None:
target.target_machine = LLVMCreateTargetMachine(
target.target,
target.triple,
"x86-64",
"",
"",
LLVMCodeGenOptLevel::Default,
LLVMRelocMode::PIC,
Expand Down

0 comments on commit 73067fd

Please sign in to comment.