Skip to content

Commit

Permalink
support llvm 14
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli committed Dec 26, 2023
1 parent d62daf8 commit d80aaa2
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 26 deletions.
25 changes: 15 additions & 10 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
llvm-version: [11, 13]
llvm-version: [11, 13, 14]
# Testing all levels because there was a bug that only happened with -O1. (#224)
opt-level: ['-O0', '-O1', '-O2', '-O3']
steps:
Expand Down Expand Up @@ -50,24 +50,29 @@ jobs:
doctest:
runs-on: ubuntu-latest
strategy:
matrix:
llvm-version: [11, 13]
steps:
- uses: actions/checkout@v3
- run: sudo apt update
- run: sudo apt install -y llvm-${{ matrix.llvm-version }}-dev clang-${{ matrix.llvm-version }} make
- run: LLVM_CONFIG=llvm-config-${{ matrix.llvm-version }} make
- run: ./doctest.sh
- run: sudo apt install -y llvm-{11,13,14}-dev clang-{11,13,14} make

- run: LLVM_CONFIG=llvm-config-11 ./doctest.sh
- run: make clean
- run: LLVM_CONFIG=llvm-config-13 ./doctest.sh
- run: make clean
- run: LLVM_CONFIG=llvm-config-14 ./doctest.sh

compare-compilers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: sudo apt update
- run: sudo apt install -y llvm-13-dev clang-13 make valgrind
- run: LLVM_CONFIG=llvm-config-13 make
- run: ./compare_compilers.sh
- run: sudo apt install -y llvm-{11,13,14}-dev clang-{11,13,14} make

- run: LLVM_CONFIG=llvm-config-11 ./compare_compilers.sh
- run: make clean
- run: LLVM_CONFIG=llvm-config-13 ./compare_compilers.sh
- run: make clean
- run: LLVM_CONFIG=llvm-config-14 ./compare_compilers.sh

editorconfig-checker:
runs-on: ubuntu-latest
Expand Down
28 changes: 21 additions & 7 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@ jobs:
opt-level: ['-O0', '-O1', '-O2', '-O3']
steps:
- uses: actions/checkout@v3
- run: brew install bash diffutils llvm@13
- run: make
- run: brew install bash diffutils llvm@{13,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: ./runtests.sh --verbose --jou-flags "${{ matrix.opt-level }}"
- run: ./runtests.sh --verbose --jou-flags "${{ matrix.opt-level }} --verbose"
- run: make clean

- name: Check that "make clean" deleted all files not committed to Git
shell: bash
run: |
Expand All @@ -30,13 +39,18 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- run: brew install bash diffutils llvm@13
- run: make
- run: ./doctest.sh
- 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

compare-compilers:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- run: brew install bash diffutils llvm@13
- run: ./compare_compilers.sh
- 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
9 changes: 6 additions & 3 deletions Makefile.posix
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Linux has llvm-config-13/11, on macos brew installs LLVM to a weird place in /usr/local/
# Linux has llvm-config-xx in PATH, where xx is version number
# On macos, brew installs LLVM to a weird place in /usr/local/
LLVM_CONFIG ?= $(shell \
which llvm-config-13 \
which llvm-config-14 \
|| which /usr/local/opt/llvm@14/bin/llvm-config \
|| which llvm-config-13 \
|| which /usr/local/opt/llvm@13/bin/llvm-config \
|| which llvm-config-11 \
|| which /usr/local/opt/llvm@11/bin/llvm-config \
Expand All @@ -20,7 +23,7 @@ compile_flags.txt:
echo "-I$(shell $(LLVM_CONFIG) --includedir)" > compile_flags.txt

config.h:
@v=`$(LLVM_CONFIG) --version`; case "$$v" in 11.*|13.*) ;; *) echo "Error: Found unsupported LLVM version $$v. Only LLVM 11, 13 are supported."; exit 1; esac
@v=`$(LLVM_CONFIG) --version`; case "$$v" in 11.*|13.*|14.*) ;; *) echo "Error: Found unsupported LLVM version $$v. Only LLVM 11, 13 and 14 are supported."; exit 1; esac
echo "// auto-generated by Makefile" > config.h
echo "#define JOU_CLANG_PATH \"$(shell $(LLVM_CONFIG) --bindir)/clang\"" >> config.h

Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ The instructions for developing Jou are in [CONTRIBUTING.md](CONTRIBUTING.md).

1. Install the dependencies:
```
$ sudo apt install git llvm-13-dev clang-13 make
$ sudo apt install git llvm-14-dev clang-14 make
```
Let me know if you use a distro that doesn't have `apt`,
and you need help with this step.
Expand Down Expand Up @@ -94,10 +94,12 @@ The instructions for developing Jou are in [CONTRIBUTING.md](CONTRIBUTING.md).
Note that the `~` character does not work here,
so you need to use a full path (or `$HOME`) instead.
It is also possible to use llvm and clang version 11 instead of 13.
By default, the `make` command decides automatically
whether to use LLVM and clang version 11 or 13,
preferring version 13 if it is installed.
These LLVM/clang versions are supported:
- LLVM 11 with clang 11
- LLVM 13 with clang 13
- LLVM 14 with clang 14
By default, the `make` command picks the latest available version.
You can also specify the version manually by setting the `LLVM_CONFIG` variable:
```
Expand Down
2 changes: 1 addition & 1 deletion src/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void init_target(void)
assert(target.target_ref);

target.target_machine_ref = LLVMCreateTargetMachine(
target.target_ref, target.triple, "x86-64", "", LLVMCodeGenLevelDefault, LLVMRelocDefault, LLVMCodeModelDefault);
target.target_ref, target.triple, "x86-64", "", LLVMCodeGenLevelDefault, LLVMRelocPIC, LLVMCodeModelDefault);
assert(target.target_machine_ref);

target.target_data_ref = LLVMCreateTargetDataLayout(target.target_machine_ref);
Expand Down

0 comments on commit d80aaa2

Please sign in to comment.