From 51b9799127781ff2d9d3713ab677616a83fe243d Mon Sep 17 00:00:00 2001 From: Akuli Date: Tue, 14 Jan 2025 20:54:58 +0200 Subject: [PATCH] Add support for LLVM 16 (#616) --- .github/workflows/linux.yml | 10 ++++++---- .github/workflows/macos.yml | 2 +- .github/workflows/valgrind.yml | 2 +- Makefile.posix | 7 +++++-- README.md | 3 ++- bootstrap_compiler/jou_compiler.h | 2 +- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 009141b7..c22050f5 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -37,10 +37,10 @@ jobs: test: timeout-minutes: 5 - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: matrix: - llvm-version: [14, 15] + llvm-version: [14, 15, 16] # Testing all levels because there was a bug that only happened with -O1. (#224) opt-level: ['-O0', '-O1', '-O2', '-O3'] steps: @@ -65,12 +65,14 @@ jobs: fi doctest: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@v3 - run: sudo apt update - - run: sudo apt install -y llvm-{14,15}-dev clang-{14,15} make + - run: sudo apt install -y llvm-{14,15,16}-dev clang-{14,15,16} make - run: LLVM_CONFIG=llvm-config-14 ./doctest.sh - run: make clean - run: LLVM_CONFIG=llvm-config-15 ./doctest.sh + - run: make clean + - run: LLVM_CONFIG=llvm-config-16 ./doctest.sh diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 0f9931c1..6e70ab3f 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -10,7 +10,7 @@ jobs: timeout-minutes: 5 strategy: matrix: - llvm-version: [14, 15] + llvm-version: [14, 15, 16] # Testing all levels because there was a bug that only happened with -O1. (#224) opt-level: ['-O0', '-O1', '-O2', '-O3'] steps: diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 3f725c0e..a9f3f434 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -12,7 +12,7 @@ jobs: timeout-minutes: 60 strategy: matrix: - llvm-version: [14, 15] + llvm-version: [14, 15, 16] # Testing all levels because there was a bug that only happened with -O1. (#224) opt-level: ['-O0', '-O1', '-O2', '-O3'] fail-fast: false diff --git a/Makefile.posix b/Makefile.posix index 67c6f295..76a72553 100644 --- a/Makefile.posix +++ b/Makefile.posix @@ -2,7 +2,10 @@ # On macos, brew installs LLVM to a weird place in /usr/local/ # On NetBSD, use llvm-config from libLLVM (package from pkgsrc) LLVM_CONFIG ?= $(shell \ - which llvm-config-15 \ + which llvm-config-16 \ + || which /usr/local/opt/llvm@16/bin/llvm-config \ + || which /opt/homebrew/opt/llvm@16/bin/llvm-config \ + || which llvm-config-15 \ || which /usr/local/opt/llvm@15/bin/llvm-config \ || which /opt/homebrew/opt/llvm@15/bin/llvm-config \ || which llvm-config-14 \ @@ -33,7 +36,7 @@ config.h: echo "#define JOU_CLANG_PATH \"$(CC)\"" >> config.h config.jou: - @v=`$(LLVM_CONFIG) --version`; case "$$v" in 14.*|15.*) ;; *) echo "Error: Found unsupported LLVM version $$v. Only LLVM 14 and 15 are supported."; exit 1; esac + @v=`$(LLVM_CONFIG) --version`; case "$$v" in 14.*|15.*|16.*) ;; *) echo "Error: Found unsupported LLVM version $$v. Only LLVM 14, 15 and 16 are supported."; exit 1; esac echo "# auto-generated by Makefile" > config.jou echo "def get_jou_clang_path() -> byte*:" >> config.jou echo " return \"$(CC)\"" >> config.jou diff --git a/README.md b/README.md index 90a739e9..fdedd453 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ The instructions for developing Jou are in [CONTRIBUTING.md](CONTRIBUTING.md). 1. Install the dependencies: ``` - $ sudo apt install git llvm-15-dev clang-15 make + $ sudo apt install git llvm-16-dev clang-16 make ``` Let me know if you use a distro that doesn't have `apt`, and you need help with this step. @@ -121,6 +121,7 @@ The instructions for developing Jou are in [CONTRIBUTING.md](CONTRIBUTING.md). These LLVM/clang versions are supported: - LLVM 14 with clang 14 - LLVM 15 with clang 15 +- LLVM 16 with clang 16 By default, the `make` command picks the latest available version. You can also specify the version manually by setting the `LLVM_CONFIG` variable: diff --git a/bootstrap_compiler/jou_compiler.h b/bootstrap_compiler/jou_compiler.h index c00ad5a7..47f2f0c5 100644 --- a/bootstrap_compiler/jou_compiler.h +++ b/bootstrap_compiler/jou_compiler.h @@ -431,7 +431,7 @@ extern const Type *byteType; // byte (8-bit unsigned) extern const Type *floatType; // float (32-bit) extern const Type *doubleType; // double (64-bit) extern const Type *voidPtrType; // void* -void init_types(); // Called once when compiler starts +void init_types(void); // Called once when compiler starts const Type *get_integer_type(int size_in_bits, bool is_signed); const Type *get_pointer_type(const Type *t); // result lives as long as t const Type *get_array_type(const Type *t, int len); // result lives as long as t