diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 1d08b5e9..eb1c64e2 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -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: @@ -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 diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 72bad46c..32cc77b0 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -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: | @@ -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 diff --git a/Makefile.posix b/Makefile.posix index 43fc81ee..a9cab3a9 100644 --- a/Makefile.posix +++ b/Makefile.posix @@ -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 \ @@ -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 diff --git a/README.md b/README.md index cf2eca9a..1d205bf4 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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: ``` diff --git a/src/target.c b/src/target.c index d82af995..8d4c303c 100644 --- a/src/target.c +++ b/src/target.c @@ -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);